<div dir="ltr">John, can't a careful use of the identity monad or the like prevent that CSE? (i'm a bit fuzzy on that piece of ghc lore)</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Apr 26, 2014 at 10:28 PM, John Lato <span dir="ltr"><<a href="mailto:jwlato@gmail.com" target="_blank">jwlato@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Niklas,<div><br></div><div>No, I mean this:</div><div><br></div><div>> V.forM_ (V.enumFromN 1 n)</div>

<div><div class="gmail_extra"><br></div><div class="gmail_extra">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.</div>


<div class="gmail_extra"><br></div><div class="gmail_extra">John L.</div><div class=""><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 26, 2014 at 6:16 PM, Niklas Hambüchen <span dir="ltr"><<a href="mailto:mail@nh2.me" target="_blank">mail@nh2.me</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey John,<br>
<br>
do you mean something along the lines of `V.forM_ (fromList [1..n])`?<br>
I guess GHC wouldn't mash away the list in this case and I'd have to<br>
use the new OverloadedLists with `V.forM_ [1..n]` (indeed that looks<br>
quite sweet).<br>
However, would that actually be fast? Judging from how list syntax is<br>
desugared, I guess that would use `V.enumFromTo` then, whose docs claim<br>
"WARNING: This operation can be very inefficient. If at all possible,<br>
use enumFromN instead".<br>
<br>
Does anybody know  wonder if "vector literals" desugar enumFromN, or<br>
what "can be very inefficient" means?<br>
<span><font color="#888888"><br>
Niklas<br>
</font></span><div><div><br>
On Sun 27 Apr 2014 01:13:52 BST, John Lato wrote:<br>
> I usually use a manually written loop, but you can use Data.Vector for<br>
> this and it should fuse.<br>
<br>
</div></div></blockquote></div><br></div></div></div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>