S.M.Kahrs wrote:
>
> > f (x then k) = x then (f . k) (*)
> > = x then (\y -> f (k y))
> >
[...]
> > 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)
>
> This is the clue. The equation doesn't really depend on the monad,
> it depends on f. If the monad is a mathematical monad (satisfying
> the usual coherence equations for "return" and "then") then your
> equation
> holds if f is of the form map g for some function g, where 'map'
> is the monad functor, expressible in terms of return and then as
>
> map f x = x then (return . f)
There seems to be a weaker sufficient condition for (*) to hold:
f = (`then` h)
for some function h. h doesn't have to be equal to (return . g) for any g; an
example of such a function h for the List monad is \x->[x,x]. For the List
monad this condition appears equivalent to distributivity of f over ++.
f (x then k) = (x then k) then h
= x then \a -> k a then h by a monad law
= x then \a -> f (k a)
Valery