<div dir="ltr">Briefly, because the 'spine' of IO (and indeed most monads) imposes a boundary on laziness, so when the IO action happens, the list *will* be built. It can only be bypassed by laziness if the IO action itself is.<div><br></div><div>Hypothetically one could have RULES that rewrite to the non-list-building variants (trailing _) if the result is seen to be discarded --- but it would probably be unreliable, much as stream fusion can only happen if things go just right.<br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 20, 2017 at 12:12 PM, Saurabh Nanda <span dir="ltr"><<a href="mailto:saurabhnanda@gmail.com" target="_blank">saurabhnanda@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="auto">Intresting. Wont using "void" or "_ <- forM blah" have the same effect? Why not? </div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 20-Sep-2017 9:37 PM, "Nick Smallbone" <<a href="mailto:nick@smallbone.se" target="_blank">nick@smallbone.se</a>> wrote:<br type="attribution"><blockquote class="m_-826665518040383374quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi Stanislav,<br>
<div class="m_-826665518040383374quoted-text"><br>
Станислав Черничкин <<a href="mailto:schernichkin@gmail.com" target="_blank">schernichkin@gmail.com</a>> writes:<br>
> I've wrote simple Haskell benchmark program, which populated primitive vector<br>
> from vector package:<br>
><br>
</div>> ...<br>
<div class="m_-826665518040383374quoted-text">> void $ for [0..1000000 - 1] $ flip (P.unsafeWrite v) (1 :: Int)<br>
<br>
</div>'for' is a variant of 'map' - it returns a list of results (in this case<br>
a list of a million () values). Instead you should use 'forM_' (note the<br>
underscore) from Control.Monad, which discards the result - that cuts<br>
the runtime by a huge amount when I try it. (And make sure to compile<br>
with -O too.)<br>
<br>
Nick<br>
<br>
______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>
</div></div></div>