[Haskell-cafe] A question about "monad laws"
valgarv at gmx.net
Fri Mar 14 02:22:57 EDT 2008
> f >=> g = \x -> f x >>= g
So you're either not taking (>=>) as primitive or you're stating the
property that there exists (>>=) such that f >=> g === (>>= g) . f
(from which you can easily show that (f . g) >=> h === (f >=> h) . g ).
A presentation of the monad laws based on (>=>) (I prefer (<=<) since it
better with (.) ) should (IMHO) regard (>=>) as primitive and state its
whence one can derive all other formulations (Note that he Identity law then
existence of return as another primitive).
That done, you define (>>=), fmap and the rest in terms of (<=<) :
(>>=) = flip (<=< id) -- I like to put it as (>>= g) = (g <=<
fmap f = (return . f) <=< id
Ariel J. Birnbaum
View this message in context: http://www.nabble.com/A-question-about-%22monad-laws%22-tp15411587p16045123.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe