Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run HLint?

Tags:

haskell

hlint

I'm only a few weeks in to programming with Haskell. I was told to use HLint to improve my code. The problem is I can't figure out how to run HLint against my .hs file. I read the documentation and I was able to install it using cabal install hlint. The next step is running HLint using hlint myfile.hs. I can't figure our where to type this line. Neither cmd nor ghci will let me run the command. What am I missing here?

I'm using windows.

edit:

I just removed Haskell and installed it again on my system. I think the problem is with my Haskell installation. Thats what I'm getting when I try to install HLint again: enter image description here

The file does exsist in C:\Users\PCPCPCCP\AppData\Roaming\cabal\setup-exe-cache

edit2:

Seems like hlint wasn't installed correctly. Even after reinstalling the haskell platform I am not able to install hlint it on my system. I did work on my virtual machine however...

like image 621
isADon Avatar asked Nov 27 '14 20:11

isADon


3 Answers

Just run it on top of the Haskell file:

hlint filename.hs

You have to run that from the terminal in Linux or the PowerShell/CMD.exe in Windows.

A sample demo from my PC:

$ hlint gem.hs
gem.hs:9:9: Warning: Use void
Found:
  print "if" >> return ()
Why not:
  void (print "if")

gem.hs:10:9: Warning: Use void
Found:
  print "else" >> return ()
Why not:
  void (print "else")

2 suggestions
like image 125
Sibi Avatar answered Nov 19 '22 01:11

Sibi


You need to export the folder of cabal that stores all installed binaries in your environment variable PATH, i.e.,

export PATH="$PATH:$HOME/.cabal/bin/"

like image 2
Zouzias Avatar answered Nov 19 '22 02:11

Zouzias


I just run it like this

hlint src/

where "src/" is the directory defined in the hs-source-dirs: line in my .cabal file.

like image 1
jamshidh Avatar answered Nov 19 '22 01:11

jamshidh