Edsko de Vries wrote: > sum :: Tree -> Int > sum t = sum' [t] 0 > where > sum' [] acc = acc > sum' (Leaf i : ts) acc = sum' ts $! (i + acc) > sum' (Node l r : ts) acc = sum' (l : r : ts) acc Because of $!, you should compare the Leaf case to foldl', not foldl. The Node case can be said to mimic a stack using heap resource.