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

13 lines
523 B
Markdown

Fix Composition (2/2)
--------------------------------------------
Goal, find: `◎ :: (b -> F c) -> (a -> F b) -> (a -> F c)`
`f :: a -> F b`, `g :: b -> F c`, <span class="yellow">`f x :: F b`</span>:
- 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`).