Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active February 9, 2017 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/8a79327cde5c8b123ec4060ce7f22c00 to your computer and use it in GitHub Desktop.
Save deque-blog/8a79327cde5c8b123ec4060ce7f22c00 to your computer and use it in GitHub Desktop.
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