Re: Disappearing instances?

Malcolm Wallace <[email protected]> Wed, 28 Jul 2004 17:06:09 +0100
Newsgroups gmane.comp.lang.haskell.nhc.user
Organization Dept of Computer Science, University of York
Message-ID <[email protected]>
Martin Sj=F6gren <[email protected]> writes:

> Fail: The class Prelude.Monad has no instance for the type Prelude.Either.
>=20
> and indeed if I look at Compat/H98.hi, it mentions
>=20
>     instance Error Prelude.Char;
>     instance (Error a) =3D> Error [a];
>=20
> but nothing about Error e =3D> 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