可能是什么原因missing module?
$ nix-shell -p haskellPackages.ghc -p haskellPackages.random\nRun Code Online (Sandbox Code Playgroud)\n\n给出以下外壳
\n\n[nix-shell:~]$ ghci \nGHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help\nLoaded GHCi configuration from /data/works/dotfiles/ghci\nPrelude> import System.Random\n\n<no location info>: error:\n Could not find module \xe2\x80\x98System.Random\xe2\x80\x99\n It is not a module in the current program, or in any known package.\nRun Code Online (Sandbox Code Playgroud)\n\nHaskell 软件包的安装和使用方法是什么?nix
我以为nixos.haskellPackages.<package>会自动注册 ghc 但似乎并非如此。
重新装上random内壳,还是不行。
[nix-shell:~]$ nix-env -iA nixos.haskellPackages.random\ninstalling \xe2\x80\x98random-1.1\xe2\x80\x99\n\n[nix-shell:~]$ ghc-pkg list | grep -i random\nRun Code Online (Sandbox Code Playgroud)\n
我不知道这不起作用的原因。但你可以尝试这个命令:
nix-shell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [random])"
Run Code Online (Sandbox Code Playgroud)
对我有用。现在ghci看到System.Random包了。
更新:
这篇文章对初学者的冒险确实很有帮助nix + haskell: