Skip to content

Commit

Permalink
Make Negative's arbitrary instance work like that of Positive
Browse files Browse the repository at this point in the history
  • Loading branch information
Wheatwizard authored and MaximilianAlgehed committed Mar 25, 2024
1 parent 5c973c6 commit 57c7ddd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Test/QuickCheck/Modifiers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ instance Functor Negative where
fmap f (Negative x) = Negative (f x)

instance (Num a, Ord a, Arbitrary a) => Arbitrary (Negative a) where
arbitrary = fmap Negative (arbitrary `suchThat` (< 0))
arbitrary = fmap Negative (fmap (negate . abs) arbitrary `suchThat` (< 0))
shrink (Negative x) = [ Negative x' | x' <- shrink x , x' < 0 ]

--------------------------------------------------------------------------
Expand Down

0 comments on commit 57c7ddd

Please sign in to comment.