[Haskell-cafe] Re: Associated Type Synonyms question

Stefan Wehr mail at stefanwehr.de
Thu Feb 16 02:19:19 EST 2006

Niklas Broberg <niklas.broberg at gmail.com> wrote::

> On 2/10/06, Ross Paterson <ross at soi.city.ac.uk> 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.


More information about the Haskell-Cafe mailing list