Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a simple way to load extra packages to ghci when invoked via cabal repl?

Tags:

cabal repl is quite useful for debugging a library, however ghci will have all packages hidden that aren't dependencies of the cabal package. While that is certainly a good thing for cabal build, for repl it means I can't load something from an unrelated package for a quick test.

I can access any package by issuing :set -package, but that'll unload all modules from the pacakge I'm working on, defeating the point of cabal repl.

What's a nice way to simply load packages I have installed, but don't want as dependencies to my library?

like image 943
leftaroundabout Avatar asked Jul 14 '14 12:07

leftaroundabout


2 Answers

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 
like image 170
SvenK Avatar answered Oct 19 '22 01:10

SvenK


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" 
like image 25
slavik Avatar answered Oct 19 '22 02:10

slavik