Hello. I’m a beginner in Haskell. I want to install modules (for example System.Random), but I dont’ know how to do it. Some easy instructions?
cabal install random
Ensure that cabal --version is >= 3.
In an empty folder, type
cabal install --lib --package-env . random
That should create a file named .ghc.environment.<somemorestuff> in the folder.
In that same empty folder, start ghci:
Some message like “Loaded package environment from…” should appear when starting.
Inside ghci, import
Prelude> import System.Random
If, when installing the package, you omit the location of the package environment:
cabal install --lib random
then it updates a default package environment located somewhere in your home directory.
With a bit of luck, ghci invocations should pick this default environment, too, but explicitly writing –package-env . is more foolprof.
Some relevant links:
Note that this can cause conflicts (e.g. Cannot satisfy -package-id X11-1.9.1-As84WI1VImVHquwEDPbrTE), so the package-env method should be preferred.
Thank you very much. It works!