This repository was archived by the owner on Mar 12, 2026. It is now read-only.
Opaque type arithmetic: clamp, monthly, eliminate .toDouble#133
Merged
Opaque type arithmetic: clamp, monthly, eliminate .toDouble#133
Conversation
- PLN, Rate, Ratio gain .clamp(lo, hi) extension method - ~20 sites converted from Type(Math.max(lo, Math.min(hi, x.toDouble))) to opaque-type arithmetic: .max(), .min(), .clamp() - Fix mistyped skillDecayRate/scarringRate: Rate → Ratio (monthly increments to Ratio fields, not interest rates) - FirmEntry.drawDigitalReadiness return type Double → Ratio
- Add Rate.monthly (annual → monthly rate conversion) - Replace PLN(x.toDouble + y.toDouble) with x + y - Replace PLN(x.toDouble * rate.toDouble / 12.0) with x * rate.monthly - Replace Rate(a.toDouble + b.toDouble + c.toDouble) with a + b + c - Replace Ratio(...toDouble * smoothing + ...toDouble * smoothing) with opaque Ratio/Rate * scalar arithmetic - GvcTrade.kahanSumBy left as-is (Kahan precision requires Double)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
clamp(lo, hi)to PLN, Rate, Ratio — replacesType(Math.max(lo, Math.min(hi, x.toDouble)))patternRate.monthly—rate / 12.0with intent (annual → monthly conversion)Type(Math.max/min(...toDouble...))to.max(),.min(),.clamp().toDoubleroundtrips in opaque type arithmetic (PLN+PLN, Rate+Rate, PLN*Rate)skillDecayRate/scarringRate:Rate→Ratio(monthly increments to Ratio fields, not interest rates)FirmEntry.drawDigitalReadinessreturn typeDouble→RatioTest plan
sbt compile— 0 errors