haskell / haskell/cabal

cabal new-repl's ghci can't :load other source files properly

Open
#5,665 13 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

using

$ cabal --version
cabal-install version 2.4.0.0
compiled using version 2.4.0.1 of the Cabal library

example session

$ cabal new-repl
Resolving dependencies...
Build profile: -w ghc-8.4.4 -O1
In order, the following will be built (use -v for more details):
- cabal-bug-0.1.0.0 (lib) --enable-profiling (configuration changed)
Configuring library for cabal-bug-0.1.0.0..
Preprocessing library for cabal-bug-0.1.0.0..
GHCi, version 8.4.4: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Library ( Library.hs, interpreted )
Ok, one module loaded.
*Library> :l Example.hs
[1 of 1] Compiling Main ( Example.hs, interpreted )
Ok, one module loaded.
Prelude> :m + Main
.
:1:1: error:
attempting to use module ‘cabal-bug-0.1.0.0-inplace:Main’ (Example.hs) which is not loaded
Prelude> :l Example.hs
[1 of 1] Compiling Main ( Example.hs, interpreted )
Ok, one module loaded.
Prelude> :m + Main
Prelude Main> Main.main
.
:5:1: error:
Not in scope: ‘Main.main’
No module named ‘Main’ is imported.
Prelude Main> :bro
main:Main.main :: IO ()
Prelude Main> :q
Leaving GHCi.

example cabal project [cabal-bug-0.1.0.0.tar.gz](https://github.com/haskell/cabal/files/2551569/cabal-bug-0.1.0.0.tar.gz):

$ ls
cabal-bug.cabal Example.hs Executable.hs Library.hs LICENSE Setup.hs

workaround (thanks to dmwit on irc) is to specify an executable for the new-repl:

$ cabal new-repl exe:cabal-bug
Build profile: -w ghc-8.4.4 -O1
In order, the following will be built (use -v for more details):
- cabal-bug-0.1.0.0 (exe:cabal-bug) --enable-profiling (first run)
Preprocessing executable 'cabal-bug' for cabal-bug-0.1.0.0..
GHCi, version 8.4.4: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( Executable.hs, interpreted )
Ok, one module loaded.
*Main> main
*Main> :l Example.hs
[1 of 1] Compiling Main ( Example.hs, interpreted )
Ok, one module loaded.
*Main> main
665
*Main> :q
Leaving GHCi.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.