acc
type of the "accumulator":fold :: (acc -> a -> acc) -> acc -> [a] -> acc
Idea: put the accumulated value inside the type.
-- Equivalent to fold (+1) 0 "cata"
(Cons 'c' (Cons 'a' (Cons 't' (Cons 'a' Nil))))
(Cons 'c' (Cons 'a' (Cons 't' (Cons 'a' 0))))
(Cons 'c' (Cons 'a' (Cons 't' 1)))
(Cons 'c' (Cons 'a' 2))
(Cons 'c' 3)
4
But where are all the informations? (+1)
and 0
?