Use catamorphism instead

Signed-off-by: Ricky Elrod <ricky@elrod.me>