Exercise Three

You Could Have Invented Monads! (And Maybe You Already Have.)

Show that lift f * lift g = lift (f.g)


f' * g' = bind f' . g'
lift f = unit . f
f' = lift f

(lift f * lift g) (x, xs)
= bind (lift f . lift g) (x, xs)
= (hx, xs++hs)
    (hx, hs) = lh x
    lh x = (f' . g') x
    f' = lift f
    g' = lift g

This line does not work, since f' cannot be applied to (g' x), for the data types are not compatible:

f' :: Float -> (Float, String)

g' :: Float -> (Float, String)

(g' x) :: (Float, String)

The meaning of f' * g' should be bind f' . (bind g') instead.

— Me@2015-09-27 10:24:54 PM

2015.09.27 Sunday (c) All rights reserved by ACHK