I accidentally the Prelude

Simon Marlow marlowsd at gmail.com
Wed Mar 3 07:10:33 EST 2010


On 02/03/2010 17:45, Yitzchak Gale wrote:
> Jeremy Shaw wrote:
>>> I would still vote for that error in the 'worst ghc error message
>>> contest'...
>
> Simon Marlow wrote:
>> Oh, the problem here is that... when we got around
>> to trying to import it we found that it was not "loaded".
>> Perhaps the implicit import of Prelude should be...
>> What you wanted to do above was "ghc --make Setup -i"...
>> And if we fix the dependency thing, you'll still need to do that,
>> because otherwise...
>
> Simon,
>
> Thank you for your incessant focus on making GHC excellent
> in every case!
>
> Even so, Prelude does seem to be a special case here,
> and in that special case the error message really is bad.
> It even confused Josef.
>
> Can't we add something like "(Is there more than one
> Prelude in your path?)" to the message for Prelude?
> Just in case somehow, somewhere, this does happen
> to someone again?

After making the fix I mentioned previously, the result is now this:

   libraries/base$ ghc --make Setup

   Prelude.hs:38:2: lexical error at character 'i'

which is reasonable, because Setup.hs imports Prelude (implicitly), and 
Prelude.hs was found in the current directory.  Prelude.hs has some CPP 
directives which result in the compilation error.

So I could add a warning ("Warning: this Prelude module is shadowing the 
real Prelude", or something), but then we'd need a new flag to turn off 
the warning if shadowing the Prelude is what you're really trying to do, 
and that sounds like an awful lot of bother to fix a very rare corner 
case.  Or can anyone think of a better way to handle this?

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list