-
Notifications
You must be signed in to change notification settings - Fork 28
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
Math operations might throw errors #274
Comments
In Elixir at least, calling |
For the sake of minimal compatibility with Elm right now it returns |
How about controversial opinion making division return |
Technically I'd think division should return a maybe unless the compiler could otherwise infer it is impossible for the denominator to be 0 (needs some measure of refined typing then). ^.^; |
@OvermindDL1 Should I create a card for implementing dependent types maybe? ;) |
@wende Lol, to do that you've have to re-implement Elm's typing system (or a better one...) before adding the refined typing enhancements. ;-) |
I like the Maybe from dividing rather than having a specific type that denotes "NonZero". |
@loganmac That's a good point but it could make false assumption of type-safety, when it's not REALLY safe, just contractual (someone could make The problem with making the division return Maybe is with overriding Basics, which cannot be easily done, so we end up with: |
So the only solution I can see right now is: |
@wende I hinted at you not being able to do that by not exposing the constructor, and only the function that can return Yeah, maybe something like |
@loganmac Oh I like the |
Right now divide by 0 on Ints returns 0.
Divide by 0 on floats returns NaN.
ANY MATH OPERATIONS ON NAN THROW ERROR.
It'd be nice to find a safe way to express 0 division consistently
The text was updated successfully, but these errors were encountered: