Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "this function will fuse" mean?

The documentation for scanl says "this function will fuse". What exactly does fuse mean here? Is it bad?

like image 705
Rob Agar Avatar asked May 17 '11 20:05

Rob Agar


2 Answers

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.

like image 177
sclv Avatar answered Sep 28 '22 05:09

sclv


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

like image 24
Cade Roux Avatar answered Sep 28 '22 04:09

Cade Roux