G'day all.

Quoting askyle <[EMAIL PROTECTED]>:

If you use this presentation you also need the following law:
(a . b) >=> c  = (a >=> c) . b

that is, compatibility with ordinary function composition. I like to call
this "naturality", since it's instrumental in proving return and bind to be
natural transformations.

Define:

    f >=> g = \x -> f x >>= g
    fmap f xs = xs >>= return . f

Then:

  fmap f . return
= (expand fmap)
  \x -> (return x >>= return . f)
= (defn. of >=>)
  \x -> (return >=> return . f) x
= (left identity)
  \x -> (return . f) x
=
  return . f

Therefore return is natural.

Bind (or, equivalently, join) is left as an exercise.

Cheers,
Andrew Bromage
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to