Skip to content

Commit

Permalink
Add arbitrary instances for Down
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianAlgehed committed Mar 21, 2024
1 parent 3479a1a commit f70d4d3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Test/QuickCheck/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ import Control.Monad

import Data.Int(Int8, Int16, Int32, Int64)
import Data.Word(Word, Word8, Word16, Word32, Word64)
import Data.Ord
import System.Exit (ExitCode(..))
import Foreign.C.Types

Expand Down Expand Up @@ -1061,6 +1062,17 @@ instance Arbitrary NewlineMode where
#endif
#endif

#if defined(MIN_VERSION_base)
#if MIN_VERSION_base(4,6,0)
instance Arbitrary1 Down where
liftArbitrary = fmap Down
liftShrink shr = fmap Down . shr . getDown
instance Arbitrary a => Arbitrary (Down a) where
arbitrary = arbitrary1
shrink = shrink1
#endif
#endif

-- ** Helper functions for implementing arbitrary

-- | Apply a binary function to random arguments.
Expand Down

0 comments on commit f70d4d3

Please sign in to comment.