stack ghci command is not working #2503
I've run across this too -- it's due to pandoc's use of a custom prelude in prelude/Prelude.hs
(a recent change to make it easier to support multiple ghc versions).
I've reproduced the problem in the simplest possible way (without using stack or pandoc source). In an empty directory, create two files:
--- Prelude.hs
{-# LANGUAGE PackageImports #-}
module Prelude
(
module P
, hi
)
where
import "base" Prelude as P
hi = print "hi"
-- test.hs
main = hi
Now ghc --make test.hs
works fine. You get a test
executable, which produces the output "hi"
if you run it.
But ghci test.hs
fils with the error
Top level:
attempting to use module ‘Prelude’ (./Prelude.hs) which is not loaded
It seems to me that this is some kind of bug in ghci, but I'm not sure.
I posted the question here and learned of this bug report against ghci.
There's a workaround: we can add import Prelude
to every source file, and add -XNoImplicitPrelude
to the ghc-options
field in pandoc.cabal. Then both cabal repl
and stack ghci
will work properly.
Thanks for the info John,
you mean to every source file of pandoc? that it is quite a big change for the workaround, or should we wait the bug to be fixed ?
Anyway, I will be happy to do the workaround change if you agree.
I've decided to handle this in a different way -- instead of explicitly importing Prelude and using NoImplicitPrelude, we now include the directory containing the custom Prelude only if ghc version is less than 7.10. It compiles on 4 GHC versions, but ghci will only work with ghc 7.10.x. This approach seems cleaner to me.
There is an exception when trying to run this command
Something I am missing ?