开发者

What does "this function will fuse" mean?

The documentation for scanl says "this function will fuse". What exactly do开发者_开发百科es fuse mean here? Is it bad?


http://www.haskell.org/haskellwiki/Short_cut_fusion

(and, for more information: http://www.haskell.org/haskellwiki/Correctness_of_short_cut_fusion)

If a function will fuse, that is a good thing. It means that a chain of functions can be merged into one function, which means less allocation, less stack, and more speed! Awesome!

Here's a trivial fusion: map f . map g ----> map (f . g).

As detailed above, there are many others that get applied by the RULES of the standard library as well.


It's kind of like coroutines - if you compose two functions they can execute on a fused stream instead of one being fully "evaluated" first then the second.

What is Haskell's Stream Fusion


I would assume it's referring to stream fusion optimization techniques, and stating that they can be applied to the function. Essentially, if you have two functions that transform sequences, the optimizer will merge the transformations together so only one traversal is required.

In short, no, it's not bad. Quite the opposite!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜