Buscar en Mind w/o Soul

miércoles, marzo 19, 2008

Arrows: combinando mónadas distintas

A Neighborhood of Infinity: Monads, Kleisli Arrows, Comonads and other Rambling Thoughts
Let's work through the details of composing Kleisli arrows: we want to compose f::a→m b and g::b→m c. The obvious thing to do is add a gluing map between them m b→b. But that's uninteresting as it just throws away the fanciness. Instead we use the fact that m is a functor (part of the mathematician's definition of monad) to lift g to a function m b→m (m c). This now composes nicely with f but the catch is that we end up with something twice as fancy. However, part of the definition of monads is that there is a map m (m c)→m c. (Twice as fancy is still just fancy.) And that can now be used to finish off the composition.

No hay comentarios: