Different Kabbalah replacement behavior for library and executable

Using cabal repl does not seem to do anything when used in library projects, but works great for executable projects. Is this the expected behavior that I just don't understand?

If I have a file containing just

 go = putStrLn "test" 

and use cabal init with all the defaults (but select "library" as the type), then running cabal repl just creates some text about setting up and preprocessing the library and never enters the REPL environment. The exact same steps, but with the "executable" selected as type, put me directly in GHCi, as expected.

The code works fine when loading directly into GHCi.

+7
haskell ghc ghci cabal cabal-install
source share
1 answer

For cabal repl to load your modules, you must first name them in the code and then specify them in the .cabal project .cabal as shown:


 -- MyModule.hs module MyModule where go = putStrLn "test" 

 -- MyProject.cabal name: MyProject -- other info ... library exposed-modules: MyModule -- other options ... 

Then, when you run cabal repl , it will have access to everything in your sandbox (if any) and open modules. It may also work if you specify them as other-modules instead of exposed-modules , but I have not tried this.

+7
source share

All Articles