What is different from hlint, hdevtools and ghc-mod

I am looking for lint code, query type, auto type-insert and misc helper for use with vim (e.g. autocomplete).

After some research, I found some similar tools that migth do what I want

  • hlint
  • hdevtools
  • ghc-mod

The main question is, Are these all basically the same tool?

When I do some testing, I find that only ghc-mod works ready (for lint code, havn't try any helper type function)

$ cat test.hs main = putStrLn "test" $ ghc-mod check test.hs test.hs:1:1:Warning: Top-level binding with no type signature: main :: IO () $ hdevtools check test.hs Run from outside a project, using implicit global project config $ hlint test.hs No hints 

Do I need to create a configuration file for hlint and hdevtools?

 $ hdevtools --version hdevtools: version 0.1.4.1 (ghc-8.0.1-x86_64-linux, cabal-1.24.0.0) $ hlint --version HLint v1.9.35, (C) Neil Mitchell 2006-2016 $ ghc-mod --version ghc-mod version 5.6.0.0 compiled by GHC 8.0.1 $ ghc --version The Glorious Glasgow Haskell Compilation System, version 8.0.1 

All tools were installed by stack install and I have /home/wizzup/.local/bin in $PATH

+6
source share
1 answer

ghc-mod installs a binary called ghc-mod on your $PATH , which can load and query your package database and source code (there is also an "interactive" version called ghc-modi , which is read in commands from the standard inside and adheres to ) For this, the GHC and Cabal APIs are used. Progress stalled for a while, but now returned to a fussy state. There are Emacs / Vim / Sublime packages that can talk to ghc-mod and provide various functions similar to the IDE for end users: typechecking, holes, search / proof search, find-definition.

hdevtools is a newer project inspired by ghc-mod . It is similar in architecture to a permanent background server with packages for each editor. It is designed to completely replace ghc-mod . The differences between ghc-mod and hdevtools seem philosophical. hdevtools has less fash ghc-mod features, but (in my experience) much faster. Something that went hdevtools quick look at code bases: hdevtools seems to rely on the GHC API to implement a GHCi-like server that can quickly reload code. Perhaps this was the key to getting good performance? I am sure that I greatly simplify.

hlint very different. This is an old old project (started in 2006 by Neil Mitchell, one of the elders of the Haskell community). He is able to detect Haskell's typical bad habits (for example, using concat . map instead of concatMap ) and in some cases it is easy to reorganize them. It relies on haskell-src-exts , which parses Haskell code in AST. I believe that hlint does not even require a full check of the code base code: it can only consider an abstract syntax tree to suggest changes and sound warnings. Usually you choose ghc-mod or hdevtools and use them in combination with hlint to get the full experience of the Haskell IDE.

We have to spend time here to also mention the FP Complete intero , which runs ghci and is similar to hdevtools . However, this only works if your Emacs editor and you use the stack. I could not find good documentation on how it differs from ghc-mod or hdevtools ; one suggests that it was intended to give Emacs users a better experience, as you might get in a situation where hdevtools / ghc-mod will stubbornly refuse to work due to a compiler or a mismatch in the package editor. With intero you can get up and work with a small piece of Elisp.

This is a big old mess!

+14
source

Source: https://habr.com/ru/post/1011479/


All Articles