Can not load a file that uses standard libraries in haskell

后端 未结 2 1404
忘了有多久
忘了有多久 2021-01-21 05:18

Hi I use GHCI and can normally load my files. Now I need to load a file that uses random. I get this error.

Chatterbot.hs:3:1: error:
    Could not find module ‘         


        
2条回答
  •  迷失自我
    2021-01-21 05:40

    If you are using a version of cabal-install >= 3.0 (check with cabal --version), then, instead of creating a cabal package, you can move to an empty folder and type:

    cabal install --lib --package-env . random
    

    This creates a .ghc.environment file in the folder. ghci sessions started inside that folder will pick it up, and they will be able to import System.Random.

    If that works correctly, you might want to install "random" globally so that any invocation of ghci can use it:

    cabal install --lib random
    

    This creates/modifies the global environment file located at ~/.ghc/$ARCH-$OS-$GHCVER/environments/default.

提交回复
热议问题