
Hello list. Since NHC doesn't distribute Control.Monad.Error that, among other things, defines the Monad (Either e) instance, I wrote the following module for Cabal: http://cvs.haskell.org/darcs/cabal/Compat/H98.hs However, when I compile it, the Monad instance seems to disappear! With a small test program
module Main where import Monad import Compat.H98 foo :: Either Char [()] foo = sequence [Right (), Left 'a', Right (), Left 'b'] main = print foo
nhc complains: 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? /Martin

Martin Sjögren
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
participants (2)
-
Malcolm Wallace
-
Martin Sjögren