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:
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...
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
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/"
I just run it like this
hlint src/
where "src/" is the directory defined in the hs-source-dirs: line in my .cabal file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With