[Haskell-cafe] How to write fast for loops
mail at nh2.me
Sun Apr 27 01:16:06 UTC 2014
do you mean something along the lines of `V.forM_ (fromList [1..n])`?
I guess GHC wouldn't mash away the list in this case and I'd have to
use the new OverloadedLists with `V.forM_ [1..n]` (indeed that looks
However, would that actually be fast? Judging from how list syntax is
desugared, I guess that would use `V.enumFromTo` then, whose docs claim
"WARNING: This operation can be very inefficient. If at all possible,
use enumFromN instead".
Does anybody know wonder if "vector literals" desugar enumFromN, or
what "can be very inefficient" means?
On Sun 27 Apr 2014 01:13:52 BST, John Lato wrote:
> I usually use a manually written loop, but you can use Data.Vector for
> this and it should fuse.
More information about the Haskell-Cafe