Is this always true: fmap (foldr f z) . sequenceA = foldr (liftA2 f) (pure z)

import Prelude hiding (foldr)

import Control.Applicative
import Data.Foldable
import Data.Traversable

left, right :: (Applicative f, Traversable t) => (a -> b -> b) -> b -> t (f a) -> f b
left f z = fmap (foldr f z) . sequenceA
right f z = foldr (liftA2 f) (pure z)

I have a strong suspicion that the expressions left and right are equal, but how to prove it?

14
задан Sjoerd Visscher 19 May 2011 в 10:12
поделиться