An anecdote... 😏 #336
Replies: 3 comments 6 replies
-
Actually, can I ask you about your take on You extend We can sensibly define distance between pair of non-negative numbers. In your view, is there a case for an OrderedMonus typeclass, ie Monus+Order, that could also implement eg Spire's |
Beta Was this translation helpful? Give feedback.
-
Another question, if I may. Your Monus chooses a "has a" over trait inheritance "is a":
Typelevel Algebra generally prefers the inheritance approach (as do I, I think) eg Field, but it is not 100% consistent see eg Signed Is there a design heuristic here that you follow and can express, or is this simply a case of different practices colliding and a lack of consensus? |
Beta Was this translation helpful? Give feedback.
-
(Moved to a discussion on this repo, where
I actually haven't heard of the "M-Semiring", can you link me anything about that? |
Beta Was this translation helpful? Give feedback.
-
Whoops, somehow using an emoji created the issue prematurely.
Anyway, an anecdote..
In an unpublished project, I have opaque types that model non-negative Integers, Doubles and Decimals.
Initially, I added bespoke operations as extension methods to each, but that got boring fast. So I switched to using Algebra; define surface-syntax in terms of the typeclasses in Typelevel algebra and Spire, and then implement those TCs for my non-negative types. Has proved quite practical, and feels like a much more solid base to go forward upon.
However. It turned out to be far from obvious what algebras to implement for non-negative integral and rational data types. I got as far as
Semifield
which gave me everything but subtraction. Solving subtraction led me down a fascinating wikipedia rabbit hole and ultimately to the discovery ofMonus
.But then I hit another doubt. What algebraic structure models non-negative rationals, in entirety? M-Semiring doesnt include division. Semifield doesn't include monus-subtraction. Is there such thing as a "M-Semifield"? 🤔 💭
Surely the combined mathematical GDP of the world has been able to give name to the algebra of such a ubiquitous class of numbers as the non-negative rationals/reals..? surely..?
And it was in the spirit of doubtful inquiry that I accidentally googled your project, number 2 after wikipedia. "Arman Bilge woz here!"
And sure enough, it does seem like the weight type
W
in your Resampler is intended to be a non-negative rational.And that felt like an anecdote worth sharing... :)
Beta Was this translation helpful? Give feedback.
All reactions