[Haskell-cafe] 'Associative' order of calling

Marcin Mrotek marcin.jan.mrotek at gmail.com
Wed Oct 28 19:05:22 UTC 2015


>
> And look at what we have: A definitive answer to OP's question:
>
> Question: What is a fold of type "(a -> a -> a) -> [a] -> a" that promises
> to call its first parameter "associatively"?
>
> Answer: It is a fold equivalent to a fold1 (left or right, it doesn't
> matter).
>
> That's nice.
>
> But is that all we can come up with? Does it really do justice to the
> original question? Viz.
>

Hello,

Sorry for jumping into the thread, but I've read the previous responses,
and I still don't get it (perhaps it's because I'm not a native English
speaker): what does "associatively" mean in this context? From what I
understand, "associativity" is a property of a function, that f (f a b) c =
f a (f b c). Nothing more, nothing less. In order to encode this property
in the type of a "fold" function, you'd need dependent types and a
type-level proof that a given function is associative. Without dependent
types, you can only trust the user to either supply an associative
function, or accept wrong results (like REPA does). Am I missing something?

Best regards,
Marcin Mrotek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151028/057af944/attachment.html>


More information about the Haskell-Cafe mailing list