Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the "r" in unfoldr?

Tags:

haskell

Why is there an r in Data.List.unfoldr? Is it only for symmetry with foldr, or is there some other reason this unfolds should be considered to be right associative?

This came up when I was considering adding an unfold to Data.HashMap, where I couldn't think of a reason to include an r in the name. HashMaps have both right and left folds. I don't see a reason why the unfold would be more right than left.

like image 658
tibbe Avatar asked May 21 '14 09:05

tibbe


1 Answers

In "The Underappreciated Unfold", where unfoldr is introduced, it is known as unfold (and foldr is fold, as you see here). However, by the time it made it into the List library, it had become unfoldr, as a dual to foldr.

like image 174
Don Stewart Avatar answered Nov 02 '22 19:11

Don Stewart