{-# LANGUAGE CPP #-}
#ifndef NO_SAFE_HASKELL
{-# LANGUAGE Safe #-}
#endif
-- | Types to help with testing polymorphic properties.
--
-- Types 'A', 'B' and 'C' are @newtype@ wrappers around 'Integer' that
-- implement 'Eq', 'Show', 'Arbitrary' and 'CoArbitrary'. Types
-- 'OrdA', 'OrdB' and 'OrdC' also implement 'Ord' and 'Num'.
--
-- See also "Test.QuickCheck.All" for an automatic way of testing
-- polymorphic properties.
module Test.QuickCheck.Poly
  ( A(..), B(..), C(..)
  , OrdA(..), OrdB(..), OrdC(..)
  )
 where

--------------------------------------------------------------------------
-- imports

import Test.QuickCheck.Arbitrary

--------------------------------------------------------------------------
-- polymorphic A, B, C (in Eq)

-- A

newtype A = A{ A -> Integer
unA :: Integer }
  deriving ( A -> A -> Bool
(A -> A -> Bool) -> (A -> A -> Bool) -> Eq A
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: A -> A -> Bool
$c/= :: A -> A -> Bool
== :: A -> A -> Bool
$c== :: A -> A -> Bool
Eq )

instance Show A where
  showsPrec :: Int -> A -> ShowS
showsPrec Int
n (A Integer
x) = Int -> Integer -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
n Integer
x

instance Arbitrary A where
  arbitrary :: Gen A
arbitrary    = (Integer -> A
A (Integer -> A) -> (Integer -> Integer) -> Integer -> A
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+Integer
1) (Integer -> Integer) -> (Integer -> Integer) -> Integer -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => a -> a
abs) (Integer -> A) -> Gen Integer -> Gen A
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen Integer
forall a. Arbitrary a => Gen a
arbitrary
  shrink :: A -> [A]
shrink (A Integer
x) = [ Integer -> A
A Integer
x' | Integer
x' <- Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
x, Integer
x' Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
0 ]

instance CoArbitrary A where
  coarbitrary :: A -> Gen b -> Gen b
coarbitrary = Integer -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary (Integer -> Gen b -> Gen b)
-> (A -> Integer) -> A -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. A -> Integer
unA

-- B

newtype B = B{ B -> Integer
unB :: Integer }
  deriving ( B -> B -> Bool
(B -> B -> Bool) -> (B -> B -> Bool) -> Eq B
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: B -> B -> Bool
$c/= :: B -> B -> Bool
== :: B -> B -> Bool
$c== :: B -> B -> Bool
Eq )

instance Show B where
  showsPrec :: Int -> B -> ShowS
showsPrec Int
n (B Integer
x) = Int -> Integer -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
n Integer
x

instance Arbitrary B where
  arbitrary :: Gen B
arbitrary    = (Integer -> B
B (Integer -> B) -> (Integer -> Integer) -> Integer -> B
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+Integer
1) (Integer -> Integer) -> (Integer -> Integer) -> Integer -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => a -> a
abs) (Integer -> B) -> Gen Integer -> Gen B
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen Integer
forall a. Arbitrary a => Gen a
arbitrary
  shrink :: B -> [B]
shrink (B Integer
x) = [ Integer -> B
B Integer
x' | Integer
x' <- Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
x, Integer
x' Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
0 ]

instance CoArbitrary B where
  coarbitrary :: B -> Gen b -> Gen b
coarbitrary = Integer -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary (Integer -> Gen b -> Gen b)
-> (B -> Integer) -> B -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. B -> Integer
unB

-- C

newtype C = C{ C -> Integer
unC :: Integer }
  deriving ( C -> C -> Bool
(C -> C -> Bool) -> (C -> C -> Bool) -> Eq C
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: C -> C -> Bool
$c/= :: C -> C -> Bool
== :: C -> C -> Bool
$c== :: C -> C -> Bool
Eq )

instance Show C where
  showsPrec :: Int -> C -> ShowS
showsPrec Int
n (C Integer
x) = Int -> Integer -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
n Integer
x

instance Arbitrary C where
  arbitrary :: Gen C
arbitrary    = (Integer -> C
C (Integer -> C) -> (Integer -> Integer) -> Integer -> C
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+Integer
1) (Integer -> Integer) -> (Integer -> Integer) -> Integer -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => a -> a
abs) (Integer -> C) -> Gen Integer -> Gen C
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen Integer
forall a. Arbitrary a => Gen a
arbitrary
  shrink :: C -> [C]
shrink (C Integer
x) = [ Integer -> C
C Integer
x' | Integer
x' <- Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
x, Integer
x' Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
0 ]

instance CoArbitrary C where
  coarbitrary :: C -> Gen b -> Gen b
coarbitrary = Integer -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary (Integer -> Gen b -> Gen b)
-> (C -> Integer) -> C -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. C -> Integer
unC

--------------------------------------------------------------------------
-- polymorphic OrdA, OrdB, OrdC (in Eq, Ord)

-- OrdA

newtype OrdA = OrdA{ OrdA -> Integer
unOrdA :: Integer }
  deriving ( OrdA -> OrdA -> Bool
(OrdA -> OrdA -> Bool) -> (OrdA -> OrdA -> Bool) -> Eq OrdA
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OrdA -> OrdA -> Bool
$c/= :: OrdA -> OrdA -> Bool
== :: OrdA -> OrdA -> Bool
$c== :: OrdA -> OrdA -> Bool
Eq, Eq OrdA
Eq OrdA
-> (OrdA -> OrdA -> Ordering)
-> (OrdA -> OrdA -> Bool)
-> (OrdA -> OrdA -> Bool)
-> (OrdA -> OrdA -> Bool)
-> (OrdA -> OrdA -> Bool)
-> (OrdA -> OrdA -> OrdA)
-> (OrdA -> OrdA -> OrdA)
-> Ord OrdA
OrdA -> OrdA -> Bool
OrdA -> OrdA -> Ordering
OrdA -> OrdA -> OrdA
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: OrdA -> OrdA -> OrdA
$cmin :: OrdA -> OrdA -> OrdA
max :: OrdA -> OrdA -> OrdA
$cmax :: OrdA -> OrdA -> OrdA
>= :: OrdA -> OrdA -> Bool
$c>= :: OrdA -> OrdA -> Bool
> :: OrdA -> OrdA -> Bool
$c> :: OrdA -> OrdA -> Bool
<= :: OrdA -> OrdA -> Bool
$c<= :: OrdA -> OrdA -> Bool
< :: OrdA -> OrdA -> Bool
$c< :: OrdA -> OrdA -> Bool
compare :: OrdA -> OrdA -> Ordering
$ccompare :: OrdA -> OrdA -> Ordering
$cp1Ord :: Eq OrdA
Ord )

liftOrdA
    :: (Integer -> Integer)
    -> OrdA -> OrdA
liftOrdA :: (Integer -> Integer) -> OrdA -> OrdA
liftOrdA Integer -> Integer
f (OrdA Integer
x) = Integer -> OrdA
OrdA (Integer -> Integer
f Integer
x)

liftOrdA2
    :: (Integer -> Integer -> Integer)
    -> OrdA -> OrdA -> OrdA
liftOrdA2 :: (Integer -> Integer -> Integer) -> OrdA -> OrdA -> OrdA
liftOrdA2 Integer -> Integer -> Integer
f (OrdA Integer
x) (OrdA Integer
y) = Integer -> OrdA
OrdA (Integer -> Integer -> Integer
f Integer
x Integer
y)

instance Num OrdA where
    + :: OrdA -> OrdA -> OrdA
(+)         = (Integer -> Integer -> Integer) -> OrdA -> OrdA -> OrdA
liftOrdA2 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(+)
    * :: OrdA -> OrdA -> OrdA
(*)         = (Integer -> Integer -> Integer) -> OrdA -> OrdA -> OrdA
liftOrdA2 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(*)
    (-)         = (Integer -> Integer -> Integer) -> OrdA -> OrdA -> OrdA
liftOrdA2 (-)
    negate :: OrdA -> OrdA
negate      = (Integer -> Integer) -> OrdA -> OrdA
liftOrdA Integer -> Integer
forall a. Num a => a -> a
negate
    abs :: OrdA -> OrdA
abs         = (Integer -> Integer) -> OrdA -> OrdA
liftOrdA Integer -> Integer
forall a. Num a => a -> a
abs
    signum :: OrdA -> OrdA
signum      = (Integer -> Integer) -> OrdA -> OrdA
liftOrdA Integer -> Integer
forall a. Num a => a -> a
signum
    fromInteger :: Integer -> OrdA
fromInteger = Integer -> OrdA
OrdA (Integer -> OrdA) -> (Integer -> Integer) -> Integer -> OrdA
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => Integer -> a
fromInteger


instance Show OrdA where
  showsPrec :: Int -> OrdA -> ShowS
showsPrec Int
n (OrdA Integer
x) = Int -> Integer -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
n Integer
x

instance Arbitrary OrdA where
  arbitrary :: Gen OrdA
arbitrary       = (Integer -> OrdA
OrdA (Integer -> OrdA) -> (Integer -> Integer) -> Integer -> OrdA
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+Integer
1) (Integer -> Integer) -> (Integer -> Integer) -> Integer -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => a -> a
abs) (Integer -> OrdA) -> Gen Integer -> Gen OrdA
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen Integer
forall a. Arbitrary a => Gen a
arbitrary
  shrink :: OrdA -> [OrdA]
shrink (OrdA Integer
x) = [ Integer -> OrdA
OrdA Integer
x' | Integer
x' <- Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
x, Integer
x' Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
0 ]

instance CoArbitrary OrdA where
  coarbitrary :: OrdA -> Gen b -> Gen b
coarbitrary = Integer -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary (Integer -> Gen b -> Gen b)
-> (OrdA -> Integer) -> OrdA -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OrdA -> Integer
unOrdA

-- OrdB

newtype OrdB = OrdB{ OrdB -> Integer
unOrdB :: Integer }
  deriving ( OrdB -> OrdB -> Bool
(OrdB -> OrdB -> Bool) -> (OrdB -> OrdB -> Bool) -> Eq OrdB
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OrdB -> OrdB -> Bool
$c/= :: OrdB -> OrdB -> Bool
== :: OrdB -> OrdB -> Bool
$c== :: OrdB -> OrdB -> Bool
Eq, Eq OrdB
Eq OrdB
-> (OrdB -> OrdB -> Ordering)
-> (OrdB -> OrdB -> Bool)
-> (OrdB -> OrdB -> Bool)
-> (OrdB -> OrdB -> Bool)
-> (OrdB -> OrdB -> Bool)
-> (OrdB -> OrdB -> OrdB)
-> (OrdB -> OrdB -> OrdB)
-> Ord OrdB
OrdB -> OrdB -> Bool
OrdB -> OrdB -> Ordering
OrdB -> OrdB -> OrdB
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: OrdB -> OrdB -> OrdB
$cmin :: OrdB -> OrdB -> OrdB
max :: OrdB -> OrdB -> OrdB
$cmax :: OrdB -> OrdB -> OrdB
>= :: OrdB -> OrdB -> Bool
$c>= :: OrdB -> OrdB -> Bool
> :: OrdB -> OrdB -> Bool
$c> :: OrdB -> OrdB -> Bool
<= :: OrdB -> OrdB -> Bool
$c<= :: OrdB -> OrdB -> Bool
< :: OrdB -> OrdB -> Bool
$c< :: OrdB -> OrdB -> Bool
compare :: OrdB -> OrdB -> Ordering
$ccompare :: OrdB -> OrdB -> Ordering
$cp1Ord :: Eq OrdB
Ord )

liftOrdB
    :: (Integer -> Integer)
    -> OrdB -> OrdB
liftOrdB :: (Integer -> Integer) -> OrdB -> OrdB
liftOrdB Integer -> Integer
f (OrdB Integer
x) = Integer -> OrdB
OrdB (Integer -> Integer
f Integer
x)

liftOrdB2
    :: (Integer -> Integer -> Integer)
    -> OrdB -> OrdB -> OrdB
liftOrdB2 :: (Integer -> Integer -> Integer) -> OrdB -> OrdB -> OrdB
liftOrdB2 Integer -> Integer -> Integer
f (OrdB Integer
x) (OrdB Integer
y) = Integer -> OrdB
OrdB (Integer -> Integer -> Integer
f Integer
x Integer
y)

instance Num OrdB where
    + :: OrdB -> OrdB -> OrdB
(+)         = (Integer -> Integer -> Integer) -> OrdB -> OrdB -> OrdB
liftOrdB2 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(+)
    * :: OrdB -> OrdB -> OrdB
(*)         = (Integer -> Integer -> Integer) -> OrdB -> OrdB -> OrdB
liftOrdB2 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(*)
    (-)         = (Integer -> Integer -> Integer) -> OrdB -> OrdB -> OrdB
liftOrdB2 (-)
    negate :: OrdB -> OrdB
negate      = (Integer -> Integer) -> OrdB -> OrdB
liftOrdB Integer -> Integer
forall a. Num a => a -> a
negate
    abs :: OrdB -> OrdB
abs         = (Integer -> Integer) -> OrdB -> OrdB
liftOrdB Integer -> Integer
forall a. Num a => a -> a
abs
    signum :: OrdB -> OrdB
signum      = (Integer -> Integer) -> OrdB -> OrdB
liftOrdB Integer -> Integer
forall a. Num a => a -> a
signum
    fromInteger :: Integer -> OrdB
fromInteger = Integer -> OrdB
OrdB (Integer -> OrdB) -> (Integer -> Integer) -> Integer -> OrdB
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => Integer -> a
fromInteger

instance Show OrdB where
  showsPrec :: Int -> OrdB -> ShowS
showsPrec Int
n (OrdB Integer
x) = Int -> Integer -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
n Integer
x

instance Arbitrary OrdB where
  arbitrary :: Gen OrdB
arbitrary       = (Integer -> OrdB
OrdB (Integer -> OrdB) -> (Integer -> Integer) -> Integer -> OrdB
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+Integer
1) (Integer -> Integer) -> (Integer -> Integer) -> Integer -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => a -> a
abs) (Integer -> OrdB) -> Gen Integer -> Gen OrdB
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen Integer
forall a. Arbitrary a => Gen a
arbitrary
  shrink :: OrdB -> [OrdB]
shrink (OrdB Integer
x) = [ Integer -> OrdB
OrdB Integer
x' | Integer
x' <- Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
x, Integer
x' Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
0 ]

instance CoArbitrary OrdB where
  coarbitrary :: OrdB -> Gen b -> Gen b
coarbitrary = Integer -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary (Integer -> Gen b -> Gen b)
-> (OrdB -> Integer) -> OrdB -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OrdB -> Integer
unOrdB

-- OrdC

newtype OrdC = OrdC{ OrdC -> Integer
unOrdC :: Integer }
  deriving ( OrdC -> OrdC -> Bool
(OrdC -> OrdC -> Bool) -> (OrdC -> OrdC -> Bool) -> Eq OrdC
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OrdC -> OrdC -> Bool
$c/= :: OrdC -> OrdC -> Bool
== :: OrdC -> OrdC -> Bool
$c== :: OrdC -> OrdC -> Bool
Eq, Eq OrdC
Eq OrdC
-> (OrdC -> OrdC -> Ordering)
-> (OrdC -> OrdC -> Bool)
-> (OrdC -> OrdC -> Bool)
-> (OrdC -> OrdC -> Bool)
-> (OrdC -> OrdC -> Bool)
-> (OrdC -> OrdC -> OrdC)
-> (OrdC -> OrdC -> OrdC)
-> Ord OrdC
OrdC -> OrdC -> Bool
OrdC -> OrdC -> Ordering
OrdC -> OrdC -> OrdC
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: OrdC -> OrdC -> OrdC
$cmin :: OrdC -> OrdC -> OrdC
max :: OrdC -> OrdC -> OrdC
$cmax :: OrdC -> OrdC -> OrdC
>= :: OrdC -> OrdC -> Bool
$c>= :: OrdC -> OrdC -> Bool
> :: OrdC -> OrdC -> Bool
$c> :: OrdC -> OrdC -> Bool
<= :: OrdC -> OrdC -> Bool
$c<= :: OrdC -> OrdC -> Bool
< :: OrdC -> OrdC -> Bool
$c< :: OrdC -> OrdC -> Bool
compare :: OrdC -> OrdC -> Ordering
$ccompare :: OrdC -> OrdC -> Ordering
$cp1Ord :: Eq OrdC
Ord )

liftOrdC
    :: (Integer -> Integer)
    -> OrdC -> OrdC
liftOrdC :: (Integer -> Integer) -> OrdC -> OrdC
liftOrdC Integer -> Integer
f (OrdC Integer
x) = Integer -> OrdC
OrdC (Integer -> Integer
f Integer
x)

liftOrdC2
    :: (Integer -> Integer -> Integer)
    -> OrdC -> OrdC -> OrdC
liftOrdC2 :: (Integer -> Integer -> Integer) -> OrdC -> OrdC -> OrdC
liftOrdC2 Integer -> Integer -> Integer
f (OrdC Integer
x) (OrdC Integer
y) = Integer -> OrdC
OrdC (Integer -> Integer -> Integer
f Integer
x Integer
y)

instance Num OrdC where
    + :: OrdC -> OrdC -> OrdC
(+)         = (Integer -> Integer -> Integer) -> OrdC -> OrdC -> OrdC
liftOrdC2 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(+)
    * :: OrdC -> OrdC -> OrdC
(*)         = (Integer -> Integer -> Integer) -> OrdC -> OrdC -> OrdC
liftOrdC2 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(*)
    (-)         = (Integer -> Integer -> Integer) -> OrdC -> OrdC -> OrdC
liftOrdC2 (-)
    negate :: OrdC -> OrdC
negate      = (Integer -> Integer) -> OrdC -> OrdC
liftOrdC Integer -> Integer
forall a. Num a => a -> a
negate
    abs :: OrdC -> OrdC
abs         = (Integer -> Integer) -> OrdC -> OrdC
liftOrdC Integer -> Integer
forall a. Num a => a -> a
abs
    signum :: OrdC -> OrdC
signum      = (Integer -> Integer) -> OrdC -> OrdC
liftOrdC Integer -> Integer
forall a. Num a => a -> a
signum
    fromInteger :: Integer -> OrdC
fromInteger = Integer -> OrdC
OrdC (Integer -> OrdC) -> (Integer -> Integer) -> Integer -> OrdC
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => Integer -> a
fromInteger

instance Show OrdC where
  showsPrec :: Int -> OrdC -> ShowS
showsPrec Int
n (OrdC Integer
x) = Int -> Integer -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
n Integer
x

instance Arbitrary OrdC where
  arbitrary :: Gen OrdC
arbitrary       = (Integer -> OrdC
OrdC (Integer -> OrdC) -> (Integer -> Integer) -> Integer -> OrdC
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+Integer
1) (Integer -> Integer) -> (Integer -> Integer) -> Integer -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => a -> a
abs) (Integer -> OrdC) -> Gen Integer -> Gen OrdC
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen Integer
forall a. Arbitrary a => Gen a
arbitrary
  shrink :: OrdC -> [OrdC]
shrink (OrdC Integer
x) = [ Integer -> OrdC
OrdC Integer
x' | Integer
x' <- Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
x, Integer
x' Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
0 ]

instance CoArbitrary OrdC where
  coarbitrary :: OrdC -> Gen b -> Gen b
coarbitrary = Integer -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary (Integer -> Gen b -> Gen b)
-> (OrdC -> Integer) -> OrdC -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OrdC -> Integer
unOrdC

--------------------------------------------------------------------------
-- the end.