Pretty wild ideas, though. Fair chance they'd be more confusing than using more specifically named instances, but solid ideas where the class instance documents that you're using the pattern, instead of describing the preferred interface.
Pretty wild ideas, though. Fair chance they'd be more confusing than using more specifically named instances, but solid ideas where the class instance documents that you're using the pattern, instead of describing the preferred interface.
I suppose it might help sometimes when designing an abstraction, to guide you to some nice properties, such as easy composition.
At least in Haskell one thing it means is you can use lots of new helper functions.
> guide you to some nice properties, such as easy composition.
Yep, which gets you code re-use for one.
So, in addition to being able to raise numbers to powers I could also use it on matrices whose elements belonged to a semiring.
That is, I could use the same code on a matrix of doubles with "times" and "plus" (for the Markov chains), as well as a matrix of booleans with "and" and "or" (for the graph connectivity).
(Of course, I could have used special purpose libraries, but these were small problems and it was fun. :)
You can write monoid and foldable interfaces in java but in haskell finding the head of a list with a monoid and foldmap is constant time (and the first or last element of a tree is logarithmic) but a java implementation would be linear.
That's what the recent CALM Theorem [1] paper uses as the first theorem:
> Monotonicity is the key property underlying the need for coordination to establish consistency, as captured in the CALM Theorem:
> THEOREM 1. Consistency As Logical Monotonicity (CALM). A problem has a consistent, coordination-free distributed implementation if and only if it is monotonic.
Unsurprisingly, this paper is reference 32 in CALM. Maybe I should check out some other papers referenced here... Thanks for the recommendation!
[1]: https://cacm.acm.org/magazines/2020/9/246941-keeping-calm/fu...