<div dir="ltr"><div><div>I don't think I see what you are getting at, Tom. Let's consider the special case of non-empty lists. One fold-like function that has the property I think Charles meant by 3., would be one that works as follows:<br><br></div>foldBalanced :: (a -> a -> a) -> [a] -> a<br></div>foldBalanced f [x] = x<br>foldBalanced f [x,y] = f x y<br><div><div>foldBalanced f [x,y,z] = f x (f y z)<br>foldBalanced f [x,y,z,u] = f (f x y) (f z u)<br></div><div>... -- I hope you can see the pattern (building f-application trees that are as balanced as possible)<br></div><div><br></div><div>I don't see how this function can be written as g . foldl f z for some g and z.<br></div><div><div><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-10-25 0:55 GMT+02:00 Tom Ellis <span dir="ltr"><<a href="mailto:tom-lists-haskell-cafe-2013@jaguarpaw.co.uk" target="_blank">tom-lists-haskell-cafe-2013@jaguarpaw.co.uk</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, Oct 24, 2015 at 08:12:11PM +0200, Janis Voigtländer wrote:<br>
> It has already been established in this thread what Charles meant by 3.<br>
><br>
> He meant that a fold-function that has the property he is after would<br>
> guarantee that it:<br>
><br>
> a) takes all the content elements from a data structure, say x1,...,xn,<br>
><br>
> b) builds an application tree with the to-be-folded, binary operation f in<br>
> the internal nodes of a binary tree, whose leafs, read from left to right,<br>
> form exactly the sequence x1,...,xn,<br>
><br>
> c) evaluates that application tree.<br>
><br>
> Do you agree that what I describe above is a property of a given fold-like<br>
> function, not of the f handed to that fold-like function?<br>
><br>
> And do you agree that what I describe above is a property that is weaker<br>
> than (and so, in particular different from) for example the property "this<br>
> fold-like function is foldl or foldr".<br>
<br>
I do agree.  I would be interested whether you think such a property could<br>
differ from my earlier proposed property:<br>
<br>
    "the function factors through `foldl f`", i.e.  is `g . foldl f` for<br>
    some `g`.<br>
<br>
(Actually when I wrote that I suppose I meant `g . foldl f z` for some `g`<br>
and `z`)<br>
<br>
Tom<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><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>
</blockquote></div><br></div>