[Haskell-cafe] FGL instance constraint

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Sat May 1 03:49:20 EDT 2010


Jason Dagit <dagit at codersbase.com> writes:

> On Sat, May 1, 2010 at 12:23 AM, Ivan Lazar Miljenovic <
> ivan.miljenovic at gmail.com> wrote:
>
>> Hmmm.... this is an interesting way of doing it, but I would argue that
>> it's pointless: the fact that you're using MPTCs doesn't give you
>> anything extra that the original class.  Furthermore, as I said earlier,
>> it doesn't make sense to constrain the label type just to make an
>> instance of a type class.
>>
>> (Now, if we had other functions in there which _might_ depend on the
>> label types, this _would_ make sense; as it stands however, it doesn't.)
>>
>
> Try removing "Cls a" from the instance.  You'll notice that my empty does
> depend on a having a Cls instance because it will fail to compile.  In other
> words, I don't understand what you're talking about.  I did need the
> constraint to define my instance.

Except that example is bogus: "isEmpty empty" returns False.

> And if that example gets boring, try making an instance of Set for
> Monad.

My understanding was that Set couldn't be a Monad specifically why you
can't make it one: Monads shouldn't constrain the value of the type
contained within.

>  Then re-read the article I linked from Oleg's website.  I'm not
> understanding your point, and I suspect you're not understanding mine
> :)

My point was that Kevin was doing it wrong and didn't need a constraint
there; what's yours?

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list