A Beautiful Session on Beautiful Folds I am a beginner at Haskell and this talk was entertaining and enlightening but more importantly, it brought together a number of ideas (not just on folds) that I am only beginning to grok. Thank you so much. Please do more (I am going to search out all of your other sessions and lessons.) BTW, I am highly critical of most speakers -- you are superb.
@Tomyb158 ай бұрын
Really amazing stuff, and the speaker did a phenomenal job at explaining it. One question I have is whether mapping over a list/traversable just to apply a newtype data constructor could be avoided in some way via type coercion (which is always doable for newtypes) and whether it ends up making a difference. I'm not an experienced haskeller but I'm guessing it would require some type family magic.
@fordox42758 жыл бұрын
How can the average-fold be so efficient, if you basically create new list of `Average`s (thus you need extra iteration to copy the list)?
@3noch8 жыл бұрын
In short, a very smart compiler. 1. All those "Average" constructors are erased at compile time by GHC. They are only used to determine how to do plumbing at the type level. 2. The folds are using stream fusion to compile to a single loop with no intermediate structures. The compiler makes heavy use of inlining to detect these cases, even when your folds are the composition of other folds across module, or even package, boundaries.