Summary: The foldr function seems simple, but is actually very complex, with lots of layers. This post dives through the layers. The foldr function takes a list and replaces all : (cons) and [] (nil) values with functions and a final value. It's available in the Haskell Prelude and described on Wikipedia. As some examples: sum = foldr (+) 0 map f = foldr (\x xs -> f x : xs) [] But the simple foldr