[Haskell-cafe] Re: Weird ghci behaviour?

Chris Smith cdsmith at twu.net
Mon Nov 12 16:41:55 EST 2007

Dan Piponi wrote:
> Several months late I now have a simple test case for what I think is
> either a GHC bug or a "misexpectation" on my part.

Here's what it looks like to me.

If there is a .hi and .o file sitting around for a module, then GHCi 
will load it in compiled mode, and only let you access those symbols 
that are exported by the .hi file.  If you compile a source file that 
has no module header, it compiles to the module Main and *only* exports 
the symbol main.  You can fix it by adding a module header explicitly, 
or by deleting either the .hi or .o file.

This is not new with GHC 6.8.  For example, it's why I had to sneakily 
add a module declaration to the top of a source file when I wrote
> http://www.haskell.org/haskellwiki/Learn_Haskell_in_10_minutes#Function_definitions

Chris Smith

More information about the Haskell-Cafe mailing list