We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Wedge
The example is a bit convoluted but illustrates the point.
I've opened a branch with a worksheet so that it's easy to reproduce.
https://github.com/gemini-hlsw/lucuma-core/blob/wedge/modules/tests/shared/src/test/scala/lucuma/core/optics/wedge.worksheet.sc
In summary, if we define:
val mirrorWedge: Wedge[Option[BigDecimal], Option[BigDecimal]] = Wedge( _.map(_.setScale(2, scala.math.BigDecimal.RoundingMode.HALF_UP)), _.map(_.setScale(2, scala.math.BigDecimal.RoundingMode.HALF_UP)) ) val posBigDecimalWedge: Wedge[Option[BigDecimal], Option[PosBigDecimal]] = Wedge( _.flatMap(bd => PosBigDecimal.from(bd).toOption), _.map(_.value) ) val combinedWedge: Wedge[Option[BigDecimal], Option[PosBigDecimal]] = mirrorWedge.andThen(posBigDecimalWedge)
Then both mirrorWedge and posBigDecimalWedge are lawful, but combinedWedge fails normalize B.
mirrorWedge
posBigDecimalWedge
combinedWedge
normalize B
It seems to be caused because truncation on the reverseGets turns a valid PosBigDecimal into an invalid one (when x < 0.01).
PosBigDecimal
x < 0.01
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The example is a bit convoluted but illustrates the point.
I've opened a branch with a worksheet so that it's easy to reproduce.
https://github.com/gemini-hlsw/lucuma-core/blob/wedge/modules/tests/shared/src/test/scala/lucuma/core/optics/wedge.worksheet.sc
In summary, if we define:
Then both
mirrorWedge
andposBigDecimalWedge
are lawful, butcombinedWedge
failsnormalize B
.It seems to be caused because truncation on the reverseGets turns a valid
PosBigDecimal
into an invalid one (whenx < 0.01
).The text was updated successfully, but these errors were encountered: