Tue Aug 16 18:46:32 CEST 2011

Monad from Kleisli Arrow

So I have an Arrow implementation that I know is the Kleisli arrow (K
a b) of some Monad (M a).  Is this enough to derive the Monad instance
from the Arrow instance?

The idea is that to implement bind, we need to "cut off the head" of
the arrow.  Maybe this can be done by the correspondence

    M a       <-->  K () a

If then wi can use a correspondance such as this we might be able to
pull it off:

    a -> M b  <-->  K a b

The catch is probably that the latter correspondence only exists if
the arrow is a true Kleisli arrow.

Actually, I rediscovered something (at least the conjecture ;) from
[1].  It says that indeed Monads are equivalent to Arrows that satisfy
the type isomorphism

    K a b  <->  a -> K () b

( In my particular implementation I ran into a blocking problem that
has to do with bad organization, so can't pull it of in its current
form.  I'm still struggling with the existentials problem though.. )

[1] http://homepages.inf.ed.ac.uk/wadler/papers/arrows-and-idioms/arrows-and-idioms.pdf