foldl' should not be foldr . flip