Stefan Wehr <[EMAIL PROTECTED]> wrote:: > Niklas Broberg <[EMAIL PROTECTED]> wrote:: > >> On 2/10/06, Ross Paterson <[EMAIL PROTECTED]> wrote: >>> On Fri, Feb 10, 2006 at 05:20:47PM +0100, Niklas Broberg wrote: >>> > - when looking at the definition of MonadWriter the Monoid constraint >>> > is not strictly necessary, and none of the other mtl monads have >>> > anything similar. Is it the assumption that this kind of constraint is >>> > never really necessary, and thus no support for it is needed for ATS? >>> >>> I think that's right -- it's only needed for the Monad instance for >>> WriterT. But it is a convenience. In any instance of MonadWriter, the >>> w will be a monoid, as there'll be a WriterT in the stack somewhere, >>> so the Monoid constraint just saves people writing general functions >>> with MonadWriter from having to add it. >> >> Sure it's a convenience, and thinking about it some more it would seem >> like that is always the case - it is never crucial to constrain a >> parameter. But then again, the same applies to the Monad m constraint, >> we could give the same argument there (all actual instances will be >> monads, hence...). So my other question still stands, why not allow >> constraints on associated types as well, as a convenience? > > Manuel (Chakravarty) and I agree that it should be possible to > constrain associated type synonyms in the context of class > definitions. Your example shows that this feature is actually > needed. I will integrate it into phrac within the next few days.
I have now implemented this feature in PHRaC. You need to get PHRaC via darcs: http://www.cse.unsw.edu.au/~pls/repos/phrac/ An example is included in PHRaC's source code under tests/constrained-assoc-types/should_pass/000.phc. I haven't tested the extension extensively. Just tell me if you have any problems. Stefan _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
