6.6 strikes me again :)

Simon Peyton-Jones simonpj at microsoft.com
Fri Sep 22 03:21:11 EDT 2006


| class (Monad m) =>  MRef m r | r->m, m->r
| class (Monad m) =>  Stream m h | h->m
| newtype StringReader r  =  StringReader r
| instance (Monad m, MRef m r) =>  Stream m (StringReader r)
| 
| coverage condition requires that monad type 'm' should occur in stream
| handle type 'StringReader r'. With MRef defined as bijective type
| function between m and r that is, in fact, true. may be compiler is
just not smart
| enough to figure this?

The coverage condition is certainly conservative -- there are cases
where nothing goes wrong if you drop it, and that's what
-fallow-undecidable-instances does.  The worst that can happen with
-fallow-undecidable-instances is that the type checker loops (and even
then it'll usually emit an error message); if the program typechecks
it'll run ok.

| is using -fallow-undecidable-instances safe in this situation?
| what of MRef fundeps, r->m or m->r, is really necessary in this case -
| i think it is r->m ?

I think you are right.

You could also try adding 'm' as a phantom type parameter to
StringrReader.

Simon


More information about the Glasgow-haskell-users mailing list