-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
[#5] Num laws for Size #32
Conversation
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.
Do you know why your PR is still not approved? Because I chose not to approve it. But they will.
|
||
additionAssotiavity :: Property | ||
additionAssotiavity = hedgehog $ do | ||
x <- forAll genSize |
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.
Suggestion: Reduce duplication
x <- forAll genSize | |
Combine with test/Test/Slist/Size.hs:75:5 |
x <- forAll genSize | ||
|
||
fromInteger 1 * x === x | ||
x * fromInteger 1 === x |
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.
Warning: Redundant fromInteger
x * fromInteger 1 === x | |
x * 1 === x |
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.
This is amazing 😮 😎 Thank you, @chshersh !
(Size x) * (Size y) | ||
| x == 0 || y == 0 = 0 | ||
| otherwise = | ||
let result = x * y in | ||
if x == result `div` y | ||
then Size (x * y) | ||
else Infinity -- multiplication overflow |
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.
🐺 👍
@@ -1 +1 @@ | |||
resolver: nightly-2019-11-08 | |||
resolver: nightly-2020-05-01 |
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.
It's been a while 😸
Part of #5
Checks
Num
instance laws forSize
. I've also added some simple check on integer overflow.