# unfoldr in Library Report

**Ross Paterson
**
ross@soi.city.ac.uk

*Fri, 1 Jun 2001 11:04:34 +0100*

While looking through the List module, I came across
The unfoldr function undoes a foldr operation. Note that, in general,
only invertible functions can be unfolded.
[followed by an equation about undoing foldr]
This is quite inadequate: unfoldr is very useful with non-invertible
functions. I suggest something like:
The unfoldr function is a `dual' to foldr: while foldr reduces a list
to a summary value, unfoldr builds a list from a seed value, e.g.,
iterate f == unfoldr (\x -> Just (x, f x))
In some cases unfoldr can undo a foldr operation:
[followed by the existing equation]