As I know cabal
is a program to manage installation of packages like FreeBSD's pkg_add
.
But there is another tool called ghc-pkg
. I don't know why there are two different programs. What's the role of each of them and how are they related?
This tool is perhaps most often used for uninstalling unneeded packages and those packages that are incompatible with packages that the user wants to install. It is also used for checking which packages are installed or have been broken by installs of other packages.
If you don't need a fully partitioned GHC environment and are happy with the installed versions on DICE, cabal might be the simplest way to install the Haskell packages you require. By default stack installs packages to ~/. cabal and ~/. ghc in your home directory.
To install the cabal executable you can use ghcup (if you're using Linux), the Haskell Platform, install the cabal-install package from your distributions package manager (if using Linux or Mac), or download the source or prebuilt binary from the Download page.
Cabal is a building and packaging library for Haskell, kind of "Haskell autotools". It reads .cabal
files and Haskell packages usually have a file Setup.hs
which uses Cabal to build the package. Then there's also cabal
command provided by the cabal-install package. It provides commands for running Setup.hs
script and some package management functions, like installing packages directly from Hackage. You should read this blogpost by Ivan Miljenovic which explains the role of Cabal, cabal-install and Hackage quite well.
ghc-pkg
is a lower-level tool for poking GHC's package database. Cabal is intended to work with every Haskell compiler, whereas ghc-pkg is obviously specific to GHC. You can't use ghc-pkg to build anything, you can just register packages you've built otherwise.
cabal is just an interface layer to ghc-pkg with some added features. It's only important to know ghc-pkg because uninstall functionality was not added to cabal, but can be done directly with ghc-pkg.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With