Hacking on GHC interactively with GHCi

Clemens Fruhwirth clemens at endorphin.org
Mon Oct 16 11:59:32 EDT 2006

Hello everyone,

I would like to hack on GHC interactively. My aim is to load ghc into
ghci and start hacking a source file in one emacs buffer, while the
other hosts an inferior-haskell session connected to GHCi. I really
like this kind of development style and found it to be way more
productive than "edit/compile/test/restart from edit".

To context of the following is the compiler/ subtree, as I'm primarily
interested in that. I tried to:

* load all GHC compiler source files into ghci, fails because of
  occassional unboxed types (bytecode generated can't deal with them)

* load all .o files (with unboxed types) and load a modified source in
interpreted mode. This doesn't work well because for that approach you
need to mix the source with the object in the same directory (copy
compiler/**/*.[l]hs to stage1 or stage2). This, fails because
there seem to be some sources missing, I have not investiged where the
.o-boot files come from like compiler/stage2/basicTypes/OccName.o-boot.
With source files, GHCi just ignores the existing .o file (resumable
because it can't check whether the .o file is more recent than the
source file)

* load "ghci -package ghc" and load main/Main.hs. This work pretty well,
but only in comparsion to the other approaches -- that means loading
does not fail. Invoking ":main -c foobar.hs" freezes the ghci
session. With this approach I can not change any module withing
the packaged ghc. Is that true? But that's what I want to do (in
particular to the parser part).

So, before I start to work towards a particular end of these 3
approaches, is there anyone how develops ghc in an interactive way
using ghci with partial :reload-ing of modules? The GHC user guide has a
good illustration of what I'm looking for

Any hint is appreciated.
Fruhwirth Clemens - http://clemens.endorphin.org 
for robots: sp4mtrap at endorphin.org

More information about the Glasgow-haskell-users mailing list