Unfortunately, the function Data.Vector.Generic.length is not currently covered by stream fusion. This is because length is defined in terms of Data.Vector.Generic.stream', which does not admit fusion rules at all.
As a result, the following simple code:
https://gist.github.com/gksato/417030a1f19f1f376dcb2fabaf66c10a#file-test-hs
does require a big allocation:
https://gist.github.com/gksato/417030a1f19f1f376dcb2fabaf66c10a#file-testbefore-ddump-simpl
I'm soon gonna submit a pull request to fix this!
Unfortunately, the function
Data.Vector.Generic.lengthis not currently covered by stream fusion. This is becauselengthis defined in terms ofData.Vector.Generic.stream', which does not admit fusion rules at all.As a result, the following simple code:
https://gist.github.com/gksato/417030a1f19f1f376dcb2fabaf66c10a#file-test-hs
does require a big allocation:
https://gist.github.com/gksato/417030a1f19f1f376dcb2fabaf66c10a#file-testbefore-ddump-simpl
I'm soon gonna submit a pull request to fix this!