AW: Newbie qustion about monads

I'm not trying to create useful monads (I'm pretty sure they aren't :), but understanding the concepts. So, the question remains: when the monad laws say that
(return x) >>= f == f x
The Monad class is just called Monad because it is intended to cover a monad. But it doesn't ensure the laws. That is your sole responsibility.
what is intended in that "=="? Eq."==" for
You can define it to your liking as long as it is commutative. HTH, Markus

On Thu, 2 Oct 2003 13:16:13 +0200 Markus.Schnell@infineon.com wrote:
The Monad class is just called Monad because it is intended to cover a monad. But it doesn't ensure the laws. That is your sole responsibility.
Yeah, I know. But it's difficult to ensure I'm satisfying the laws when I'm not entirely sure what do they ask from me...
You can define it to your liking as long as it is commutative.
Ah, that's what I was expecting. So, in both my examples, defining: instance Eq MyMonad where MM _ x == MM _ y = x == y would suffice and the first law would be satisfied. Thanks, Juanma

W liście z czw, 02-10-2003, godz. 14:25, Juanma Barranquero pisze:
Yeah, I know. But it's difficult to ensure I'm satisfying the laws when I'm not entirely sure what do they ask from me...
1. (return x) >>= f == f x 2. m >>= return == m 3. (m >>= f) >>= g == m >>= (\x -> f x >>= g) My intuition: 1 & 2. return doesn't do anything (except having the given result). If added before or after an action, it doesn't change its effect. 3. (>>=) is associative, so it must not leave trails of where it was applied, it only propagates effects of the arguments being composed. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/
participants (3)
-
Juanma Barranquero
-
Marcin 'Qrczak' Kowalczyk
-
Markus.Schnell@infineon.com