I'm getting an error that says the module doesn't exist when I try to runhaskell. It's odd because I try to install it first and says its up to date. Any idea how to fix this?
You could try creating the package environment in the local directory that holds your project, like this:
c:\Users\...\ex1haskell> cabal install --lib --package-env . QuickCheck
This should create a file of the form .ghc.environment.xxx
in ex1haskell
, which hopefully should be picked up by runhaskell
/ghci
/ghc
invocations.
In ghci
sessions, a sign that the environment is being picked up is the following message while starting:
Loaded package environment from ...
When the --package-env
location is not given explicitly, a default location is used. According to the docs:
By default, it is writing to the global environment in ~/.ghc/$ARCH-$OS-$GHCVER/environments/default. v2-install provides the --package-env flag to control which of these environments is modified.
But it seems that runhaskell
is having problems to find the environment file in that default location.
Note. When creating a package environment, it's possible to specify multiple packages simultaneously, like this:
cabal install --lib --package-env . QuickCheck random aeson transformers
Also, package environments are just text files, so local environments can be deleted and recreated at will. The actual package binaries reside elsewhere and can potentially be reused by cabal
.