[Haskell-cafe] Coverage Condition?

lists at qseep.net lists at qseep.net
Tue Dec 26 19:01:52 EST 2006

Hi folks,

I'm working on a program that I've been dabbling with for years. For the
first time, I tried to compile it with GHC 6.6, and got an error,
explaining that I was violating the Coverage Condition in my instance
declaration. The instance declaration looks like this:

instance MonadReader r m => MonadReader r (CPST o m) where ...

The MonadReader class definition, which doesn't appear to have changed
since 6.4.2, looks like this:

class Monad m => MonadReader r m | m -> r where ...

Apparently, the Coverage Condition disallows my instance declaration,
because the variable 'r' is not mentioned in the '(CPST o m)' term. Now
this would make sense to me if I didn't have the assertion 'MonadReader r
m'. Because of that assertion, m -> r, so '(CPST o m)' shouldn't need to
explicitly mention 'r'.

I will try using -fallow-undecidable-instances, and see if the message
goes away. But can someone explain to me why this is wrong, and what would
be the preferred way to write it? I've attached the two relevant source
files. (Try compiling both files.)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: CPST.hs
Type: application/octet-stream
Size: 2261 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20061226/7edc4bc7/CPST.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CPSTInstances.hs
Type: application/octet-stream
Size: 592 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20061226/7edc4bc7/CPSTInstances.obj

More information about the Haskell-Cafe mailing list