My old Haskell workflow was having a tmux window split into two panes, one with Vim, one with GHCi loaded (with different modules). When making relevant changes, I jumped to the GHCi window and typed
:r. I have no issues with this workflow, but one jump less is more… civilized.
Now I have a similar approach. Assume a Haskell project located in SomeProject.hs (including the main function) and just write,
ghcid --command 'ghci SomeFile.hs' --test :main
Every saved change in your editor will immediately force a type check and run the main function. If the project contains errors, you see errors with the usual GHCi view. And if no errors exist, your project runs. This is especially suited for projects involving some kind of visual interface.
Recently I was told by a colleague, that Stack includes a flag for re-compiling (even re-running) on changes, however, for some reason, you must also press a key (any key). Therefore I think the GHCid procedure is more pleasant. You can combine this with Stack projects as well,
ghcid --command 'stack ghci app/Main.hs' --test :main
It’s not naive efficiency measured in time that please me the most – rather, vaguely put, the user experience and if you will, making it more ergonomic.
This is a demo of an less advanced use, only using GHCid for instant GHCi type checking.
ghcid --command 'ghci hello.hs'
Still, it doesn’t seem very far-fetched that this means one less cognitive barrier.
Whenever we are hindered in going from thought to action, chances are that we may lose the thought and have to think once more to obtain it. An at times frustrating process, even though we usually are fully capable of keeping thoughts. But every unrelated and unimportant interruption to a thought process should be, if possible, removed. Indeed only a regulative idea which is balanced against others, but an important one.