[Haskell-cafe] Coverage Condition?

Stefan O'Rear stefanor at cox.net
Tue Dec 26 19:38:38 EST 2006

On Tue, Dec 26, 2006 at 07:01:52PM -0500, lists at qseep.net wrote:
> 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 ...

1. Does 'CPS' stand for Continuation Passing Style?  If so, have a look
   at Control.Monad.Cont.ContT and eliminate your problem entirely (free
   pre-debugged code)

2. Your problem, is that *looking only at the instance head*, r could be
   anything.  GHC doesn't look at the context when deciding wether an
   instance is compatible with functional dependencies.
3. http://darcs.haskell.org/packages/mtl/Control/Monad/Cont.hs
   Looking at the standard CPS monad, there is a {-# OPTIONS_GHC -fallow-
   undecidable-instances #-} pragma and a comment to the effect of it
   being required for the MonadReader instance.

More information about the Haskell-Cafe mailing list