Skip to content

Commit

Permalink
CoArbitrary and Function for Small
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianAlgehed committed Mar 21, 2024
1 parent cae124f commit 6c4eb24
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Test/QuickCheck/Modifiers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ module Test.QuickCheck.Modifiers
import Test.QuickCheck.Gen
import Test.QuickCheck.Arbitrary
import Test.QuickCheck.Exception
import Test.QuickCheck.Function

import Data.List
( sort
Expand Down Expand Up @@ -384,6 +385,12 @@ instance Integral a => Arbitrary (Small a) where
arbitrary = fmap Small arbitrarySizedIntegral
shrink (Small x) = map Small (shrinkIntegral x)

instance CoArbitrary a => CoArbitrary (Small a) where
coarbitrary (Small a) = coarbitrary a

instance Function a => Function (Small a) where
function = functionMap getSmall Small

--------------------------------------------------------------------------
-- | @Shrink2 x@: allows 2 shrinking steps at the same time when shrinking x
newtype Shrink2 a = Shrink2 {getShrink2 :: a}
Expand Down

0 comments on commit 6c4eb24

Please sign in to comment.