Skip to main content

Recursion for Haskells

Recursion in Haskell is the main way to repeat work, since there are no loops with mutable counters. A function calls itself on a smaller input until a base case stops it. Higher-order functions such as map, filter and foldr capture common recursive patterns so you rarely write the recursion by hand.

Stage: Foundations · Part of the Haskell roadmap · Last reviewed 19 November 2026

What to learn in Recursion

Recursion interview questions

What is the difference between foldl and foldr?

foldr processes a list from the right, replacing each cons with a function and the empty list with an initial value, so it can work on infinite lists lazily. foldl accumulates from the left and can build up unevaluated thunks, so foldl' is preferred for sums.

What is tail recursion and does it matter in Haskell?

A tail-recursive function makes its recursive call as the last action, so it can run in constant stack space. In Haskell laziness changes the picture, so the accumulator may need to be forced with seq or a bang pattern to avoid building thunks.

Where Recursion fits in the Haskell roadmap

Recursion belongs to the Foundations stage (intermediate level), which takes about 23 hours. Pure functions.

Back to the full Haskell roadmap