Paramorphism
code:hs
para :: (a -> (a, b) -> b) -> b -> a -> b para f z [] = z
para f z (x:xs) = f x (xs, para f z xs)
code:hs
para :: (a -> (a, b) -> b) -> b -> a -> b cata :: (a -> b -> b) -> b -> a -> b para f z [] = z
cata f z [] = z
para f z (x:xs) = f x (xs, para f z xs)
cata f z (x:xs) = f x (cata f z xs)
(xs, ..の部分で元のobject xsも保存している箇所だけが異なる