Section FoldLeft.
Variables (T R : Type) (f : R -> T -> R).
Fixpoint foldl z s := if s is x :: s' then foldl (f z x) s' else z.
End Flatten.
Prenex Implicits flatten shape reshape.

Lemma map_flatten S T (f : T -> S) ss :
map f (flatten ss) = flatten (map (map f) ss).