Hi,
I am asking about which kind of monads <M, return, then> respect the
following equation:
f (x then k) = x then (f . k) (*)
= x then (\y -> f (k y))
where, of course, f is an adequate polymorphic function i.e.
f : M a -> M a for any type $a$.
It is easy to see that for the identity monad, this equation (*) becomes
simply the definition of composition:
f (k x) = (f . k) x
In the case of the list monad (M a = [a]), equation (*)
holds only if $f$ is a morphism over the concat operator
i.e. f (u ++ v) = (f u) ++ (f v)
I am wandering if the equation (*) is true (and for which conditions
for $f$) in the case of the State monad. I was unable to prove it but
it seems to me that it is intuitively true because, in the case of the
State monad, composition ensures single-threadedness and it is the
same to apply $f$ on the result of (x then k) or to wait for the
computation $y$ (coming from the value $x$) and to apply $f$ on the
result of $k y$.
Is someone could help me on this problem?
Thank you.
Francois-Nicola Demers
[EMAIL PROTECTED]
[EMAIL PROTECTED]