GHCI Can't Find Module But GHC Can

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Thu, 27 Jun 2002 13:59:56 +0100


Alastair Reid <reid@cs.utah.edu> writes:

> > For instance, hmake manages just fine with a
> > simplified parser that understands only token streams introduced by
> > the keyword 'import' at the beginning of a line ...
> 
> It's true that many people layout their code in such a way that this
> will work.  

The hmake parser specifically doesn't depend on layout.  A module doing
crazy stuff like

    module M where
      import qualified {- " -}
        N

is perfectly fine, and all it takes to implement is the addition of a
`concatMap' over and above the version which expects the whole import
on one line.  (FWIW, the hmake parser is ~200 lines, of which ~150
lines deals with cpp, ~30 lines deals with comments, and ~20 lines
actually reads the imports.)

> But ghci already contains a Haskell parser - so it should be much less
> work.

Agreed, except that you don't want to fully-parse each module
twice, nor in general do you want to report all parse errors on the
import-gathering pass!

Regards,
    Malcolm