Is there a simple way to load extra packages to ghci when invoked via cabal repl?
cabal repl --ghc-option='-package xyz'
This will load the package you are calling cabal repl
from and the package xyz
.
To do that after the fact, i.e. when you're already in the REPL and want to load an extra helper module from another package:
GHCi> :set -package xyz
GHCi> :m +XYZ.Module.You.Suddenly.Need
When I needed QuickCheck library in scope of ghci I tried
cabal repl --ghc-option='-package QuickCheck'
and it didn't work at all.
The following saved my day
cabal repl --build-depends "QuickCheck >= 2.14"
This is only tangential. I searched for how to do with stack repl
. With Stack you do:
stack repl --package xyz
Here repl
is synonymous with ghci
.