[Haskell-cafe] A question about "monad laws"
askyle
valgarv at gmx.net
Fri Mar 14 02:22:57 EDT 2008
ajb-2 wrote:
>
> Define:
> f >=> g = \x -> f x >>= g
>
So you're either not taking (>=>) as primitive or you're stating the
additional
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
meshes
better with (.) ) should (IMHO) regard (>=>) as primitive and state its
needed properties
whence one can derive all other formulations (Note that he Identity law then
requires the
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 <=<
id)
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
mailing list