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 (ie 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.