Haskell - My setup/Workflow

Posted on November 25, 2019

Tools:

My setup matches my personality and that is I always go for the bare minimum. I download all these tools using nixpkgs and I enable haskell-mode in doom-emacs. That’s it! I start writing Haskell.

Once I start writing Haskell I have another terminal open that runs ghcid. It has very fast development feedback loop, it’s how I know if my types are matching. I use typed-holes heavily so ghcid can tell me what types I need for a section of my code.

Here’s a contrived example

This will be ghcid’s response in the repl

This tells me that I need a function that takes two Integer that also outputs an Integer. This even tells me the “Relevant bindings” and “Valid hole fits” which is amazing. ghcid helps as much as it can. This flow goes a very long way. It starts getting hazy for me when it comes to lens errors, but I’m sure if I use lens more often I’ll be able to decipher what ghcid is telling me much quickly. This even works in the type level.

ghcid repl will respond with

ghcid is the reason I don’t use any IDE or any fancy editor plugins. I only have syntax highlighting and some formatting in my emacs.

When it comes to actually running my code I usually use cabal. After ghcid tells me my code is clear I run

Sometimes I use stack because of yesod. That’s mostly for work.

I’m aware of the holy war between stack, cabal, and nix, I hope this blog doesn’t get involved in that war. I use all of them. They all have a spot in my workflow.