<div dir="ltr">Fantastic! Thanks, Thomas!<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 7, 2015 at 3:49 PM, Thomas Bach <span dir="ltr"><<a href="mailto:thbach@students.uni-mainz.de" target="_blank">thbach@students.uni-mainz.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Jeffrey Brown <<a href="mailto:jeffbrown.the@gmail.com">jeffbrown.the@gmail.com</a>> writes:<br>
<br>
> head $ Data.Set.toList S. If I do that, am I correct that Haskell will<br>
> not try to convert all of S to a list; instead it will only convert<br>
> one element, and then return it, and leave the rest of the list<br>
> unevaluated?<br>
<br>
</span>This is how toList from Data.Set.Base is defined in containers-0.5.0:<br>
<br>
{--------------------------------------------------------------------<br>
  Lists<br>
--------------------------------------------------------------------}<br>
-- | /O(n)/. Convert the set to a list of elements. Subject to list fusion.<br>
toList :: Set a -> [a]<br>
toList = toAscList<br>
<br>
-- | /O(n)/. Convert the set to an ascending list of elements. Subject to list fusion.<br>
toAscList :: Set a -> [a]<br>
toAscList = foldr (:) []<br>
<br>
The buzzword you are looking for is list fusion:<br>
<br>
<a href="http://stackoverflow.com/questions/10945429/haskell-list-fusion-where-is-it-needed" target="_blank">http://stackoverflow.com/questions/10945429/haskell-list-fusion-where-is-it-needed</a><br>
<br>
Regards<br>
<span class="HOEnZb"><font color="#888888"><br>
        Thomas Bach.<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</font></span></blockquote></div><br></div>