Mathematical structures in functional programming