You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- | Shrink an integral number.
shrinkIntegral :: Integral a => a -> [a]
shrinkIntegral x =
nub $
[ -x
| x < 0, -x > x
] ++
[ x'
| x' <- takeWhile (<< x) (0:[ x - i | i <- tail (iterate (`quot` 2) x) ])
]
where
-- a << b is "morally" abs a < abs b, but taking care of overflow.
a << b = case (a >= 0, b >= 0) of
(True, True) -> a < b
(False, False) -> a > b
(True, False) -> a + b < 0
(False, True) -> a + b > 0
This definition causes a *** Exception: divide by zero as x 'quot' 2 == x 'quot' 0 because (2 :: BitVector 1) == 0.
The text was updated successfully, but these errors were encountered:
The Arbitrary instance for BitVector is defined using shrinkIntegral, shown below.
This definition causes a
*** Exception: divide by zero
asx 'quot' 2 == x 'quot' 0
because(2 :: BitVector 1) == 0
.The text was updated successfully, but these errors were encountered: