-
Notifications
You must be signed in to change notification settings - Fork 4
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
PositiveDouble
prototype: representing a positive and finite numbers
#5
Conversation
* } | ||
* ``` | ||
*/ | ||
open class ArrowExactConstraintViolationError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this less verbose? It's a trade-off between information and verboseness.
* } | ||
* ``` | ||
*/ | ||
class ArrowExactPositiveDoubleConstraintError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this less verbose? It's a trade-off between information and verboseness.
@@ -69,3 +69,7 @@ kotlin { | |||
} | |||
} | |||
} | |||
|
|||
tasks.named<Test>("jvmTest") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests couldn't execute so I added this. Idk, if this or the invalidate & restart fixed the issues
PositiveDouble
prototype: represents a positive and finite numbersPositiveDouble
prototype: representing a positive and finite numbers
Are you sure about operators returning context(Raise<ArrowExactConstraintViolationError>)
operator fun plus(other: PositiveDouble): PositiveDouble and dsl like Yes, I am suggesting to design it with context receivers from the start and keep experimental/ pre-release until context receivers are landed. I just don't see it any other way for primitives. P.S. I apologize in advance, I could be totally off track here and misunderstand a lot since I did not even use arrow yet, just reading the new web site. |
Side note: Don't forget to check #4 which our discussion issue: Feel free to share your thoughts, ideas, and opinions - all are more than welcome! |
Good point @pacher! I like the |
Also, it feels right to do overloading like operator fun plus(other: PositiveDouble) = if (...) throw ...
context(Raise<ArrowExactConstraintViolationError>)
operator fun plus(other: PositiveDouble) = if (...) raise ... but it is actively discouraged ... sigh |
And the biggest design question is what to do when mixing with regular primitives. What should be the return type of |
We decided to use a more generalized design in #4 which makes this PR obsolete. |
Based on #4 I've implemented a simple
PositiveDouble
prototype.TL;DR;
PositiveDouble(5.0)
orPositiveDouble.unsafe(-2.0)
which throws are exceptionPositiveDouble.fromDouble(a)
which returns OptionPositiveDouble#mapSafe
extension for safely transforming the wrapped Double valueArrowExactConstraintViolationError
with detailed error message for easier debugging or handling programatically