When I use both ghci with -fobject-code
and command-line ghc, code is compiled fully when switching from one to the other. For example, when I work interactively in Emacs using haskell inferior mode configured to use cabal repl
, code loads and compiles fine. Then I do a cabal build
and same code is recompiled.
How can I prevent this double compilation assuming -fobject-code
in ghci actually uses the same kind of binary format than ghc does?
You can have ghci
and friends use different suffixes for the compiled files. Add the following to your ~/.ghci
:
:set -hisuf i_hi
:set -osuf i_o
...and ghci will output stuff to foo.i_hi
and foo.i_o
which won't overwrite the .hi
and .o
files of ghc.