Executing `cabal repl` with top-level functions
I am trying to learn how to isolate my Haskell projects with cabal.
I use the command interpreter extensively ghci
, which imports top level functions by default.
cabal repl
also provides a shell, but top-level functions are not imported.
How can I run cabal repl
so that top-level constants and functions are defined in the shell?
Here's a minimal example:
-- somefile.hs someConstant :: Int someConstant = 5 main :: IO () main = undefined
someConstant
Will now be defined at startup ghci somefile.hs
, but it will not be defined when I run cabal repl
.
source to share
If the module is listed in your project (i.e. in sections with open modules or other modules):
:m *ModuleName
Otherwise:
:l somefile.hs
See also What's really available in the tooltip? from Fine Documentation.
source to share