let rec fold f a acc = match a with | Var _ -> f a acc | App(_, l, _) -> List.fold_right (fold f) l acc