Hacking on GHC interactively with GHCi
simonmarhaskell at gmail.com
Tue Oct 17 05:26:15 EDT 2006
Clemens Fruhwirth wrote:
> 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)
This is something we haven't tried, although if you get all the files in the
right places I don't see any reason why it shouldn't work.
> * 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).
It should be possible to do this, except that I'm fairly certain you'll run into
trouble if you try to run GHCi within itself due to the global state of the RTS
linker. But just doing ordinary compilation in GHC loaded into GHCi should
work. We have done some simple experiments using the GHC API from inside GHCi.
It sounds like there's a straightforward way to show the problem, so could you
submit a ticket detailing what you did to reproduce it? Thanks.
More information about the Glasgow-haskell-users