Using Emacs for Haskell development
github.com
github.com
I have been using various Lisps professionally since 1981 and the more I use Haskell, it seems like just another Lisp but with a different syntax, because of the interactive, bottom up development style.
I've always wondered why functional programming-people seem to prefer emacs over vim? I guess it could be the choice for people wanting more IDE-like features, and aren't afraid of a little bloat(cause surely it can't just be the lisp in the configs), am I right?
I think the reason for Emacs dominance is mostly historical: early on it was probably due to good capability for integrating a REPL process. Also since it is written in a lisp and can be grown organically to fit almost any purpose it developed an ecosystem of useful tools more quickly than Vim - attracting more developers who further developed tooling.
Today the only feature you can't get in Vim that Emacs has is structured haskell mode. I haven't used that enough to know if its worth the switch...
I DID try to switch and while none of this is a real show-stopper and it all could be fixed - I spent a dozen hours on trying to get an Emacs setup with all the features I have in Vim and simply couldn't. For example the auto-complete plugins do not list the type signatures in the pop-up window like neco-ghc does and there is nothing that comes close to fugitive. Also Emacs has an hdevtools plugin for flycheck but I doubt its used much because it doesn't even have a way to pass command line arguments so I had to go hack that in myself. Hdevtools is a killer feature, having instant compilation feedback is incredibly useful in Haskell...it makes it so easy to use the type system interactively while designing a new module. I did get hdevtools to work eventually but I would have to learn emacs lisp to get it working right and since there are other gaps I never put in the effort. I could never figure out how to launch a ghci process with custom arguments...I want the damn REPL to be launched with cabal repl so that it has the same environment as my code and ... I'm sure its easy if you know what you are doing, but I spent at least a couple of hours on that alone and failed. I spent probably 3-4 hours getting Evil working the way I want, things like imap keybinds required a lot of research for some reason. I did get it to work though...Emacs without Evil is not even a contender in mind - modal editing is just way to powerful and my left pinky will be out the goddamn door if I make it pound chords all day.
(Oh, and parenthetically, I would mention that rebinding your Caps Lock key to an additional Control key helps a lot with the pinky situation. Sure, you still work that finger harder than you do with a modal editor, but you no longer have to cramp your hand to do so, and after a little while getting used to it -- I advise disabling the "real" Control key, or rebinding it to do nothing but emit a nasty noise -- you no longer think about it at all.)
I have never used fugitive, but I can't imagine being unhappy with Magit? What makes fugitive so much better?
For some time I wanted dive into haskell, and could not afford time, but recently I am getting some time freed up.
Can you suggest, how to set up vim for haskell like any plugins or scripts for better development experience.
As a side not this video(https://www.youtube.com/watch?v=ScS8Q32lMxA) of live haskell coding in vim looks interesting.
With one install command, you get a polished Vim/Haskell setup with tab completion, type inspection, Hoogle, hinting, unicode symbols, etc.
Also has a nice dark theme. In fact, I use it as my go-to Vim configuration on new systems, even outside of Haskell.
It also lets you pipe code to the Haskell REPL for live evaluation (via tmux).
[1] https://github.com/begriffs/haskell-vim-now [2] https://www.youtube.com/watch?v=7sr8cAIwdBs
EDIT: Add video
Hehe. The "linux tiling wm" and "emacs-like editor" fads were cooler the current one ("our own javascript ui framework").