Last active
February 9, 2017 18:15
-
-
Save deque-blog/8a79327cde5c8b123ec4060ce7f22c00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
instance Arbitrary Integer where | |
arbitrary = Gen $ \rand -> fromIntegral $ fst (next rand) | |
shrink n | |
| n == 0 = [] | |
| otherwise = [abs n | n < 0] ++ 0 : rightDichotomy where | |
rightDichotomy = | |
takeWhile | |
(\m -> abs m < abs n) | |
[ n - i | i <- tail (iterate (`quot` 2) n)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment