[nhc-users] Disappearing instances?

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Wed Jul 28 12:06:09 EDT 2004


Martin Sjögren <msjogren at gmail.com> writes:

> Fail: The class Prelude.Monad has no instance for the type Prelude.Either.
> 
> and indeed if I look at Compat/H98.hi, it mentions
> 
>     instance Error Prelude.Char;
>     instance (Error a) => Error [a];
> 
> but nothing about Error e => Monad (Either e)
> What should I do? Is this a bug?

It's a feature.  :-)

nhc98 omits an instance from an interface file if both the class
and the type mentioned in the instance are defined in the Prelude.
(This is because such instances are presumed to be always available
directly from the Prelude itself - omitting them makes interface
files much smaller, and thus compilation much faster.)

You can force nhc98 to write the instance to the interface file with
the -prelude option.  If you like, you can put

    {-# OPTIONS_COMPILE -prelude #-}

at the top of Compat/H98.hs to avoid messing around with Makefiles.

Regards,
    Malcolm


More information about the Nhc-users mailing list