Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Or by a sufficiently smart compiler that realises it can fuse the intermediate steps into a single loop (like GHC)?).


So, the appeal of transducers is plug-and-play fusion. Like, it takes quite a bit of work to get newly created non-list types to fuse correctly in Haskell (that being said: you can do it in Haskell, which is kind of amazing considering how ridiculously impossible this is in almost every toolset, and popular libraries already have, which is also amazing). Transducers get you stream fusion for e.g. channels in a close-to-free way (you define the stepping function, you get takeWhile, partition-by, etc. all for free, so it's O(1) instead of O(n)-O(n^2) to figure out all the combos you want to stream together).

EDIT: _part_ of the appeal. The other is concisely describing things like takeWhile in a way that's both polymorphic and doesn't require multiple implementations. Good refactor motivation in general, happens to have the above property, which is good.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: