简体   繁体   English

`ghc-pkg`和`cabal`程序如何相关? (Haskell的)

[英]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 . 据我所知, cabal是一个管理FreeBSD的pkg_add等软件包安装的程序。 But there is another tool called ghc-pkg . 但还有另一种叫做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". Cabal是Haskell的建筑和包装库,有点像“Haskell autotools”。 It reads .cabal files and Haskell packages usually have a file Setup.hs which uses Cabal to build the package. 它读取.cabal文件和Haskell包通常有一个文件Setup.hs ,它使用Cabal来构建包。 Then there's also cabal command provided by the cabal-install package. 然后还有cabal-install软件包提供的cabal命令。 It provides commands for running Setup.hs script and some package management functions, like installing packages directly from Hackage. 它提供了运行Setup.hs脚本和一些包管理功能的命令,比如直接从Hackage安装包。 You should read this blogpost by Ivan Miljenovic which explains the role of Cabal, cabal-install and Hackage quite well. 你应该阅读Ivan Miljenovic的这篇博文 ,其中很好地解释了Cabal,cabal-install和Hackage的作用。

ghc-pkg is a lower-level tool for poking GHC's package database. ghc-pkg是一个用于调用GHC包数据库的低级工具。 Cabal is intended to work with every Haskell compiler, whereas ghc-pkg is obviously specific to GHC. Cabal旨在与每个Haskell编译器一起使用,而ghc-pkg显然特定于GHC。 You can't use ghc-pkg to build anything, you can just register packages you've built otherwise. 你不能使用ghc-pkg来构建任何东西,你可以只注册你已经构建的包。

cabal is just an interface layer to ghc-pkg with some added features. cabal只是ghc-pkg的一个界面层,增加了一些功能。 It's only important to know ghc-pkg because uninstall functionality was not added to cabal, but can be done directly with ghc-pkg. 了解ghc-pkg非常重要,因为卸载功能未添加到cabal,但可以直接使用ghc-pkg完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM