Hi Niklas,

No, I mean this:

> V.forM_ (V.enumFromN 1 n)

I agree it's less elegant.  And like Daniel points out with lists, you definitely don't want the "enumFromN" to be shared.  But one of the biggest warts of Haskell IMHO is that it's still very difficult to get really high-performance code without an intimate understanding of the optimizer.

John L.

On Sat, Apr 26, 2014 at 6:16 PM, Niklas Hambüchen <mail@nh2.me> wrote:
Hey John,

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
quite sweet).
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?

Niklas

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.