Haskell Cabal v2和沙盒 [英] Haskell Cabal v2 and Sandbox

查看:107
本文介绍了Haskell Cabal v2和沙盒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们被告知,这现在是用于管理用户定义的沙箱的cabal传统模式:

We are told that this is now legacy mode of cabal, to manage a user-defined sandbox:

cabal init sandbox
cabal install <some stuff>

稍后根据您的判断使用

cabal exec bash

问题:使用Cabal的新实现如何执行等效操作?

Question: How is an equivalent operation performed using the new implementation of Cabal?

该文档(目前而言)非常神秘,使用示例为零。

The documentation is (as it currently stands) very cryptic with zero usage example. That would be helpful to facilitate migration.

当前正在考虑将Cabal 2.4.0.0与GHC 8.6.5结合起来。

Currently contemplating Cabal 2.4.0.0 with GHC 8.6.5.

推荐答案

没有沙箱。您可以安装软件包,然后使用 v2-install v2-install --lib 将其最终存储在用户的阴谋商店中。让我们使用cabal安装一些软件包:

There are no sandboxes. You can install packages and they end up in the user's cabal store using v2-install and v2-install --lib. Let's use cabal to install a few packages:

cabal v2-udpate
cabal v2-install --lib generic-trie containers

现在我们可以从GHCi中的这些软件包中加载模块了:

Now we can load modules from these packages in GHCi:

ghci
> import Data.GenericTrie
> import Data.Map

为什么这样做?因为 cabal v2-install --lib 修改了GHCi用来加载软件包的默认环境。该文件位于 .ghc / x86_64-linux-8.6.5 / environments / default

Why does this work? Because the cabal v2-install --lib modifies the default environment GHCi looks at to load packages. This file is found at .ghc/x86_64-linux-8.6.5/environments/default.

您可以随时删除环境文件以开始全新的工作。如果cabal告诉您某些软件包与先前的软件包有相互依赖的依赖关系,这将很方便。可以将其视为一家全球商店,而只是指向Nix风格的产品的指针,因此销毁并重做的成本很低。

You can delete the environment file any time to start mostly fresh. This is handy if cabal is telling you some set of packages have conflicting dependencies with prior packages. Think of it as a global store but as just pointers to the nix-style builds, so it's cheap to blow away and redo.

这篇关于Haskell Cabal v2和沙盒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆