(更多信息:< a href="http://www.haskell.org/haskellwiki/Correctness_of_short_cut_fusion" rel="noreferrer">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.
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.
发布评论
评论(3)
http://www.haskell.org/haskellwiki/Short_cut_fusion
(更多信息:< a href="http://www.haskell.org/haskellwiki/Correctness_of_short_cut_fusion" rel="noreferrer">http://www.haskell.org/haskellwiki/Correctness_of_short_cut_fusion)
如果一个函数能够融合,那是一件好事。这意味着一系列函数可以合并为一个函数,这意味着更少的分配、更少的堆栈和更快的速度!惊人的!
这是一个简单的融合:
map f 。地图g
---->地图(f.g)
。如上所述,还有许多其他内容也适用标准库的规则。
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.
它有点像协程 - 如果您编写两个函数,它们可以在融合流上执行,而不是先完全“评估”一个,然后再“评估”第二个。
什么是 Haskell 的 Stream Fusion
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!