Hello Alexey,<div><br></div><div>sorry for my slow response.<br><br><div class="gmail_quote">On Thu, Aug 4, 2011 at 7:10 AM, Alexey Khudyakov <span dir="ltr">&lt;<a href="mailto:alexey.skladnoy@gmail.com">alexey.skladnoy@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 02.08.2011 08:16, Sebastian Fischer wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Data.Foldable also provides the monoidal fold function foldMap. It is<br>
left unspecified whether the elements are accumulated leftwards,<br>
rightwards or in some other way, which is possible because the combining<br>
function is required to be associative. Does this additional freedom for<br>
implementors go so far as to allow for strict accumulation?<br>
<br>
</blockquote></div>
Left and right folds behave identically for finite structures but they are different for infinite ones. </blockquote><div><br></div><div>I agree that for types like normal lists that allow infinite structure it makes sense to have different folds like foldr and foldl that are explicit about the nesting of the combining function.</div>
<div><br></div><div>I don&#39;t think that there are laws for foldMap that require it to work for infinite lists. One could even argue that the monoid laws imply that the results for folding leftwards and rightwards should be equal, that is undefined..</div>
<div><br></div><div>For types that only allow finite sequences (like Data.Sequence or Data.Vector) this is not an issue. But you convinced me that a strict and lazy foldMap can be distinguished even for list types that have a strict append function by using a lazy mappend function for accumulation.</div>
<div><br></div><div>Best regards,</div><div>Sebastian</div></div></div>