Proposal: Add a catamorphism on Trees

Michael Walker mike at barrucadu.co.uk
Tue May 17 21:19:01 UTC 2016


On Tue, 17 May 2016 17:03:31 -0400
David Feuer <david.feuer at gmail.com> wrote:

> Daniel Wagner would like to add the following straightforward function
> to Data.Tree. I think this is a grand idea.
> 
> foldTree :: (a -> [b] -> b) -> Tree a -> b
> foldTree f = go
>   where
>     go (Node x ts) = f x (map go ts)

+1

Nice, simple, and useful.

-- 
Michael Walker (http://www.barrucadu.co.uk)


More information about the Libraries mailing list