News for hackers. Stuff that matters.
Re:Monoids, Functors, Applicatives, and Monads: Main Ideas by dllthomas on Monday January 05, 2015 @10:53PM (#8842842)
Ah, it does seem to follow:

    M1: return a >>= f  = f a
    M2: m >>= return    = m
    M3: (m >>= f) >>= g = m >>= (\ x -> f x >>= g)

    (fmap f . fmap g) m = (fmap f . fmap g) m

    by defn of (.)      = fmap f (fmap g m)
    by defn of fmap     = fmap f (m >>= return . g)
    by defn of fmap     = (m >>= return . g) >>= return . f
    by M3               = m >>= (\ x -> (return . g) x >>= return . f)
    by defn of (.)      = m >>= (\ x -> return (g x) >>= return . f)
    by M1               = m >>= (\ x -> (return . f) (g x))
    by defn of (.)      = m >>= (\ x -> return (f (g x)))
    by defn of (.)      = m >>= (\ x -> (return . (f . g)) x)
    eta reduction       = m >>= return . (f . g)
    by defn of fmap     = fmap (f . g) m

    (fmap f . fmap g) m = fmap (f . g) m

There are no comments on this comment yet.