add catamorphism (courtesy Emil)