Newbie qustion about monads
Juanma Barranquero
lektu at terra.es
Thu Oct 2 22:49:41 EDT 2003
On Thu, 2 Oct 2003 16:09:11 +0100, Alastair Reid <alastair at reid-consulting-uk.ltd.uk> wrote:
> So you should not interpret the '==' in the monad law as requiring you to
> define an Eq instance.
>
> If you do define an Eq instance, it ought to be reflexive, symmetric and
> transitive (i.e., an equivalence) if you want functions with Eq constraints
> to behave in a meaningful way.
Thanks, I understand now. (Incidentally, the == I was defining was an
equivalence, AFAICS.)
> Also, although there's probably no necessity for your Eq instance to match
> your notion of equality between computations (i.e., the == used in the monad
> laws), I think you'll end up very confused if you define an Eq instance which
> doesn't match in the same way that having Eq on pairs ignore the 2nd field
> would confuse you.
Sure. I imagine only very specialized monads will need an Eq that
doesn't match the equality implicit in the monad laws. As Derek has
pointed out, I'm yet far from reaching a point where I should worry
about that :)
Thanks for your comments,
Juanma
More information about the Haskell-Cafe
mailing list