
Yeah, I realize that its probably not conveniently expressible in types or
anything. I was more thinking along the lines of how the Monad laws are
expressed as a side note in the docs, and not type enforced in Haskell
itself.
I just thought it was vague to say that a fold takes an associative
function instead of indicating what kind of topology a fold honors, as the
former is only implying how the fold promises to operate. It would be
surprising to me that this hasn't been formalized mathematically in some
way.
Charlie
On Fri, Oct 23, 2015 at 7:01 PM, Clinton Mead
Basically you want to force an argument to be associative yes?
I don't think there's a way to do that in Haskell, but what you could do is create a datatype:
data Associative a b = Associative (a -> b)
You could then make "Associative" a Category, or perhaps even an Arrow, so you could combine Associative functions to make new Associative functions.
But it would still be up to the user to ensure they only promote actual associative functions to "Associative".
On Sat, Oct 24, 2015 at 8:24 AM, Bardur Arantsson
wrote: On 10/23/2015 06:07 PM, Charles Durham wrote:
I can think of a few properties that folds can honor:
1. Promises to call f on all data (does not have any guarantees on order)
"Exhaustive"?
... but then that's not really observable in a language like Haskell, except if you monitor CPU heat.
Regards,
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe