I'm trying to learn to sandbox my Haskell projects with cabal.
I make extensive use of the command interpreter ghci, which imports top-level functions by default.
cabal repl also provides a command interpreter, but top-level functions are not imported.
How can I run cabal repl so that top-level constants and functions will be defined in the command interpreter?
Here's a minimal example:
-- somefile.hs
someConstant :: Int
someConstant = 5
main :: IO ()
main = undefined
Now, someConstant will be defined when I run ghci somefile.hs, but it won't be defined when I run cabal repl.
If the module is one listed in your project (i.e. in your exposed-modules or other-modules sections):
:m *ModuleName
Otherwise:
:l somefile.hs
See also What's really in scope at the prompt? from the Fine Documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With