2 ms·
I don't think it's true in Haskell at all. A fold is just walking a list with an accumulator. That's not weird or low-level; it's as common for Haskell progra
by mbrubeck 17y ago
I don't think it's true in Haskell at all. A fold is just walking a list with an accumulator. That's not weird or low-level; it's as common for Haskell programmers as loops and variables for C programmers. It actually took me a while (when first learning SML and Scheme) to realize I could use the built-in reduce functions more, instead of writing loops "by hand" all the time.
It's also very common in Haskell to implement your own fold for various reasons. For example, in a simple 50-line text processing script[1], I defined a fold for a list-of-trees data structure without calling any builtin fold function[2].
[1]: http://github.com/mbrubeck/outline-grep http://github.com/mbrubeck/outline-grep
[2]: http://github.com/mbrubeck/outline-grep/blob/master/OutlineGrep.lhs#L20 http://github.com/mbrubeck/outline-grep/blob/master/OutlineG...
P.S. I like your blog, and huge thanks for Django!
- jrockway 17y agoActually, a fold is walking a Foldable with an accumulator :)