-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplifying coulomb operation signatures #534
Comments
On the down side, doing this would itself be a somewhat substantial rewrite, including some of the documentation. But at least it would be a rewrite in the direction of "more simple and easy" |
I could, while I am at it, reconsider |
What exactly are your reservations? Spire has been extremely stable for several years now. Btw, overall big 👍 to the simplifications proposed here. Besides the UX improvements, it also lowers the bar to contributors and increases the maintainer bus factor. Thanks for the exposition here! |
@armanbilge my concerns with spire mostly stem from:
Regarding (1), I guess the transition is complete, so it's no longer an issue, unless we are some day presented with scala 4 :) Regarding (2), maybe it's just an indication that the package is stable. There's only so much one can do, implementing numeric types. Lastly, I really wanted to make |
As a side note, one of the things that has been interesting working with I occasionally wish I could make Quantity into a monad, but its two type parameters work against that. I've been lately wondering if something like this would be feasible, and if so would it be worth it. // give Quantity a single type parameter,
// but force it to be of form `(V, U)`
Quantity[VU <: (?, ?)] |
One of the most unusual facets of coulomb is that the unit parameter is a totally free type parameter - it is not associated with any actual concrete value, but only influences certain relations at compile time. |
Right, fortunately this was a one-time thing :) To that point: have you encountered any significant issues using it on Scala 3? If not, I would say that transition was a success, and the Spire has stabilized its Scala 3 support (off the top of my head I can think of only one outstanding Scala 3-specific bug relating to the
Isn't that the definition of stability? 😜 if you are looking for a library that can move fast and break things to better support Coulomb's usecases, indeed Spire is not the right choice: at this stage we have little appetite for compatibility-breaking changes. However, if there are specific things we can do to further stabilize Spire and make it more useful to Coulomb please let me know. Is it possible your reservations are about whether Spire is "maintained" rather than if it is "stable"? In that case, yes, I am maintaining it :) |
@armanbilge no, I have had no issues with spire. As you say, inactivity is often a warning sign that projects are no longer maintained. I wondered if you were maintaining it, I did notice you were the most recent commit :) I think the only issue I had with spire, was constructing a matrix of conversions. Not all of its types convert directly to each other, and I'm pretty sure I get why, since it involves making some choices in terms of precision in some cases. Getting rid of value promotion may reduce the need for that, but either way I have a solution. I'm leaning toward just deciding to make it a coulomb-core dependency. |
It would really help me if |
Hi Erik, apologies for the slow response on this. We've discussed the Spire dependency in another thread, but as to the primary topic of this proposal, simplifying the signatures and eliminating cross-value operations, I'm good with that. From time to time I do combine Ints and BigDecimals (typically when treating an Int as a way to make a Decimal), or add an Int to a Long timestamp. But these will be readily handled with explicit conversions. Intrigued but unsure about idea of expressing Quantity with a single type Seems like we can derive single-type-param TCs (eg
|
@benhutchison I'm not really sure if a single It's clean to define additive monoid for |
Great point, thanks for the reminder. 🤔 💭 actually I wonder... is that distinction among Monoids visible in algebra/math? |
That is a very interesting question - I gave a talk one time on my unit-aware matrix algebra, and a mathematician in the audience said "we don't generally care because the matrixes are all isometric" - and although I care, his point was solid 😁 I think even if you are tracking the units, they are probably still multiplicative monoids if you take the view that the "objects" are "algebraic terms with number and unit factors in them" - so I suppose that would make them more or less like RuntimeQuantity. |
When I designed the scala-3 port, I designed the operation signatures to support value semantics similar to traditional numeric value promotion: for example
1 + 2.0 => 3.0
(integer + double => double). I also pushed the implicit conversion of units into the same signatures, and so I have fairly complex implicit constucts like:And furthermore the entire
ValueResolution
machinery:https://github.com/erikerlandson/coulomb/blob/scala3/core/src/main/scala/coulomb/ops/ops.scala#L180
While I was able to make all of this complexity work, and it was cool and fun, I have my doubts about whether it is a great design in the bigger picture.
scala.Conversion
and I can do the same. This will localize the conversion logic and simplify it substantially. If someone would prefer to not enable implicit conversions, they can just not import them (itself a simplification of "policies").scala.Conversion
orq.toValue
,q.toUnit
, etc.This would make
coulomb-core
smaller, simpler, and probably easier to understand. It also reduces compiler load, and probably makes the entire system a bit more stable. When implementingAdd
and friends, I often felt like the compiler barely supported what I was trying to do. Pulling back from that threshold a bit might be a good thing.The text was updated successfully, but these errors were encountered: