Why can you reverse list with foldl, but not with foldr in Haskell
问题 Why can you reverse a list with the foldl? reverse' :: [a] -> [a] reverse' xs = foldl (\acc x-> x : acc) [] xs But this one gives me a compile error. reverse' :: [a] -> [a] reverse' xs = foldr (\acc x-> x : acc) [] xs Error Couldn't match expected type `a' with actual type `[a]' `a' is a rigid type variable bound by the type signature for reverse' :: [a] -> [a] at foldl.hs:33:13 Relevant bindings include x :: [a] (bound at foldl.hs:34:27) acc :: [a] (bound at foldl.hs:34:23) xs :: [a] (bound