[Haskell] type class does not compile

Ben.Yu at combined.com Ben.Yu at combined.com
Mon Jul 12 20:24:21 EDT 2004

please bear with me if my question turns out to be a stupid mistake. It has
taken me hours to figure this out.

class Rule r u u' m where
  apply :: r -> u -> m u'

data And = And

data Bin a b o = Bin a b o

instance (Monad m, Rule r1 u u' m, Rule r2 u' u'' m) => Rule (Bin r1 r2
And) u u'' m where
  apply (Bin r1 r2 _) u = apply r1 u >>= apply r2

Ghc complains about "Could not deduce (Rule r1 u u'1 m, Rule r2 u'1 u''
m)", but it is obviously same as the constraint I gave in the instance

What am I doing wrong here?

Thank you very much!

This message is intended only for the addressee and may contain information
that is confidential or privileged. Unauthorized use is strictly prohibited
and may be unlawful. If you are not the intended recipient, or the person
responsible for delivering to the intended recipient, you should not read,
copy, disclose or otherwise use this message, except for the purpose of
delivery to the addressee. If you have received this email in error, please
delete and advise us immediately.

More information about the Haskell mailing list