From 6c4eb242007bab41505bae01f39437ffe6b3523e Mon Sep 17 00:00:00 2001 From: Maximilian Algehed Date: Thu, 21 Mar 2024 13:19:09 +0100 Subject: [PATCH] CoArbitrary and Function for `Small` --- src/Test/QuickCheck/Modifiers.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Test/QuickCheck/Modifiers.hs b/src/Test/QuickCheck/Modifiers.hs index 62f71c52..467bcc90 100644 --- a/src/Test/QuickCheck/Modifiers.hs +++ b/src/Test/QuickCheck/Modifiers.hs @@ -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 @@ -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}