Cabal is the defacto build tool for building packages in the haskell universe. Unfortunately, it was not designed to be a package manager for haskell and has some limitations. The most recent improvement to cabal was the introduction of cabal sandboxes, which goes a long way to help haskell developers avoid the infamous cabal hell.
Still, the utilities for cabal sandbox are generally rough on the edges, so here’s a few shell functions and wrapper functions I have written to make it easier to automate the management of cabal sandbox environment – https://github.com/calvinchengx/cabalenv
It works much like python’s virtualenv/virtualenvwrapper, you can easily switch to a particular cabal environment with a single command and set your cabal sandbox’s bin directory into your `$PATH`.
A few convenient wrapper functions like `ghcis`, `ghc` and `runhaskells` (notice the “s”) also help us avoid specifying the `-package-db` flag everytime we want `ghci` or `ghc` or `runhaskell` to use the cabal sandbox package database. `cabal exec — runhaskell` does the same thing of course, but I am just too lazy to type such lengthy command.
So there you go, a simple shell script (`zsh` at the moment) to simplify the management of my cabal sandbox environment for my haskell projects and experiments.