Haskell Cabal v2 and Sandbox

霸气de小男生 提交于 2020-06-27 11:58:39

问题


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

cabal init sandbox
cabal install <some stuff>

Which is later loaded at your discretion using

cabal exec bash

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.

Currently contemplating Cabal 2.4.0.0 with GHC 8.6.5.


回答1:


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

Now we can load modules from these packages in GHCi:

ghci
> import Data.GenericTrie
> import Data.Map

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.

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.



来源:https://stackoverflow.com/questions/58272366/haskell-cabal-v2-and-sandbox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!