
I'm in chapter 4 of Bird's very interesting *Thinking Functionally with Haskell *and he has a problem at the end of the chapter where he lists these equations map f . take n = take n . map f map f . reverse = reverse . map f map f . sort = sort . map f map f . filter p = map fst . filter snd . map (fork (f,p)) filter (p . g) = map (invertg) . filter p . map g reverse . concat = concat . reverse . map reverse filter p . concat = concat . map (filter p) adding this caveat for the 3rd equation iff x <= y <=> f x <= f y and this for the 4th equation fork (f,g) x = (f x, g x) and for the 5th invertg satisfies invertg . g = id My confusion is over the commutative-ness of most of this but only anecdotally. With the particularly dense map f . filter p = map fst . filter snd . map (fork (f,p)) We have
:t (map myF . filter myP) Integral b => [b] -> [b] :t (map fst . filter snd . map (myFork (myF,myP))) Integral b => [b] -> [b]
Is there anything universal to be drawn from these anecdotal examples of seeming commutativity? My breakdown of the third equation shows the same type definition for both sides. Is this a way to find equality? All in all, Bird doesn't indicate that there are any underlying truths, just "almost" commutativity. LB