GHCi, or GHC interactive, is the interactive shell (or REPL) for GHC Haskell. It’s a surprisingly featureful and useful tool that is invaluable in our day to day work, along with ghcid. We are constantly exploring what we can do with GHCi and finding new tools waiting there for us. The section of the GHC User Manual that covers using GHCi has more information than we’re going to explain here – but also less, in some cases, as is often the case with technical documentation. This series will show off how we, a couple of experienced and mostly happy Haskellers, use GHCi, rather than trying to be absolutely comprehensive. Since we use it a lot, it covers more than you may suspect is there to cover.
GHCi is fast. One of the most common complaints about statically typed languages is that, while catching errors at compile time is nice and all, having to compile all the time forces a lengthy feedback loop. You change some things and then compile and then finally get back the errors telling you what to fix. It can seem like an unnecessary burden. The secret is neither we nor most of the Haskellers we know compile their code very often; instead, we interpret! You still get the compiler errors as if you compiled the code but on a much shorter – essentially immediate – time frame.
This series explains the many features GHCi provides, starting with a basic overview of how to use it. And if you want to start off by customizing your GHCi prompt so that you, too, have a lambda prompt, you can start by reading about GHCi configuration if you like. We won’t lie: it was also one of the first things we did when we started using Haskell!