category-theory-presentation/categories/30_How/200_Monads/080_Fix_Composition_2_2.md
2013-02-28 16:49:12 +01:00

523 B

Fix Composition (2/2)

Goal, find: ◎ :: (b -> F c) -> (a -> F b) -> (a -> F c)
f :: a -> F b, g :: b -> F c, f x :: F b:

  • Use fmap :: (t -> u) -> (F t -> F u)!
  • (fmap g) :: F b -> F (F c) ; (t=b, u=F c)
  • (fmap g) (f x) :: F (F c) it almost WORKS!
  • We lack an important component, join :: F (F c) -> F c
  • (g ◎ f) x = join ((fmap g) (f x))
    ◎ is the Kleisli composition; in Haskell: <=< (in Control.Monad).