define catamorphisms by template haskell