More beautiful fold zipping
My previous post, Another lovely example of type class morphisms, placed some standard structure around Max Rabkin’s Beautiful folding, using type class morphisms to confirm that the Functor
and Applicative
instances agreed with their inevitable meanings.
In the process of working out the Applicative
case, I realized the essence of fold zipping was getting a bit obscured.
This post simplifies Max’s Fold
data type a bit and shows how to zip strict left folds in the simpler setting.
You can get the code described here.
Edits:
- 2008-11-15: I renamed the
Pair
andPair'
classes toZip
andZip'
.