How are `ghc-pkg` and `cabal` programs related? (Haskell)
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?
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.
精彩评论