<div dir="ltr"><div>Ok, so if understood the bottom line of the answers I got from Vanessa and Hiromi the take away seems to be: if you're prototyping then stick to the lazy version of sum, otherwise use more advanced data structures (Vectors or Folds).</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Aug 14, 2018 at 5:18 PM Vanessa McHale <<a href="mailto:vanessa.mchale@iohk.io">vanessa.mchale@iohk.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p>Actually, vector has a sum function already:
<a class="m_3297687457578488098moz-txt-link-freetext" href="http://hackage.haskell.org/package/vector-0.12.0.1/docs/Data-Vector.html#v:sum" target="_blank">http://hackage.haskell.org/package/vector-0.12.0.1/docs/Data-Vector.html#v:sum</a><br>
<br>
It's strict, and I'd guess more efficient than foldl' on lists. <br>
</p>
<br>
<div class="m_3297687457578488098moz-cite-prefix">On 08/14/2018 09:44 AM, Vanessa McHale
wrote:<br>
</div>
<blockquote type="cite">
<p>To be more explicit: unless you've actually benchmarked <tt>sum</tt>
vs <tt>sum'</tt> this seems to be a premature optimization and
you'd be better off just using the stock <tt>sum</tt> with a
sensible data structure.<br>
</p>
<br>
<div class="m_3297687457578488098moz-cite-prefix">On 08/14/2018 09:40 AM, Damian
Nadales wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr"><br>
<br>
<div class="gmail_quote">
<div dir="ltr">On Tue, Aug 14, 2018 at 4:25 PM Vanessa
McHale <<a href="mailto:vanessa.mchale@iohk.io" target="_blank">vanessa.mchale@iohk.io</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p>If you'd rather import a custom prelude instead of
writing `sum = foldl' (+) 0` you might want to think
about how dependencies affect maintaining a package.</p>
<p>What's the actual problem you're trying to solve?<br>
</p>
</div>
</blockquote>
<div>Just add a list of values. I was expecting such a
function to be already defined somewhere else.</div>
<div><br>
</div>
<div>Personally, in terms of cognitive complexity I find
`sum` less complex than `fold' (+) 0`...<br>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p> </p>
<br>
<div class="m_3297687457578488098m_-9122893266650837319moz-cite-prefix">On
08/14/2018 04:09 AM, Damian Nadales wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>I thought the answer would be easy to find on
the internet, but I cannot find any package that
features a strict version of `sum`. <br>
</div>
<div><br>
</div>
<div>Do you know if such a function is defined
anywhere? (like a custom prelude for instance)</div>
<div><br>
</div>
<div>I know it is trivial to define, but I would
prefer not to repeat myself (and somebody else).</div>
<div><br>
</div>
<div>Thanks!<br>
</div>
</div>
<br>
<fieldset class="m_3297687457578488098m_-9122893266650837319mimeAttachmentHeader"></fieldset>
<br>
<pre>_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a class="m_3297687457578488098m_-9122893266650837319moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
</blockquote>
</div>
_______________________________________________<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-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed
to post.</blockquote>
</div>
</div>
</blockquote>
<br>
<div class="m_3297687457578488098moz-signature">-- <br>
<br>
<br>
<br>
<strong style="color:#000;font-family:Helvetica,Arial;font-size:116%">Vanessa
McHale</strong><br>
<span style="color:#000;font-family:Helvetica,Arial;font-size:100%"><span style="color:#f00">Functional Compiler Engineer |</span>
Chicago, IL</span> <br>
<br>
<span style="color:#999;font-family:Helvetica,Arial;font-size:85%">Website:
<a href="http://iohk.io" style="color:#f00" target="_blank">www.iohk.io</a></span><br>
<span style="color:#999;font-family:Helvetica,Arial;font-size:85%">Twitter:
@vamchale</span><br>
<span style="color:#999;font-family:Helvetica,Arial;font-size:85%">PGP
Key ID: 4209B7B5</span><br>
<br>
<a href="http://iohk.io" target="_blank"><img src="https://static.iohk.io/logo/logo-email.png" alt="Input
Output" height="46" width="200"></a>
<br>
<br>
<a href="https://twitter.com/InputOutputHK" target="_blank"><img src="https://static.iohk.io/images/ic-tw.png" alt="Twitter" height="16" width="18"></a> <a href="https://github.com/input-output-hk" target="_blank"><img src="https://static.iohk.io/images/ic-gh.png" alt="Github" height="16" width="21"></a> <a href="https://www.linkedin.com/company/input-output-global" target="_blank"><img src="https://static.iohk.io/images/ic-li.png" alt="LinkedIn" height="16" width="19"></a> <br>
<br>
<br>
<span style="color:#444;font-family:Helvetica,Arial;font-size:77%"><small>This
e-mail and any file transmitted with it are confidential and
intended solely for the use of the recipient(s) to whom it
is addressed. Dissemination, distribution, and/or copying of
the transmission by anyone other than the intended
recipient(s) is prohibited. If you have received this
transmission in error please notify IOHK immediately and
delete it from your system. E-mail transmissions cannot be
guaranteed to be secure or error free. We do not accept
liability for any loss, damage, or error arising from this
transmission</small></span></div>
</blockquote>
<br>
<div class="m_3297687457578488098moz-signature">-- <br>
<br>
<br>
<br>
<strong style="color:#000;font-family:Helvetica,Arial;font-size:116%">Vanessa
McHale</strong><br>
<span style="color:#000;font-family:Helvetica,Arial;font-size:100%"><span style="color:#f00">Functional Compiler Engineer |</span>
Chicago, IL</span>
<br>
<br>
<span style="color:#999;font-family:Helvetica,Arial;font-size:85%">Website:
<a href="http://iohk.io" style="color:#f00" target="_blank">www.iohk.io</a></span><br>
<span style="color:#999;font-family:Helvetica,Arial;font-size:85%">Twitter:
@vamchale</span><br>
<span style="color:#999;font-family:Helvetica,Arial;font-size:85%">PGP
Key ID: 4209B7B5</span><br>
<br>
<a href="http://iohk.io" target="_blank"><img src="https://static.iohk.io/logo/logo-email.png" alt="Input
Output" height="46" width="200"></a>
<br>
<br>
<a href="https://twitter.com/InputOutputHK" target="_blank"><img src="https://static.iohk.io/images/ic-tw.png" alt="Twitter" height="16" width="18"></a>
<a href="https://github.com/input-output-hk" target="_blank"><img src="https://static.iohk.io/images/ic-gh.png" alt="Github" height="16" width="21"></a>
<a href="https://www.linkedin.com/company/input-output-global" target="_blank"><img src="https://static.iohk.io/images/ic-li.png" alt="LinkedIn" height="16" width="19"></a>
<br>
<br>
<br>
<span style="color:#444;font-family:Helvetica,Arial;font-size:77%"><small>This
e-mail and any file transmitted with it are confidential and
intended solely for the use of the recipient(s) to whom it is
addressed. Dissemination, distribution, and/or copying of the
transmission by anyone other than the intended recipient(s) is
prohibited. If you have received this transmission in error
please notify IOHK immediately and delete it from your system.
E-mail transmissions cannot be guaranteed to be secure or
error free. We do not accept liability for any loss, damage,
or error arising from this transmission</small></span></div>
</div>
</blockquote></div>