extract cata_foldr into Haskell (see ext/cata_foldr.hs)