A categorical approach to functional programming