Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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