gpt4 book ai didi

haskell - 在 nix-shell 中找不到模块

转载 作者:行者123 更新时间:2023-12-05 02:18:51 25 4
gpt4 key购买 nike

missing module 可能是什么原因? ?

$ nix-shell -p haskellPackages.ghc -p haskellPackages.random

给出以下shell

[nix-shell:~]$ ghci 
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /data/works/dotfiles/ghci
Prelude> import System.Random

<no location info>: error:
Could not find module ‘System.Random’
It is not a module in the current program, or in any known package.

什么是nix如何安装和使用 Haskell 包?

我以为nixos.haskellPackages.<package>会自动注册 ghc 但似乎并非如此。

重新安装 random在 shell 中不要修复它。

[nix-shell:~]$ nix-env -iA nixos.haskellPackages.random
installing ‘random-1.1’

[nix-shell:~]$ ghc-pkg list | grep -i random

最佳答案

我不知道这不起作用的原因。但是你可以试试这个命令:

nix-shell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [random])"

适合我。现在 ghci 看到了 System.Random 包。

更新:

这篇文章对初学者在他们的 nix + haskell 冒险中真的很有帮助:

https://web.archive.org/web/20170910171927/http://alpmestan.com/posts/2017-09-06-quick-haskell-hacking-with-nix.html

关于haskell - 在 nix-shell 中找不到模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44047412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com