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
Rational numbers can't contain a zero denominator. Smart constructors such as Data.Ratio.(%) prevent this, but store allows it.
Data.Ratio.(%)
store
Data.Store.decodeEx "\NUL\001\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\000\NUL\NUL\NUL\NUL\NUL\NUL\NUL" :: Rational 1 % 0 > Data.Store.decodeEx "\NUL\000\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\000\NUL\NUL\NUL\NUL\NUL\NUL\NUL" :: Rational 0 % 0 > Data.Store.decodeEx "\001\NUL\NUL\NUL\000\NUL\NUL\NUL" :: Ratio Int32 1 % 0 > Data.Store.decodeEx "\000\NUL\NUL\NUL\000\NUL\NUL\NUL" :: Ratio Int32 0 % 0
For comparison, other serialization/deserialization libraries take care of preventing a zero denominator (see k0001/safe-money#21)
Other than showing it, there's no much you can do with a Ratio with a zero denominator, since most operations on them fail. For example:
show
Ratio
> 1 + (Data.Store.decodeEx "\000\NUL\NUL\NUL\000\NUL\NUL\NUL" :: Ratio Int32) *** Exception: Ratio has zero denominator
store should always fail to parse Ratios that have a zero denominator.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Rational numbers can't contain a zero denominator. Smart constructors such as
Data.Ratio.(%)
prevent this, butstore
allows it.For comparison, other serialization/deserialization libraries take care of preventing a zero denominator (see k0001/safe-money#21)
Other than
show
ing it, there's no much you can do with aRatio
with a zero denominator, since most operations on them fail. For example:store
should always fail to parseRatio
s that have a zero denominator.The text was updated successfully, but these errors were encountered: