By chance, I noticed that the resolution of constraints in combination
with overlapping instances has changed in the `September 1999' version
of Hugs.

This code scrap used to run ...


> import Monad

> instance (Monad m) => Functor m where
>     fmap f m          =  m >>= return . f

  class (Monad m) => MonadPlus m where
      mzero             :: m a
      mplus             :: m a -> m a -> m a

> wrap                  :: (MonadPlus m) => m a -> m (Maybe a)
> wrap m                =  fmap Just m `mplus` return Nothing


Now, Hugs (hugs +o) reports

ERROR "Map.lhs" (line 7): Cannot justify constraints in explicitly typed binding
*** Expression    : wrap
*** Type          : MonadPlus a => a b -> a (Maybe b)
*** Given context : MonadPlus a
*** Constraints   : Functor a

However, an instance of `MonadPlus' is also an instance of `Monad' and
the first instance declaration formalizes, that a `Monad' instance is
also an instance of `Functor' (of course, this instance overlaps with
all other instances).

Is this a deliberate change or a bug?

Cheers, Ralf

Reply via email to