{-# LANGUAGE CPP #-}
#ifndef NO_SAFE_HASKELL
{-# LANGUAGE Trustworthy #-}
#endif
#ifndef NO_MULTI_PARAM_TYPE_CLASSES
{-# LANGUAGE MultiParamTypeClasses #-}
#endif
#ifndef NO_NEWTYPE_DERIVING
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
#endif
#ifndef NO_TYPEABLE
{-# LANGUAGE DeriveDataTypeable #-}
#endif
-- | Modifiers for test data.
--
-- These types do things such as restricting the kind of test data that can be generated.
-- They can be pattern-matched on in properties as a stylistic
-- alternative to using explicit quantification.
--
-- __Note__: the contents of this module are re-exported by
-- "Test.QuickCheck". You do not need to import it directly.
--
-- Examples:
--
-- @
-- -- Functions cannot be shown (but see "Test.QuickCheck.Function")
-- prop_TakeDropWhile ('Blind' p) (xs :: ['A']) =
--   takeWhile p xs ++ dropWhile p xs == xs
-- @
--
-- @
-- prop_TakeDrop ('NonNegative' n) (xs :: ['A']) =
--   take n xs ++ drop n xs == xs
-- @
--
-- @
-- -- cycle does not work for empty lists
-- prop_Cycle ('NonNegative' n) ('NonEmpty' (xs :: ['A'])) =
--   take n (cycle xs) == take n (xs ++ cycle xs)
-- @
--
-- @
-- -- Instead of 'forAll' 'orderedList'
-- prop_Sort ('Ordered' (xs :: ['OrdA'])) =
--   sort xs == xs
-- @
module Test.QuickCheck.Modifiers
  (
  -- ** Type-level modifiers for changing generator behavior
    Blind(..)
  , Fixed(..)
  , OrderedList(..)
  , NonEmptyList(..)
  , InfiniteList(..)
  , SortedList(..)
  , Positive(..)
  , Negative(..)
  , NonZero(..)
  , NonNegative(..)
  , NonPositive(..)
  , Large(..)
  , Small(..)
  , Smart(..)
  , Shrink2(..)
#ifndef NO_MULTI_PARAM_TYPE_CLASSES
  , Shrinking(..)
  , ShrinkState(..)
#endif
  , ASCIIString(..)
  , UnicodeString(..)
  , PrintableString(..)
  )
 where

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

import Test.QuickCheck.Gen
import Test.QuickCheck.Arbitrary
import Test.QuickCheck.Exception

import Data.List
  ( sort
  )
import Data.Ix (Ix)

#ifndef NO_TYPEABLE
import Data.Typeable (Typeable)
#endif

--------------------------------------------------------------------------
-- | @Blind x@: as x, but x does not have to be in the 'Show' class.
newtype Blind a = Blind {forall a. Blind a -> a
getBlind :: a}
 deriving ( Blind a -> Blind a -> Bool
forall a. Eq a => Blind a -> Blind a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Blind a -> Blind a -> Bool
$c/= :: forall a. Eq a => Blind a -> Blind a -> Bool
== :: Blind a -> Blind a -> Bool
$c== :: forall a. Eq a => Blind a -> Blind a -> Bool
Eq, Blind a -> Blind a -> Bool
Blind a -> Blind a -> Ordering
Blind a -> Blind a -> Blind a
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
forall {a}. Ord a => Eq (Blind a)
forall a. Ord a => Blind a -> Blind a -> Bool
forall a. Ord a => Blind a -> Blind a -> Ordering
forall a. Ord a => Blind a -> Blind a -> Blind a
min :: Blind a -> Blind a -> Blind a
$cmin :: forall a. Ord a => Blind a -> Blind a -> Blind a
max :: Blind a -> Blind a -> Blind a
$cmax :: forall a. Ord a => Blind a -> Blind a -> Blind a
>= :: Blind a -> Blind a -> Bool
$c>= :: forall a. Ord a => Blind a -> Blind a -> Bool
> :: Blind a -> Blind a -> Bool
$c> :: forall a. Ord a => Blind a -> Blind a -> Bool
<= :: Blind a -> Blind a -> Bool
$c<= :: forall a. Ord a => Blind a -> Blind a -> Bool
< :: Blind a -> Blind a -> Bool
$c< :: forall a. Ord a => Blind a -> Blind a -> Bool
compare :: Blind a -> Blind a -> Ordering
$ccompare :: forall a. Ord a => Blind a -> Blind a -> Ordering
Ord
#ifndef NO_NEWTYPE_DERIVING
          , Integer -> Blind a
Blind a -> Blind a
Blind a -> Blind a -> Blind a
forall a. Num a => Integer -> Blind a
forall a. Num a => Blind a -> Blind a
forall a. Num a => Blind a -> Blind a -> Blind a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Blind a
$cfromInteger :: forall a. Num a => Integer -> Blind a
signum :: Blind a -> Blind a
$csignum :: forall a. Num a => Blind a -> Blind a
abs :: Blind a -> Blind a
$cabs :: forall a. Num a => Blind a -> Blind a
negate :: Blind a -> Blind a
$cnegate :: forall a. Num a => Blind a -> Blind a
* :: Blind a -> Blind a -> Blind a
$c* :: forall a. Num a => Blind a -> Blind a -> Blind a
- :: Blind a -> Blind a -> Blind a
$c- :: forall a. Num a => Blind a -> Blind a -> Blind a
+ :: Blind a -> Blind a -> Blind a
$c+ :: forall a. Num a => Blind a -> Blind a -> Blind a
Num, Blind a -> Integer
Blind a -> Blind a -> (Blind a, Blind a)
Blind a -> Blind a -> Blind a
forall {a}. Integral a => Enum (Blind a)
forall {a}. Integral a => Real (Blind a)
forall a. Integral a => Blind a -> Integer
forall a. Integral a => Blind a -> Blind a -> (Blind a, Blind a)
forall a. Integral a => Blind a -> Blind a -> Blind a
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: Blind a -> Integer
$ctoInteger :: forall a. Integral a => Blind a -> Integer
divMod :: Blind a -> Blind a -> (Blind a, Blind a)
$cdivMod :: forall a. Integral a => Blind a -> Blind a -> (Blind a, Blind a)
quotRem :: Blind a -> Blind a -> (Blind a, Blind a)
$cquotRem :: forall a. Integral a => Blind a -> Blind a -> (Blind a, Blind a)
mod :: Blind a -> Blind a -> Blind a
$cmod :: forall a. Integral a => Blind a -> Blind a -> Blind a
div :: Blind a -> Blind a -> Blind a
$cdiv :: forall a. Integral a => Blind a -> Blind a -> Blind a
rem :: Blind a -> Blind a -> Blind a
$crem :: forall a. Integral a => Blind a -> Blind a -> Blind a
quot :: Blind a -> Blind a -> Blind a
$cquot :: forall a. Integral a => Blind a -> Blind a -> Blind a
Integral, Blind a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall {a}. Real a => Num (Blind a)
forall {a}. Real a => Ord (Blind a)
forall a. Real a => Blind a -> Rational
toRational :: Blind a -> Rational
$ctoRational :: forall a. Real a => Blind a -> Rational
Real, Int -> Blind a
Blind a -> Int
Blind a -> [Blind a]
Blind a -> Blind a
Blind a -> Blind a -> [Blind a]
Blind a -> Blind a -> Blind a -> [Blind a]
forall a. Enum a => Int -> Blind a
forall a. Enum a => Blind a -> Int
forall a. Enum a => Blind a -> [Blind a]
forall a. Enum a => Blind a -> Blind a
forall a. Enum a => Blind a -> Blind a -> [Blind a]
forall a. Enum a => Blind a -> Blind a -> Blind a -> [Blind a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Blind a -> Blind a -> Blind a -> [Blind a]
$cenumFromThenTo :: forall a. Enum a => Blind a -> Blind a -> Blind a -> [Blind a]
enumFromTo :: Blind a -> Blind a -> [Blind a]
$cenumFromTo :: forall a. Enum a => Blind a -> Blind a -> [Blind a]
enumFromThen :: Blind a -> Blind a -> [Blind a]
$cenumFromThen :: forall a. Enum a => Blind a -> Blind a -> [Blind a]
enumFrom :: Blind a -> [Blind a]
$cenumFrom :: forall a. Enum a => Blind a -> [Blind a]
fromEnum :: Blind a -> Int
$cfromEnum :: forall a. Enum a => Blind a -> Int
toEnum :: Int -> Blind a
$ctoEnum :: forall a. Enum a => Int -> Blind a
pred :: Blind a -> Blind a
$cpred :: forall a. Enum a => Blind a -> Blind a
succ :: Blind a -> Blind a
$csucc :: forall a. Enum a => Blind a -> Blind a
Enum
#endif
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor Blind where
  fmap :: forall a b. (a -> b) -> Blind a -> Blind b
fmap a -> b
f (Blind a
x) = forall a. a -> Blind a
Blind (a -> b
f a
x)

instance Show (Blind a) where
  show :: Blind a -> String
show Blind a
_ = String
"(*)"

instance Arbitrary a => Arbitrary (Blind a) where
  arbitrary :: Gen (Blind a)
arbitrary = forall a. a -> Blind a
Blind forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Arbitrary a => Gen a
arbitrary

  shrink :: Blind a -> [Blind a]
shrink (Blind a
x) = [ forall a. a -> Blind a
Blind a
x' | a
x' <- forall a. Arbitrary a => a -> [a]
shrink a
x ]

--------------------------------------------------------------------------
-- | @Fixed x@: as x, but will not be shrunk.
newtype Fixed a = Fixed {forall a. Fixed a -> a
getFixed :: a}
 deriving ( Fixed a -> Fixed a -> Bool
forall a. Eq a => Fixed a -> Fixed a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Fixed a -> Fixed a -> Bool
$c/= :: forall a. Eq a => Fixed a -> Fixed a -> Bool
== :: Fixed a -> Fixed a -> Bool
$c== :: forall a. Eq a => Fixed a -> Fixed a -> Bool
Eq, Fixed a -> Fixed a -> Bool
Fixed a -> Fixed a -> Ordering
Fixed a -> Fixed a -> Fixed a
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
forall {a}. Ord a => Eq (Fixed a)
forall a. Ord a => Fixed a -> Fixed a -> Bool
forall a. Ord a => Fixed a -> Fixed a -> Ordering
forall a. Ord a => Fixed a -> Fixed a -> Fixed a
min :: Fixed a -> Fixed a -> Fixed a
$cmin :: forall a. Ord a => Fixed a -> Fixed a -> Fixed a
max :: Fixed a -> Fixed a -> Fixed a
$cmax :: forall a. Ord a => Fixed a -> Fixed a -> Fixed a
>= :: Fixed a -> Fixed a -> Bool
$c>= :: forall a. Ord a => Fixed a -> Fixed a -> Bool
> :: Fixed a -> Fixed a -> Bool
$c> :: forall a. Ord a => Fixed a -> Fixed a -> Bool
<= :: Fixed a -> Fixed a -> Bool
$c<= :: forall a. Ord a => Fixed a -> Fixed a -> Bool
< :: Fixed a -> Fixed a -> Bool
$c< :: forall a. Ord a => Fixed a -> Fixed a -> Bool
compare :: Fixed a -> Fixed a -> Ordering
$ccompare :: forall a. Ord a => Fixed a -> Fixed a -> Ordering
Ord, Int -> Fixed a -> ShowS
forall a. Show a => Int -> Fixed a -> ShowS
forall a. Show a => [Fixed a] -> ShowS
forall a. Show a => Fixed a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Fixed a] -> ShowS
$cshowList :: forall a. Show a => [Fixed a] -> ShowS
show :: Fixed a -> String
$cshow :: forall a. Show a => Fixed a -> String
showsPrec :: Int -> Fixed a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Fixed a -> ShowS
Show, ReadPrec [Fixed a]
ReadPrec (Fixed a)
ReadS [Fixed a]
forall a. Read a => ReadPrec [Fixed a]
forall a. Read a => ReadPrec (Fixed a)
forall a. Read a => Int -> ReadS (Fixed a)
forall a. Read a => ReadS [Fixed a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Fixed a]
$creadListPrec :: forall a. Read a => ReadPrec [Fixed a]
readPrec :: ReadPrec (Fixed a)
$creadPrec :: forall a. Read a => ReadPrec (Fixed a)
readList :: ReadS [Fixed a]
$creadList :: forall a. Read a => ReadS [Fixed a]
readsPrec :: Int -> ReadS (Fixed a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Fixed a)
Read
#ifndef NO_NEWTYPE_DERIVING
          , Integer -> Fixed a
Fixed a -> Fixed a
Fixed a -> Fixed a -> Fixed a
forall a. Num a => Integer -> Fixed a
forall a. Num a => Fixed a -> Fixed a
forall a. Num a => Fixed a -> Fixed a -> Fixed a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Fixed a
$cfromInteger :: forall a. Num a => Integer -> Fixed a
signum :: Fixed a -> Fixed a
$csignum :: forall a. Num a => Fixed a -> Fixed a
abs :: Fixed a -> Fixed a
$cabs :: forall a. Num a => Fixed a -> Fixed a
negate :: Fixed a -> Fixed a
$cnegate :: forall a. Num a => Fixed a -> Fixed a
* :: Fixed a -> Fixed a -> Fixed a
$c* :: forall a. Num a => Fixed a -> Fixed a -> Fixed a
- :: Fixed a -> Fixed a -> Fixed a
$c- :: forall a. Num a => Fixed a -> Fixed a -> Fixed a
+ :: Fixed a -> Fixed a -> Fixed a
$c+ :: forall a. Num a => Fixed a -> Fixed a -> Fixed a
Num, Fixed a -> Integer
Fixed a -> Fixed a -> (Fixed a, Fixed a)
Fixed a -> Fixed a -> Fixed a
forall {a}. Integral a => Enum (Fixed a)
forall {a}. Integral a => Real (Fixed a)
forall a. Integral a => Fixed a -> Integer
forall a. Integral a => Fixed a -> Fixed a -> (Fixed a, Fixed a)
forall a. Integral a => Fixed a -> Fixed a -> Fixed a
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: Fixed a -> Integer
$ctoInteger :: forall a. Integral a => Fixed a -> Integer
divMod :: Fixed a -> Fixed a -> (Fixed a, Fixed a)
$cdivMod :: forall a. Integral a => Fixed a -> Fixed a -> (Fixed a, Fixed a)
quotRem :: Fixed a -> Fixed a -> (Fixed a, Fixed a)
$cquotRem :: forall a. Integral a => Fixed a -> Fixed a -> (Fixed a, Fixed a)
mod :: Fixed a -> Fixed a -> Fixed a
$cmod :: forall a. Integral a => Fixed a -> Fixed a -> Fixed a
div :: Fixed a -> Fixed a -> Fixed a
$cdiv :: forall a. Integral a => Fixed a -> Fixed a -> Fixed a
rem :: Fixed a -> Fixed a -> Fixed a
$crem :: forall a. Integral a => Fixed a -> Fixed a -> Fixed a
quot :: Fixed a -> Fixed a -> Fixed a
$cquot :: forall a. Integral a => Fixed a -> Fixed a -> Fixed a
Integral, Fixed a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall {a}. Real a => Num (Fixed a)
forall {a}. Real a => Ord (Fixed a)
forall a. Real a => Fixed a -> Rational
toRational :: Fixed a -> Rational
$ctoRational :: forall a. Real a => Fixed a -> Rational
Real, Int -> Fixed a
Fixed a -> Int
Fixed a -> [Fixed a]
Fixed a -> Fixed a
Fixed a -> Fixed a -> [Fixed a]
Fixed a -> Fixed a -> Fixed a -> [Fixed a]
forall a. Enum a => Int -> Fixed a
forall a. Enum a => Fixed a -> Int
forall a. Enum a => Fixed a -> [Fixed a]
forall a. Enum a => Fixed a -> Fixed a
forall a. Enum a => Fixed a -> Fixed a -> [Fixed a]
forall a. Enum a => Fixed a -> Fixed a -> Fixed a -> [Fixed a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Fixed a -> Fixed a -> Fixed a -> [Fixed a]
$cenumFromThenTo :: forall a. Enum a => Fixed a -> Fixed a -> Fixed a -> [Fixed a]
enumFromTo :: Fixed a -> Fixed a -> [Fixed a]
$cenumFromTo :: forall a. Enum a => Fixed a -> Fixed a -> [Fixed a]
enumFromThen :: Fixed a -> Fixed a -> [Fixed a]
$cenumFromThen :: forall a. Enum a => Fixed a -> Fixed a -> [Fixed a]
enumFrom :: Fixed a -> [Fixed a]
$cenumFrom :: forall a. Enum a => Fixed a -> [Fixed a]
fromEnum :: Fixed a -> Int
$cfromEnum :: forall a. Enum a => Fixed a -> Int
toEnum :: Int -> Fixed a
$ctoEnum :: forall a. Enum a => Int -> Fixed a
pred :: Fixed a -> Fixed a
$cpred :: forall a. Enum a => Fixed a -> Fixed a
succ :: Fixed a -> Fixed a
$csucc :: forall a. Enum a => Fixed a -> Fixed a
Enum
#endif
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor Fixed where
  fmap :: forall a b. (a -> b) -> Fixed a -> Fixed b
fmap a -> b
f (Fixed a
x) = forall a. a -> Fixed a
Fixed (a -> b
f a
x)

instance Arbitrary a => Arbitrary (Fixed a) where
  arbitrary :: Gen (Fixed a)
arbitrary = forall a. a -> Fixed a
Fixed forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Arbitrary a => Gen a
arbitrary

  -- no shrink function

--------------------------------------------------------------------------
-- | @Ordered xs@: guarantees that xs is ordered.
newtype OrderedList a = Ordered {forall a. OrderedList a -> [a]
getOrdered :: [a]}
 deriving ( OrderedList a -> OrderedList a -> Bool
forall a. Eq a => OrderedList a -> OrderedList a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OrderedList a -> OrderedList a -> Bool
$c/= :: forall a. Eq a => OrderedList a -> OrderedList a -> Bool
== :: OrderedList a -> OrderedList a -> Bool
$c== :: forall a. Eq a => OrderedList a -> OrderedList a -> Bool
Eq, OrderedList a -> OrderedList a -> Bool
OrderedList a -> OrderedList a -> Ordering
OrderedList a -> OrderedList a -> OrderedList a
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
forall {a}. Ord a => Eq (OrderedList a)
forall a. Ord a => OrderedList a -> OrderedList a -> Bool
forall a. Ord a => OrderedList a -> OrderedList a -> Ordering
forall a. Ord a => OrderedList a -> OrderedList a -> OrderedList a
min :: OrderedList a -> OrderedList a -> OrderedList a
$cmin :: forall a. Ord a => OrderedList a -> OrderedList a -> OrderedList a
max :: OrderedList a -> OrderedList a -> OrderedList a
$cmax :: forall a. Ord a => OrderedList a -> OrderedList a -> OrderedList a
>= :: OrderedList a -> OrderedList a -> Bool
$c>= :: forall a. Ord a => OrderedList a -> OrderedList a -> Bool
> :: OrderedList a -> OrderedList a -> Bool
$c> :: forall a. Ord a => OrderedList a -> OrderedList a -> Bool
<= :: OrderedList a -> OrderedList a -> Bool
$c<= :: forall a. Ord a => OrderedList a -> OrderedList a -> Bool
< :: OrderedList a -> OrderedList a -> Bool
$c< :: forall a. Ord a => OrderedList a -> OrderedList a -> Bool
compare :: OrderedList a -> OrderedList a -> Ordering
$ccompare :: forall a. Ord a => OrderedList a -> OrderedList a -> Ordering
Ord, Int -> OrderedList a -> ShowS
forall a. Show a => Int -> OrderedList a -> ShowS
forall a. Show a => [OrderedList a] -> ShowS
forall a. Show a => OrderedList a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OrderedList a] -> ShowS
$cshowList :: forall a. Show a => [OrderedList a] -> ShowS
show :: OrderedList a -> String
$cshow :: forall a. Show a => OrderedList a -> String
showsPrec :: Int -> OrderedList a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> OrderedList a -> ShowS
Show, ReadPrec [OrderedList a]
ReadPrec (OrderedList a)
ReadS [OrderedList a]
forall a. Read a => ReadPrec [OrderedList a]
forall a. Read a => ReadPrec (OrderedList a)
forall a. Read a => Int -> ReadS (OrderedList a)
forall a. Read a => ReadS [OrderedList a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OrderedList a]
$creadListPrec :: forall a. Read a => ReadPrec [OrderedList a]
readPrec :: ReadPrec (OrderedList a)
$creadPrec :: forall a. Read a => ReadPrec (OrderedList a)
readList :: ReadS [OrderedList a]
$creadList :: forall a. Read a => ReadS [OrderedList a]
readsPrec :: Int -> ReadS (OrderedList a)
$creadsPrec :: forall a. Read a => Int -> ReadS (OrderedList a)
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor OrderedList where
  fmap :: forall a b. (a -> b) -> OrderedList a -> OrderedList b
fmap a -> b
f (Ordered [a]
x) = forall a. [a] -> OrderedList a
Ordered (forall a b. (a -> b) -> [a] -> [b]
map a -> b
f [a]
x)

instance (Ord a, Arbitrary a) => Arbitrary (OrderedList a) where
  arbitrary :: Gen (OrderedList a)
arbitrary = forall a. [a] -> OrderedList a
Ordered forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. (Ord a, Arbitrary a) => Gen [a]
orderedList

  shrink :: OrderedList a -> [OrderedList a]
shrink (Ordered [a]
xs) =
    [ forall a. [a] -> OrderedList a
Ordered [a]
xs'
    | [a]
xs' <- forall a. Arbitrary a => a -> [a]
shrink [a]
xs
    , forall a. Ord a => [a] -> [a]
sort [a]
xs' forall a. Eq a => a -> a -> Bool
== [a]
xs'
    ]

--------------------------------------------------------------------------
-- | @NonEmpty xs@: guarantees that xs is non-empty.
newtype NonEmptyList a = NonEmpty {forall a. NonEmptyList a -> [a]
getNonEmpty :: [a]}
 deriving ( NonEmptyList a -> NonEmptyList a -> Bool
forall a. Eq a => NonEmptyList a -> NonEmptyList a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NonEmptyList a -> NonEmptyList a -> Bool
$c/= :: forall a. Eq a => NonEmptyList a -> NonEmptyList a -> Bool
== :: NonEmptyList a -> NonEmptyList a -> Bool
$c== :: forall a. Eq a => NonEmptyList a -> NonEmptyList a -> Bool
Eq, NonEmptyList a -> NonEmptyList a -> Bool
NonEmptyList a -> NonEmptyList a -> Ordering
NonEmptyList a -> NonEmptyList a -> NonEmptyList a
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
forall {a}. Ord a => Eq (NonEmptyList a)
forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Bool
forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Ordering
forall a.
Ord a =>
NonEmptyList a -> NonEmptyList a -> NonEmptyList a
min :: NonEmptyList a -> NonEmptyList a -> NonEmptyList a
$cmin :: forall a.
Ord a =>
NonEmptyList a -> NonEmptyList a -> NonEmptyList a
max :: NonEmptyList a -> NonEmptyList a -> NonEmptyList a
$cmax :: forall a.
Ord a =>
NonEmptyList a -> NonEmptyList a -> NonEmptyList a
>= :: NonEmptyList a -> NonEmptyList a -> Bool
$c>= :: forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Bool
> :: NonEmptyList a -> NonEmptyList a -> Bool
$c> :: forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Bool
<= :: NonEmptyList a -> NonEmptyList a -> Bool
$c<= :: forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Bool
< :: NonEmptyList a -> NonEmptyList a -> Bool
$c< :: forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Bool
compare :: NonEmptyList a -> NonEmptyList a -> Ordering
$ccompare :: forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Ordering
Ord, Int -> NonEmptyList a -> ShowS
forall a. Show a => Int -> NonEmptyList a -> ShowS
forall a. Show a => [NonEmptyList a] -> ShowS
forall a. Show a => NonEmptyList a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NonEmptyList a] -> ShowS
$cshowList :: forall a. Show a => [NonEmptyList a] -> ShowS
show :: NonEmptyList a -> String
$cshow :: forall a. Show a => NonEmptyList a -> String
showsPrec :: Int -> NonEmptyList a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> NonEmptyList a -> ShowS
Show, ReadPrec [NonEmptyList a]
ReadPrec (NonEmptyList a)
ReadS [NonEmptyList a]
forall a. Read a => ReadPrec [NonEmptyList a]
forall a. Read a => ReadPrec (NonEmptyList a)
forall a. Read a => Int -> ReadS (NonEmptyList a)
forall a. Read a => ReadS [NonEmptyList a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NonEmptyList a]
$creadListPrec :: forall a. Read a => ReadPrec [NonEmptyList a]
readPrec :: ReadPrec (NonEmptyList a)
$creadPrec :: forall a. Read a => ReadPrec (NonEmptyList a)
readList :: ReadS [NonEmptyList a]
$creadList :: forall a. Read a => ReadS [NonEmptyList a]
readsPrec :: Int -> ReadS (NonEmptyList a)
$creadsPrec :: forall a. Read a => Int -> ReadS (NonEmptyList a)
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor NonEmptyList where
  fmap :: forall a b. (a -> b) -> NonEmptyList a -> NonEmptyList b
fmap a -> b
f (NonEmpty [a]
x) = forall a. [a] -> NonEmptyList a
NonEmpty (forall a b. (a -> b) -> [a] -> [b]
map a -> b
f [a]
x)

instance Arbitrary a => Arbitrary (NonEmptyList a) where
  arbitrary :: Gen (NonEmptyList a)
arbitrary = forall a. [a] -> NonEmptyList a
NonEmpty forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` (forall a. Arbitrary a => Gen a
arbitrary forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> Bool
null))

  shrink :: NonEmptyList a -> [NonEmptyList a]
shrink (NonEmpty [a]
xs) =
    [ forall a. [a] -> NonEmptyList a
NonEmpty [a]
xs'
    | [a]
xs' <- forall a. Arbitrary a => a -> [a]
shrink [a]
xs
    , Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
xs')
    ]

----------------------------------------------------------------------
-- | @InfiniteList xs _@: guarantees that xs is an infinite list.
-- When a counterexample is found, only prints the prefix of xs
-- that was used by the program.
--
-- Here is a contrived example property:
--
-- > prop_take_10 :: InfiniteList Char -> Bool
-- > prop_take_10 (InfiniteList xs _) =
-- >   or [ x == 'a' | x <- take 10 xs ]
--
-- In the following counterexample, the list must start with @"bbbbbbbbbb"@ but
-- the remaining (infinite) part can contain anything:
--
-- >>> quickCheck prop_take_10
-- *** Failed! Falsified (after 1 test and 14 shrinks):
-- "bbbbbbbbbb" ++ ...
data InfiniteList a =
  InfiniteList {
    forall a. InfiniteList a -> [a]
getInfiniteList :: [a],
    forall a. InfiniteList a -> InfiniteListInternalData a
infiniteListInternalData :: InfiniteListInternalData a }

-- Uses a similar trick to Test.QuickCheck.Function:
-- the Arbitrary instance generates an infinite list, which is
-- reduced to a finite prefix by shrinking. We use discard to
-- check that nothing coming after the finite prefix is used
-- (see infiniteListFromData).
data InfiniteListInternalData a = Infinite [a] | FinitePrefix [a]

infiniteListFromData :: InfiniteListInternalData a -> InfiniteList a
infiniteListFromData :: forall a. InfiniteListInternalData a -> InfiniteList a
infiniteListFromData info :: InfiniteListInternalData a
info@(Infinite [a]
xs) = forall a. [a] -> InfiniteListInternalData a -> InfiniteList a
InfiniteList [a]
xs InfiniteListInternalData a
info
infiniteListFromData info :: InfiniteListInternalData a
info@(FinitePrefix [a]
xs) =
  forall a. [a] -> InfiniteListInternalData a -> InfiniteList a
InfiniteList ([a]
xs forall a. [a] -> [a] -> [a]
++ forall a. a
discard) InfiniteListInternalData a
info

instance Show a => Show (InfiniteList a) where
  showsPrec :: Int -> InfiniteList a -> ShowS
showsPrec Int
_ (InfiniteList [a]
_ (Infinite [a]
_)) =
    (String
"<infinite list>" forall a. [a] -> [a] -> [a]
++)
  showsPrec Int
n (InfiniteList [a]
_ (FinitePrefix [a]
xs)) =
    (if Int
n forall a. Ord a => a -> a -> Bool
> Int
10 then (Char
'('forall a. a -> [a] -> [a]
:) else forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
.
    forall a. Show a => Int -> a -> ShowS
showsPrec Int
0 [a]
xs forall b c a. (b -> c) -> (a -> b) -> a -> c
.
    (String
" ++ ..." forall a. [a] -> [a] -> [a]
++) forall b c a. (b -> c) -> (a -> b) -> a -> c
.
    (if Int
n forall a. Ord a => a -> a -> Bool
> Int
10 then (Char
')'forall a. a -> [a] -> [a]
:) else forall a. a -> a
id)

instance Arbitrary a => Arbitrary (InfiniteList a) where
  arbitrary :: Gen (InfiniteList a)
arbitrary = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. InfiniteListInternalData a -> InfiniteList a
infiniteListFromData forall a. Arbitrary a => Gen a
arbitrary
  shrink :: InfiniteList a -> [InfiniteList a]
shrink (InfiniteList [a]
_ InfiniteListInternalData a
info) =
    forall a b. (a -> b) -> [a] -> [b]
map forall a. InfiniteListInternalData a -> InfiniteList a
infiniteListFromData (forall a. Arbitrary a => a -> [a]
shrink InfiniteListInternalData a
info)

instance Arbitrary a => Arbitrary (InfiniteListInternalData a) where
  arbitrary :: Gen (InfiniteListInternalData a)
arbitrary = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. [a] -> InfiniteListInternalData a
Infinite forall a. Arbitrary a => Gen [a]
infiniteList
  shrink :: InfiniteListInternalData a -> [InfiniteListInternalData a]
shrink (Infinite [a]
xs) =
    [forall a. [a] -> InfiniteListInternalData a
FinitePrefix (forall a. Int -> [a] -> [a]
take Int
n [a]
xs) | Int
n <- forall a b. (a -> b) -> [a] -> [b]
map (Int
2forall a b. (Num a, Integral b) => a -> b -> a
^) [Integer
0..]]
  shrink (FinitePrefix [a]
xs) =
    forall a b. (a -> b) -> [a] -> [b]
map forall a. [a] -> InfiniteListInternalData a
FinitePrefix (forall a. Arbitrary a => a -> [a]
shrink [a]
xs)

--------------------------------------------------------------------------
-- | @Sorted xs@: guarantees that xs is sorted.
newtype SortedList a = Sorted {forall a. SortedList a -> [a]
getSorted :: [a]}
 deriving ( SortedList a -> SortedList a -> Bool
forall a. Eq a => SortedList a -> SortedList a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SortedList a -> SortedList a -> Bool
$c/= :: forall a. Eq a => SortedList a -> SortedList a -> Bool
== :: SortedList a -> SortedList a -> Bool
$c== :: forall a. Eq a => SortedList a -> SortedList a -> Bool
Eq, SortedList a -> SortedList a -> Bool
SortedList a -> SortedList a -> Ordering
SortedList a -> SortedList a -> SortedList a
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
forall {a}. Ord a => Eq (SortedList a)
forall a. Ord a => SortedList a -> SortedList a -> Bool
forall a. Ord a => SortedList a -> SortedList a -> Ordering
forall a. Ord a => SortedList a -> SortedList a -> SortedList a
min :: SortedList a -> SortedList a -> SortedList a
$cmin :: forall a. Ord a => SortedList a -> SortedList a -> SortedList a
max :: SortedList a -> SortedList a -> SortedList a
$cmax :: forall a. Ord a => SortedList a -> SortedList a -> SortedList a
>= :: SortedList a -> SortedList a -> Bool
$c>= :: forall a. Ord a => SortedList a -> SortedList a -> Bool
> :: SortedList a -> SortedList a -> Bool
$c> :: forall a. Ord a => SortedList a -> SortedList a -> Bool
<= :: SortedList a -> SortedList a -> Bool
$c<= :: forall a. Ord a => SortedList a -> SortedList a -> Bool
< :: SortedList a -> SortedList a -> Bool
$c< :: forall a. Ord a => SortedList a -> SortedList a -> Bool
compare :: SortedList a -> SortedList a -> Ordering
$ccompare :: forall a. Ord a => SortedList a -> SortedList a -> Ordering
Ord, Int -> SortedList a -> ShowS
forall a. Show a => Int -> SortedList a -> ShowS
forall a. Show a => [SortedList a] -> ShowS
forall a. Show a => SortedList a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SortedList a] -> ShowS
$cshowList :: forall a. Show a => [SortedList a] -> ShowS
show :: SortedList a -> String
$cshow :: forall a. Show a => SortedList a -> String
showsPrec :: Int -> SortedList a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> SortedList a -> ShowS
Show, ReadPrec [SortedList a]
ReadPrec (SortedList a)
ReadS [SortedList a]
forall a. Read a => ReadPrec [SortedList a]
forall a. Read a => ReadPrec (SortedList a)
forall a. Read a => Int -> ReadS (SortedList a)
forall a. Read a => ReadS [SortedList a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SortedList a]
$creadListPrec :: forall a. Read a => ReadPrec [SortedList a]
readPrec :: ReadPrec (SortedList a)
$creadPrec :: forall a. Read a => ReadPrec (SortedList a)
readList :: ReadS [SortedList a]
$creadList :: forall a. Read a => ReadS [SortedList a]
readsPrec :: Int -> ReadS (SortedList a)
$creadsPrec :: forall a. Read a => Int -> ReadS (SortedList a)
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor SortedList where
  fmap :: forall a b. (a -> b) -> SortedList a -> SortedList b
fmap a -> b
f (Sorted [a]
x) = forall a. [a] -> SortedList a
Sorted (forall a b. (a -> b) -> [a] -> [b]
map a -> b
f [a]
x)

instance (Arbitrary a, Ord a) => Arbitrary (SortedList a) where
  arbitrary :: Gen (SortedList a)
arbitrary = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. [a] -> SortedList a
Sorted forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Ord a => [a] -> [a]
sort) forall a. Arbitrary a => Gen a
arbitrary

  shrink :: SortedList a -> [SortedList a]
shrink (Sorted [a]
xs) =
    [ forall a. [a] -> SortedList a
Sorted [a]
xs'
    | [a]
xs' <- forall a b. (a -> b) -> [a] -> [b]
map forall a. Ord a => [a] -> [a]
sort (forall a. Arbitrary a => a -> [a]
shrink [a]
xs)
    ]

--------------------------------------------------------------------------
-- | @Positive x@: guarantees that @x \> 0@.
newtype Positive a = Positive {forall a. Positive a -> a
getPositive :: a}
 deriving ( Positive a -> Positive a -> Bool
forall a. Eq a => Positive a -> Positive a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Positive a -> Positive a -> Bool
$c/= :: forall a. Eq a => Positive a -> Positive a -> Bool
== :: Positive a -> Positive a -> Bool
$c== :: forall a. Eq a => Positive a -> Positive a -> Bool
Eq, Positive a -> Positive a -> Bool
Positive a -> Positive a -> Ordering
Positive a -> Positive a -> Positive a
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
forall {a}. Ord a => Eq (Positive a)
forall a. Ord a => Positive a -> Positive a -> Bool
forall a. Ord a => Positive a -> Positive a -> Ordering
forall a. Ord a => Positive a -> Positive a -> Positive a
min :: Positive a -> Positive a -> Positive a
$cmin :: forall a. Ord a => Positive a -> Positive a -> Positive a
max :: Positive a -> Positive a -> Positive a
$cmax :: forall a. Ord a => Positive a -> Positive a -> Positive a
>= :: Positive a -> Positive a -> Bool
$c>= :: forall a. Ord a => Positive a -> Positive a -> Bool
> :: Positive a -> Positive a -> Bool
$c> :: forall a. Ord a => Positive a -> Positive a -> Bool
<= :: Positive a -> Positive a -> Bool
$c<= :: forall a. Ord a => Positive a -> Positive a -> Bool
< :: Positive a -> Positive a -> Bool
$c< :: forall a. Ord a => Positive a -> Positive a -> Bool
compare :: Positive a -> Positive a -> Ordering
$ccompare :: forall a. Ord a => Positive a -> Positive a -> Ordering
Ord, Int -> Positive a -> ShowS
forall a. Show a => Int -> Positive a -> ShowS
forall a. Show a => [Positive a] -> ShowS
forall a. Show a => Positive a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Positive a] -> ShowS
$cshowList :: forall a. Show a => [Positive a] -> ShowS
show :: Positive a -> String
$cshow :: forall a. Show a => Positive a -> String
showsPrec :: Int -> Positive a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Positive a -> ShowS
Show, ReadPrec [Positive a]
ReadPrec (Positive a)
ReadS [Positive a]
forall a. Read a => ReadPrec [Positive a]
forall a. Read a => ReadPrec (Positive a)
forall a. Read a => Int -> ReadS (Positive a)
forall a. Read a => ReadS [Positive a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Positive a]
$creadListPrec :: forall a. Read a => ReadPrec [Positive a]
readPrec :: ReadPrec (Positive a)
$creadPrec :: forall a. Read a => ReadPrec (Positive a)
readList :: ReadS [Positive a]
$creadList :: forall a. Read a => ReadS [Positive a]
readsPrec :: Int -> ReadS (Positive a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Positive a)
Read
#ifndef NO_NEWTYPE_DERIVING
          , Int -> Positive a
Positive a -> Int
Positive a -> [Positive a]
Positive a -> Positive a
Positive a -> Positive a -> [Positive a]
Positive a -> Positive a -> Positive a -> [Positive a]
forall a. Enum a => Int -> Positive a
forall a. Enum a => Positive a -> Int
forall a. Enum a => Positive a -> [Positive a]
forall a. Enum a => Positive a -> Positive a
forall a. Enum a => Positive a -> Positive a -> [Positive a]
forall a.
Enum a =>
Positive a -> Positive a -> Positive a -> [Positive a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Positive a -> Positive a -> Positive a -> [Positive a]
$cenumFromThenTo :: forall a.
Enum a =>
Positive a -> Positive a -> Positive a -> [Positive a]
enumFromTo :: Positive a -> Positive a -> [Positive a]
$cenumFromTo :: forall a. Enum a => Positive a -> Positive a -> [Positive a]
enumFromThen :: Positive a -> Positive a -> [Positive a]
$cenumFromThen :: forall a. Enum a => Positive a -> Positive a -> [Positive a]
enumFrom :: Positive a -> [Positive a]
$cenumFrom :: forall a. Enum a => Positive a -> [Positive a]
fromEnum :: Positive a -> Int
$cfromEnum :: forall a. Enum a => Positive a -> Int
toEnum :: Int -> Positive a
$ctoEnum :: forall a. Enum a => Int -> Positive a
pred :: Positive a -> Positive a
$cpred :: forall a. Enum a => Positive a -> Positive a
succ :: Positive a -> Positive a
$csucc :: forall a. Enum a => Positive a -> Positive a
Enum
#endif
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor Positive where
  fmap :: forall a b. (a -> b) -> Positive a -> Positive b
fmap a -> b
f (Positive a
x) = forall a. a -> Positive a
Positive (a -> b
f a
x)

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

--------------------------------------------------------------------------
-- | @Negative x@: guarantees that @x \< 0@.
newtype Negative a = Negative {forall a. Negative a -> a
getNegative :: a}
 deriving ( Negative a -> Negative a -> Bool
forall a. Eq a => Negative a -> Negative a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Negative a -> Negative a -> Bool
$c/= :: forall a. Eq a => Negative a -> Negative a -> Bool
== :: Negative a -> Negative a -> Bool
$c== :: forall a. Eq a => Negative a -> Negative a -> Bool
Eq, Negative a -> Negative a -> Bool
Negative a -> Negative a -> Ordering
Negative a -> Negative a -> Negative a
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
forall {a}. Ord a => Eq (Negative a)
forall a. Ord a => Negative a -> Negative a -> Bool
forall a. Ord a => Negative a -> Negative a -> Ordering
forall a. Ord a => Negative a -> Negative a -> Negative a
min :: Negative a -> Negative a -> Negative a
$cmin :: forall a. Ord a => Negative a -> Negative a -> Negative a
max :: Negative a -> Negative a -> Negative a
$cmax :: forall a. Ord a => Negative a -> Negative a -> Negative a
>= :: Negative a -> Negative a -> Bool
$c>= :: forall a. Ord a => Negative a -> Negative a -> Bool
> :: Negative a -> Negative a -> Bool
$c> :: forall a. Ord a => Negative a -> Negative a -> Bool
<= :: Negative a -> Negative a -> Bool
$c<= :: forall a. Ord a => Negative a -> Negative a -> Bool
< :: Negative a -> Negative a -> Bool
$c< :: forall a. Ord a => Negative a -> Negative a -> Bool
compare :: Negative a -> Negative a -> Ordering
$ccompare :: forall a. Ord a => Negative a -> Negative a -> Ordering
Ord, Int -> Negative a -> ShowS
forall a. Show a => Int -> Negative a -> ShowS
forall a. Show a => [Negative a] -> ShowS
forall a. Show a => Negative a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Negative a] -> ShowS
$cshowList :: forall a. Show a => [Negative a] -> ShowS
show :: Negative a -> String
$cshow :: forall a. Show a => Negative a -> String
showsPrec :: Int -> Negative a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Negative a -> ShowS
Show, ReadPrec [Negative a]
ReadPrec (Negative a)
ReadS [Negative a]
forall a. Read a => ReadPrec [Negative a]
forall a. Read a => ReadPrec (Negative a)
forall a. Read a => Int -> ReadS (Negative a)
forall a. Read a => ReadS [Negative a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Negative a]
$creadListPrec :: forall a. Read a => ReadPrec [Negative a]
readPrec :: ReadPrec (Negative a)
$creadPrec :: forall a. Read a => ReadPrec (Negative a)
readList :: ReadS [Negative a]
$creadList :: forall a. Read a => ReadS [Negative a]
readsPrec :: Int -> ReadS (Negative a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Negative a)
Read
#ifndef NO_NEWTYPE_DERIVING
          , Int -> Negative a
Negative a -> Int
Negative a -> [Negative a]
Negative a -> Negative a
Negative a -> Negative a -> [Negative a]
Negative a -> Negative a -> Negative a -> [Negative a]
forall a. Enum a => Int -> Negative a
forall a. Enum a => Negative a -> Int
forall a. Enum a => Negative a -> [Negative a]
forall a. Enum a => Negative a -> Negative a
forall a. Enum a => Negative a -> Negative a -> [Negative a]
forall a.
Enum a =>
Negative a -> Negative a -> Negative a -> [Negative a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Negative a -> Negative a -> Negative a -> [Negative a]
$cenumFromThenTo :: forall a.
Enum a =>
Negative a -> Negative a -> Negative a -> [Negative a]
enumFromTo :: Negative a -> Negative a -> [Negative a]
$cenumFromTo :: forall a. Enum a => Negative a -> Negative a -> [Negative a]
enumFromThen :: Negative a -> Negative a -> [Negative a]
$cenumFromThen :: forall a. Enum a => Negative a -> Negative a -> [Negative a]
enumFrom :: Negative a -> [Negative a]
$cenumFrom :: forall a. Enum a => Negative a -> [Negative a]
fromEnum :: Negative a -> Int
$cfromEnum :: forall a. Enum a => Negative a -> Int
toEnum :: Int -> Negative a
$ctoEnum :: forall a. Enum a => Int -> Negative a
pred :: Negative a -> Negative a
$cpred :: forall a. Enum a => Negative a -> Negative a
succ :: Negative a -> Negative a
$csucc :: forall a. Enum a => Negative a -> Negative a
Enum
#endif
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor Negative where
  fmap :: forall a b. (a -> b) -> Negative a -> Negative b
fmap a -> b
f (Negative a
x) = forall a. a -> Negative a
Negative (a -> b
f a
x)

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

--------------------------------------------------------------------------
-- | @NonZero x@: guarantees that @x \/= 0@.
newtype NonZero a = NonZero {forall a. NonZero a -> a
getNonZero :: a}
 deriving ( NonZero a -> NonZero a -> Bool
forall a. Eq a => NonZero a -> NonZero a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NonZero a -> NonZero a -> Bool
$c/= :: forall a. Eq a => NonZero a -> NonZero a -> Bool
== :: NonZero a -> NonZero a -> Bool
$c== :: forall a. Eq a => NonZero a -> NonZero a -> Bool
Eq, NonZero a -> NonZero a -> Bool
NonZero a -> NonZero a -> Ordering
NonZero a -> NonZero a -> NonZero a
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
forall {a}. Ord a => Eq (NonZero a)
forall a. Ord a => NonZero a -> NonZero a -> Bool
forall a. Ord a => NonZero a -> NonZero a -> Ordering
forall a. Ord a => NonZero a -> NonZero a -> NonZero a
min :: NonZero a -> NonZero a -> NonZero a
$cmin :: forall a. Ord a => NonZero a -> NonZero a -> NonZero a
max :: NonZero a -> NonZero a -> NonZero a
$cmax :: forall a. Ord a => NonZero a -> NonZero a -> NonZero a
>= :: NonZero a -> NonZero a -> Bool
$c>= :: forall a. Ord a => NonZero a -> NonZero a -> Bool
> :: NonZero a -> NonZero a -> Bool
$c> :: forall a. Ord a => NonZero a -> NonZero a -> Bool
<= :: NonZero a -> NonZero a -> Bool
$c<= :: forall a. Ord a => NonZero a -> NonZero a -> Bool
< :: NonZero a -> NonZero a -> Bool
$c< :: forall a. Ord a => NonZero a -> NonZero a -> Bool
compare :: NonZero a -> NonZero a -> Ordering
$ccompare :: forall a. Ord a => NonZero a -> NonZero a -> Ordering
Ord, Int -> NonZero a -> ShowS
forall a. Show a => Int -> NonZero a -> ShowS
forall a. Show a => [NonZero a] -> ShowS
forall a. Show a => NonZero a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NonZero a] -> ShowS
$cshowList :: forall a. Show a => [NonZero a] -> ShowS
show :: NonZero a -> String
$cshow :: forall a. Show a => NonZero a -> String
showsPrec :: Int -> NonZero a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> NonZero a -> ShowS
Show, ReadPrec [NonZero a]
ReadPrec (NonZero a)
ReadS [NonZero a]
forall a. Read a => ReadPrec [NonZero a]
forall a. Read a => ReadPrec (NonZero a)
forall a. Read a => Int -> ReadS (NonZero a)
forall a. Read a => ReadS [NonZero a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NonZero a]
$creadListPrec :: forall a. Read a => ReadPrec [NonZero a]
readPrec :: ReadPrec (NonZero a)
$creadPrec :: forall a. Read a => ReadPrec (NonZero a)
readList :: ReadS [NonZero a]
$creadList :: forall a. Read a => ReadS [NonZero a]
readsPrec :: Int -> ReadS (NonZero a)
$creadsPrec :: forall a. Read a => Int -> ReadS (NonZero a)
Read
#ifndef NO_NEWTYPE_DERIVING
          , Int -> NonZero a
NonZero a -> Int
NonZero a -> [NonZero a]
NonZero a -> NonZero a
NonZero a -> NonZero a -> [NonZero a]
NonZero a -> NonZero a -> NonZero a -> [NonZero a]
forall a. Enum a => Int -> NonZero a
forall a. Enum a => NonZero a -> Int
forall a. Enum a => NonZero a -> [NonZero a]
forall a. Enum a => NonZero a -> NonZero a
forall a. Enum a => NonZero a -> NonZero a -> [NonZero a]
forall a.
Enum a =>
NonZero a -> NonZero a -> NonZero a -> [NonZero a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: NonZero a -> NonZero a -> NonZero a -> [NonZero a]
$cenumFromThenTo :: forall a.
Enum a =>
NonZero a -> NonZero a -> NonZero a -> [NonZero a]
enumFromTo :: NonZero a -> NonZero a -> [NonZero a]
$cenumFromTo :: forall a. Enum a => NonZero a -> NonZero a -> [NonZero a]
enumFromThen :: NonZero a -> NonZero a -> [NonZero a]
$cenumFromThen :: forall a. Enum a => NonZero a -> NonZero a -> [NonZero a]
enumFrom :: NonZero a -> [NonZero a]
$cenumFrom :: forall a. Enum a => NonZero a -> [NonZero a]
fromEnum :: NonZero a -> Int
$cfromEnum :: forall a. Enum a => NonZero a -> Int
toEnum :: Int -> NonZero a
$ctoEnum :: forall a. Enum a => Int -> NonZero a
pred :: NonZero a -> NonZero a
$cpred :: forall a. Enum a => NonZero a -> NonZero a
succ :: NonZero a -> NonZero a
$csucc :: forall a. Enum a => NonZero a -> NonZero a
Enum
#endif
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor NonZero where
  fmap :: forall a b. (a -> b) -> NonZero a -> NonZero b
fmap a -> b
f (NonZero a
x) = forall a. a -> NonZero a
NonZero (a -> b
f a
x)

instance (Num a, Eq a, Arbitrary a) => Arbitrary (NonZero a) where
  arbitrary :: Gen (NonZero a)
arbitrary = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> NonZero a
NonZero forall a b. (a -> b) -> a -> b
$ forall a. Arbitrary a => Gen a
arbitrary forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (forall a. Eq a => a -> a -> Bool
/= a
0)

  shrink :: NonZero a -> [NonZero a]
shrink (NonZero a
x) = [ forall a. a -> NonZero a
NonZero a
x' | a
x' <- forall a. Arbitrary a => a -> [a]
shrink a
x, a
x' forall a. Eq a => a -> a -> Bool
/= a
0 ]

--------------------------------------------------------------------------
-- | @NonNegative x@: guarantees that @x \>= 0@.
newtype NonNegative a = NonNegative {forall a. NonNegative a -> a
getNonNegative :: a}
 deriving ( NonNegative a -> NonNegative a -> Bool
forall a. Eq a => NonNegative a -> NonNegative a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NonNegative a -> NonNegative a -> Bool
$c/= :: forall a. Eq a => NonNegative a -> NonNegative a -> Bool
== :: NonNegative a -> NonNegative a -> Bool
$c== :: forall a. Eq a => NonNegative a -> NonNegative a -> Bool
Eq, NonNegative a -> NonNegative a -> Bool
NonNegative a -> NonNegative a -> Ordering
NonNegative a -> NonNegative a -> NonNegative a
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
forall {a}. Ord a => Eq (NonNegative a)
forall a. Ord a => NonNegative a -> NonNegative a -> Bool
forall a. Ord a => NonNegative a -> NonNegative a -> Ordering
forall a. Ord a => NonNegative a -> NonNegative a -> NonNegative a
min :: NonNegative a -> NonNegative a -> NonNegative a
$cmin :: forall a. Ord a => NonNegative a -> NonNegative a -> NonNegative a
max :: NonNegative a -> NonNegative a -> NonNegative a
$cmax :: forall a. Ord a => NonNegative a -> NonNegative a -> NonNegative a
>= :: NonNegative a -> NonNegative a -> Bool
$c>= :: forall a. Ord a => NonNegative a -> NonNegative a -> Bool
> :: NonNegative a -> NonNegative a -> Bool
$c> :: forall a. Ord a => NonNegative a -> NonNegative a -> Bool
<= :: NonNegative a -> NonNegative a -> Bool
$c<= :: forall a. Ord a => NonNegative a -> NonNegative a -> Bool
< :: NonNegative a -> NonNegative a -> Bool
$c< :: forall a. Ord a => NonNegative a -> NonNegative a -> Bool
compare :: NonNegative a -> NonNegative a -> Ordering
$ccompare :: forall a. Ord a => NonNegative a -> NonNegative a -> Ordering
Ord, Int -> NonNegative a -> ShowS
forall a. Show a => Int -> NonNegative a -> ShowS
forall a. Show a => [NonNegative a] -> ShowS
forall a. Show a => NonNegative a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NonNegative a] -> ShowS
$cshowList :: forall a. Show a => [NonNegative a] -> ShowS
show :: NonNegative a -> String
$cshow :: forall a. Show a => NonNegative a -> String
showsPrec :: Int -> NonNegative a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> NonNegative a -> ShowS
Show, ReadPrec [NonNegative a]
ReadPrec (NonNegative a)
ReadS [NonNegative a]
forall a. Read a => ReadPrec [NonNegative a]
forall a. Read a => ReadPrec (NonNegative a)
forall a. Read a => Int -> ReadS (NonNegative a)
forall a. Read a => ReadS [NonNegative a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NonNegative a]
$creadListPrec :: forall a. Read a => ReadPrec [NonNegative a]
readPrec :: ReadPrec (NonNegative a)
$creadPrec :: forall a. Read a => ReadPrec (NonNegative a)
readList :: ReadS [NonNegative a]
$creadList :: forall a. Read a => ReadS [NonNegative a]
readsPrec :: Int -> ReadS (NonNegative a)
$creadsPrec :: forall a. Read a => Int -> ReadS (NonNegative a)
Read
#ifndef NO_NEWTYPE_DERIVING
          , Int -> NonNegative a
NonNegative a -> Int
NonNegative a -> [NonNegative a]
NonNegative a -> NonNegative a
NonNegative a -> NonNegative a -> [NonNegative a]
NonNegative a -> NonNegative a -> NonNegative a -> [NonNegative a]
forall a. Enum a => Int -> NonNegative a
forall a. Enum a => NonNegative a -> Int
forall a. Enum a => NonNegative a -> [NonNegative a]
forall a. Enum a => NonNegative a -> NonNegative a
forall a.
Enum a =>
NonNegative a -> NonNegative a -> [NonNegative a]
forall a.
Enum a =>
NonNegative a -> NonNegative a -> NonNegative a -> [NonNegative a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: NonNegative a -> NonNegative a -> NonNegative a -> [NonNegative a]
$cenumFromThenTo :: forall a.
Enum a =>
NonNegative a -> NonNegative a -> NonNegative a -> [NonNegative a]
enumFromTo :: NonNegative a -> NonNegative a -> [NonNegative a]
$cenumFromTo :: forall a.
Enum a =>
NonNegative a -> NonNegative a -> [NonNegative a]
enumFromThen :: NonNegative a -> NonNegative a -> [NonNegative a]
$cenumFromThen :: forall a.
Enum a =>
NonNegative a -> NonNegative a -> [NonNegative a]
enumFrom :: NonNegative a -> [NonNegative a]
$cenumFrom :: forall a. Enum a => NonNegative a -> [NonNegative a]
fromEnum :: NonNegative a -> Int
$cfromEnum :: forall a. Enum a => NonNegative a -> Int
toEnum :: Int -> NonNegative a
$ctoEnum :: forall a. Enum a => Int -> NonNegative a
pred :: NonNegative a -> NonNegative a
$cpred :: forall a. Enum a => NonNegative a -> NonNegative a
succ :: NonNegative a -> NonNegative a
$csucc :: forall a. Enum a => NonNegative a -> NonNegative a
Enum
#endif
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor NonNegative where
  fmap :: forall a b. (a -> b) -> NonNegative a -> NonNegative b
fmap a -> b
f (NonNegative a
x) = forall a. a -> NonNegative a
NonNegative (a -> b
f a
x)

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

--------------------------------------------------------------------------
-- | @NonPositive x@: guarantees that @x \<= 0@.
newtype NonPositive a = NonPositive {forall a. NonPositive a -> a
getNonPositive :: a}
 deriving ( NonPositive a -> NonPositive a -> Bool
forall a. Eq a => NonPositive a -> NonPositive a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NonPositive a -> NonPositive a -> Bool
$c/= :: forall a. Eq a => NonPositive a -> NonPositive a -> Bool
== :: NonPositive a -> NonPositive a -> Bool
$c== :: forall a. Eq a => NonPositive a -> NonPositive a -> Bool
Eq, NonPositive a -> NonPositive a -> Bool
NonPositive a -> NonPositive a -> Ordering
NonPositive a -> NonPositive a -> NonPositive a
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
forall {a}. Ord a => Eq (NonPositive a)
forall a. Ord a => NonPositive a -> NonPositive a -> Bool
forall a. Ord a => NonPositive a -> NonPositive a -> Ordering
forall a. Ord a => NonPositive a -> NonPositive a -> NonPositive a
min :: NonPositive a -> NonPositive a -> NonPositive a
$cmin :: forall a. Ord a => NonPositive a -> NonPositive a -> NonPositive a
max :: NonPositive a -> NonPositive a -> NonPositive a
$cmax :: forall a. Ord a => NonPositive a -> NonPositive a -> NonPositive a
>= :: NonPositive a -> NonPositive a -> Bool
$c>= :: forall a. Ord a => NonPositive a -> NonPositive a -> Bool
> :: NonPositive a -> NonPositive a -> Bool
$c> :: forall a. Ord a => NonPositive a -> NonPositive a -> Bool
<= :: NonPositive a -> NonPositive a -> Bool
$c<= :: forall a. Ord a => NonPositive a -> NonPositive a -> Bool
< :: NonPositive a -> NonPositive a -> Bool
$c< :: forall a. Ord a => NonPositive a -> NonPositive a -> Bool
compare :: NonPositive a -> NonPositive a -> Ordering
$ccompare :: forall a. Ord a => NonPositive a -> NonPositive a -> Ordering
Ord, Int -> NonPositive a -> ShowS
forall a. Show a => Int -> NonPositive a -> ShowS
forall a. Show a => [NonPositive a] -> ShowS
forall a. Show a => NonPositive a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NonPositive a] -> ShowS
$cshowList :: forall a. Show a => [NonPositive a] -> ShowS
show :: NonPositive a -> String
$cshow :: forall a. Show a => NonPositive a -> String
showsPrec :: Int -> NonPositive a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> NonPositive a -> ShowS
Show, ReadPrec [NonPositive a]
ReadPrec (NonPositive a)
ReadS [NonPositive a]
forall a. Read a => ReadPrec [NonPositive a]
forall a. Read a => ReadPrec (NonPositive a)
forall a. Read a => Int -> ReadS (NonPositive a)
forall a. Read a => ReadS [NonPositive a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NonPositive a]
$creadListPrec :: forall a. Read a => ReadPrec [NonPositive a]
readPrec :: ReadPrec (NonPositive a)
$creadPrec :: forall a. Read a => ReadPrec (NonPositive a)
readList :: ReadS [NonPositive a]
$creadList :: forall a. Read a => ReadS [NonPositive a]
readsPrec :: Int -> ReadS (NonPositive a)
$creadsPrec :: forall a. Read a => Int -> ReadS (NonPositive a)
Read
#ifndef NO_NEWTYPE_DERIVING
          , Int -> NonPositive a
NonPositive a -> Int
NonPositive a -> [NonPositive a]
NonPositive a -> NonPositive a
NonPositive a -> NonPositive a -> [NonPositive a]
NonPositive a -> NonPositive a -> NonPositive a -> [NonPositive a]
forall a. Enum a => Int -> NonPositive a
forall a. Enum a => NonPositive a -> Int
forall a. Enum a => NonPositive a -> [NonPositive a]
forall a. Enum a => NonPositive a -> NonPositive a
forall a.
Enum a =>
NonPositive a -> NonPositive a -> [NonPositive a]
forall a.
Enum a =>
NonPositive a -> NonPositive a -> NonPositive a -> [NonPositive a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: NonPositive a -> NonPositive a -> NonPositive a -> [NonPositive a]
$cenumFromThenTo :: forall a.
Enum a =>
NonPositive a -> NonPositive a -> NonPositive a -> [NonPositive a]
enumFromTo :: NonPositive a -> NonPositive a -> [NonPositive a]
$cenumFromTo :: forall a.
Enum a =>
NonPositive a -> NonPositive a -> [NonPositive a]
enumFromThen :: NonPositive a -> NonPositive a -> [NonPositive a]
$cenumFromThen :: forall a.
Enum a =>
NonPositive a -> NonPositive a -> [NonPositive a]
enumFrom :: NonPositive a -> [NonPositive a]
$cenumFrom :: forall a. Enum a => NonPositive a -> [NonPositive a]
fromEnum :: NonPositive a -> Int
$cfromEnum :: forall a. Enum a => NonPositive a -> Int
toEnum :: Int -> NonPositive a
$ctoEnum :: forall a. Enum a => Int -> NonPositive a
pred :: NonPositive a -> NonPositive a
$cpred :: forall a. Enum a => NonPositive a -> NonPositive a
succ :: NonPositive a -> NonPositive a
$csucc :: forall a. Enum a => NonPositive a -> NonPositive a
Enum
#endif
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor NonPositive where
  fmap :: forall a b. (a -> b) -> NonPositive a -> NonPositive b
fmap a -> b
f (NonPositive a
x) = forall a. a -> NonPositive a
NonPositive (a -> b
f a
x)

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

--------------------------------------------------------------------------
-- | @Large x@: by default, QuickCheck generates 'Int's drawn from a small
-- range. @Large Int@ gives you values drawn from the entire range instead.
newtype Large a = Large {forall a. Large a -> a
getLarge :: a}
 deriving ( Large a -> Large a -> Bool
forall a. Eq a => Large a -> Large a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Large a -> Large a -> Bool
$c/= :: forall a. Eq a => Large a -> Large a -> Bool
== :: Large a -> Large a -> Bool
$c== :: forall a. Eq a => Large a -> Large a -> Bool
Eq, Large a -> Large a -> Bool
Large a -> Large a -> Ordering
Large a -> Large a -> Large a
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
forall {a}. Ord a => Eq (Large a)
forall a. Ord a => Large a -> Large a -> Bool
forall a. Ord a => Large a -> Large a -> Ordering
forall a. Ord a => Large a -> Large a -> Large a
min :: Large a -> Large a -> Large a
$cmin :: forall a. Ord a => Large a -> Large a -> Large a
max :: Large a -> Large a -> Large a
$cmax :: forall a. Ord a => Large a -> Large a -> Large a
>= :: Large a -> Large a -> Bool
$c>= :: forall a. Ord a => Large a -> Large a -> Bool
> :: Large a -> Large a -> Bool
$c> :: forall a. Ord a => Large a -> Large a -> Bool
<= :: Large a -> Large a -> Bool
$c<= :: forall a. Ord a => Large a -> Large a -> Bool
< :: Large a -> Large a -> Bool
$c< :: forall a. Ord a => Large a -> Large a -> Bool
compare :: Large a -> Large a -> Ordering
$ccompare :: forall a. Ord a => Large a -> Large a -> Ordering
Ord, Int -> Large a -> ShowS
forall a. Show a => Int -> Large a -> ShowS
forall a. Show a => [Large a] -> ShowS
forall a. Show a => Large a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Large a] -> ShowS
$cshowList :: forall a. Show a => [Large a] -> ShowS
show :: Large a -> String
$cshow :: forall a. Show a => Large a -> String
showsPrec :: Int -> Large a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Large a -> ShowS
Show, ReadPrec [Large a]
ReadPrec (Large a)
ReadS [Large a]
forall a. Read a => ReadPrec [Large a]
forall a. Read a => ReadPrec (Large a)
forall a. Read a => Int -> ReadS (Large a)
forall a. Read a => ReadS [Large a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Large a]
$creadListPrec :: forall a. Read a => ReadPrec [Large a]
readPrec :: ReadPrec (Large a)
$creadPrec :: forall a. Read a => ReadPrec (Large a)
readList :: ReadS [Large a]
$creadList :: forall a. Read a => ReadS [Large a]
readsPrec :: Int -> ReadS (Large a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Large a)
Read
#ifndef NO_NEWTYPE_DERIVING
          , Integer -> Large a
Large a -> Large a
Large a -> Large a -> Large a
forall a. Num a => Integer -> Large a
forall a. Num a => Large a -> Large a
forall a. Num a => Large a -> Large a -> Large a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Large a
$cfromInteger :: forall a. Num a => Integer -> Large a
signum :: Large a -> Large a
$csignum :: forall a. Num a => Large a -> Large a
abs :: Large a -> Large a
$cabs :: forall a. Num a => Large a -> Large a
negate :: Large a -> Large a
$cnegate :: forall a. Num a => Large a -> Large a
* :: Large a -> Large a -> Large a
$c* :: forall a. Num a => Large a -> Large a -> Large a
- :: Large a -> Large a -> Large a
$c- :: forall a. Num a => Large a -> Large a -> Large a
+ :: Large a -> Large a -> Large a
$c+ :: forall a. Num a => Large a -> Large a -> Large a
Num, Large a -> Integer
Large a -> Large a -> (Large a, Large a)
Large a -> Large a -> Large a
forall {a}. Integral a => Enum (Large a)
forall {a}. Integral a => Real (Large a)
forall a. Integral a => Large a -> Integer
forall a. Integral a => Large a -> Large a -> (Large a, Large a)
forall a. Integral a => Large a -> Large a -> Large a
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: Large a -> Integer
$ctoInteger :: forall a. Integral a => Large a -> Integer
divMod :: Large a -> Large a -> (Large a, Large a)
$cdivMod :: forall a. Integral a => Large a -> Large a -> (Large a, Large a)
quotRem :: Large a -> Large a -> (Large a, Large a)
$cquotRem :: forall a. Integral a => Large a -> Large a -> (Large a, Large a)
mod :: Large a -> Large a -> Large a
$cmod :: forall a. Integral a => Large a -> Large a -> Large a
div :: Large a -> Large a -> Large a
$cdiv :: forall a. Integral a => Large a -> Large a -> Large a
rem :: Large a -> Large a -> Large a
$crem :: forall a. Integral a => Large a -> Large a -> Large a
quot :: Large a -> Large a -> Large a
$cquot :: forall a. Integral a => Large a -> Large a -> Large a
Integral, Large a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall {a}. Real a => Num (Large a)
forall {a}. Real a => Ord (Large a)
forall a. Real a => Large a -> Rational
toRational :: Large a -> Rational
$ctoRational :: forall a. Real a => Large a -> Rational
Real, Int -> Large a
Large a -> Int
Large a -> [Large a]
Large a -> Large a
Large a -> Large a -> [Large a]
Large a -> Large a -> Large a -> [Large a]
forall a. Enum a => Int -> Large a
forall a. Enum a => Large a -> Int
forall a. Enum a => Large a -> [Large a]
forall a. Enum a => Large a -> Large a
forall a. Enum a => Large a -> Large a -> [Large a]
forall a. Enum a => Large a -> Large a -> Large a -> [Large a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Large a -> Large a -> Large a -> [Large a]
$cenumFromThenTo :: forall a. Enum a => Large a -> Large a -> Large a -> [Large a]
enumFromTo :: Large a -> Large a -> [Large a]
$cenumFromTo :: forall a. Enum a => Large a -> Large a -> [Large a]
enumFromThen :: Large a -> Large a -> [Large a]
$cenumFromThen :: forall a. Enum a => Large a -> Large a -> [Large a]
enumFrom :: Large a -> [Large a]
$cenumFrom :: forall a. Enum a => Large a -> [Large a]
fromEnum :: Large a -> Int
$cfromEnum :: forall a. Enum a => Large a -> Int
toEnum :: Int -> Large a
$ctoEnum :: forall a. Enum a => Int -> Large a
pred :: Large a -> Large a
$cpred :: forall a. Enum a => Large a -> Large a
succ :: Large a -> Large a
$csucc :: forall a. Enum a => Large a -> Large a
Enum, (Large a, Large a) -> Int
(Large a, Large a) -> [Large a]
(Large a, Large a) -> Large a -> Bool
(Large a, Large a) -> Large a -> Int
forall a.
Ord a
-> ((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
forall {a}. Ix a => Ord (Large a)
forall a. Ix a => (Large a, Large a) -> Int
forall a. Ix a => (Large a, Large a) -> [Large a]
forall a. Ix a => (Large a, Large a) -> Large a -> Bool
forall a. Ix a => (Large a, Large a) -> Large a -> Int
unsafeRangeSize :: (Large a, Large a) -> Int
$cunsafeRangeSize :: forall a. Ix a => (Large a, Large a) -> Int
rangeSize :: (Large a, Large a) -> Int
$crangeSize :: forall a. Ix a => (Large a, Large a) -> Int
inRange :: (Large a, Large a) -> Large a -> Bool
$cinRange :: forall a. Ix a => (Large a, Large a) -> Large a -> Bool
unsafeIndex :: (Large a, Large a) -> Large a -> Int
$cunsafeIndex :: forall a. Ix a => (Large a, Large a) -> Large a -> Int
index :: (Large a, Large a) -> Large a -> Int
$cindex :: forall a. Ix a => (Large a, Large a) -> Large a -> Int
range :: (Large a, Large a) -> [Large a]
$crange :: forall a. Ix a => (Large a, Large a) -> [Large a]
Ix
#endif
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor Large where
  fmap :: forall a b. (a -> b) -> Large a -> Large b
fmap a -> b
f (Large a
x) = forall a. a -> Large a
Large (a -> b
f a
x)

instance (Integral a, Bounded a) => Arbitrary (Large a) where
  arbitrary :: Gen (Large a)
arbitrary = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> Large a
Large forall a. (Bounded a, Integral a) => Gen a
arbitrarySizedBoundedIntegral
  shrink :: Large a -> [Large a]
shrink (Large a
x) = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> Large a
Large (forall a. Integral a => a -> [a]
shrinkIntegral a
x)

--------------------------------------------------------------------------
-- | @Small x@: generates values of @x@ drawn from a small range.
-- The opposite of 'Large'.
newtype Small a = Small {forall a. Small a -> a
getSmall :: a}
 deriving ( Small a -> Small a -> Bool
forall a. Eq a => Small a -> Small a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Small a -> Small a -> Bool
$c/= :: forall a. Eq a => Small a -> Small a -> Bool
== :: Small a -> Small a -> Bool
$c== :: forall a. Eq a => Small a -> Small a -> Bool
Eq, Small a -> Small a -> Bool
Small a -> Small a -> Ordering
Small a -> Small a -> Small a
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
forall {a}. Ord a => Eq (Small a)
forall a. Ord a => Small a -> Small a -> Bool
forall a. Ord a => Small a -> Small a -> Ordering
forall a. Ord a => Small a -> Small a -> Small a
min :: Small a -> Small a -> Small a
$cmin :: forall a. Ord a => Small a -> Small a -> Small a
max :: Small a -> Small a -> Small a
$cmax :: forall a. Ord a => Small a -> Small a -> Small a
>= :: Small a -> Small a -> Bool
$c>= :: forall a. Ord a => Small a -> Small a -> Bool
> :: Small a -> Small a -> Bool
$c> :: forall a. Ord a => Small a -> Small a -> Bool
<= :: Small a -> Small a -> Bool
$c<= :: forall a. Ord a => Small a -> Small a -> Bool
< :: Small a -> Small a -> Bool
$c< :: forall a. Ord a => Small a -> Small a -> Bool
compare :: Small a -> Small a -> Ordering
$ccompare :: forall a. Ord a => Small a -> Small a -> Ordering
Ord, Int -> Small a -> ShowS
forall a. Show a => Int -> Small a -> ShowS
forall a. Show a => [Small a] -> ShowS
forall a. Show a => Small a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Small a] -> ShowS
$cshowList :: forall a. Show a => [Small a] -> ShowS
show :: Small a -> String
$cshow :: forall a. Show a => Small a -> String
showsPrec :: Int -> Small a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Small a -> ShowS
Show, ReadPrec [Small a]
ReadPrec (Small a)
ReadS [Small a]
forall a. Read a => ReadPrec [Small a]
forall a. Read a => ReadPrec (Small a)
forall a. Read a => Int -> ReadS (Small a)
forall a. Read a => ReadS [Small a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Small a]
$creadListPrec :: forall a. Read a => ReadPrec [Small a]
readPrec :: ReadPrec (Small a)
$creadPrec :: forall a. Read a => ReadPrec (Small a)
readList :: ReadS [Small a]
$creadList :: forall a. Read a => ReadS [Small a]
readsPrec :: Int -> ReadS (Small a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Small a)
Read
#ifndef NO_NEWTYPE_DERIVING
          , Integer -> Small a
Small a -> Small a
Small a -> Small a -> Small a
forall a. Num a => Integer -> Small a
forall a. Num a => Small a -> Small a
forall a. Num a => Small a -> Small a -> Small a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Small a
$cfromInteger :: forall a. Num a => Integer -> Small a
signum :: Small a -> Small a
$csignum :: forall a. Num a => Small a -> Small a
abs :: Small a -> Small a
$cabs :: forall a. Num a => Small a -> Small a
negate :: Small a -> Small a
$cnegate :: forall a. Num a => Small a -> Small a
* :: Small a -> Small a -> Small a
$c* :: forall a. Num a => Small a -> Small a -> Small a
- :: Small a -> Small a -> Small a
$c- :: forall a. Num a => Small a -> Small a -> Small a
+ :: Small a -> Small a -> Small a
$c+ :: forall a. Num a => Small a -> Small a -> Small a
Num, Small a -> Integer
Small a -> Small a -> (Small a, Small a)
Small a -> Small a -> Small a
forall {a}. Integral a => Enum (Small a)
forall {a}. Integral a => Real (Small a)
forall a. Integral a => Small a -> Integer
forall a. Integral a => Small a -> Small a -> (Small a, Small a)
forall a. Integral a => Small a -> Small a -> Small a
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: Small a -> Integer
$ctoInteger :: forall a. Integral a => Small a -> Integer
divMod :: Small a -> Small a -> (Small a, Small a)
$cdivMod :: forall a. Integral a => Small a -> Small a -> (Small a, Small a)
quotRem :: Small a -> Small a -> (Small a, Small a)
$cquotRem :: forall a. Integral a => Small a -> Small a -> (Small a, Small a)
mod :: Small a -> Small a -> Small a
$cmod :: forall a. Integral a => Small a -> Small a -> Small a
div :: Small a -> Small a -> Small a
$cdiv :: forall a. Integral a => Small a -> Small a -> Small a
rem :: Small a -> Small a -> Small a
$crem :: forall a. Integral a => Small a -> Small a -> Small a
quot :: Small a -> Small a -> Small a
$cquot :: forall a. Integral a => Small a -> Small a -> Small a
Integral, Small a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall {a}. Real a => Num (Small a)
forall {a}. Real a => Ord (Small a)
forall a. Real a => Small a -> Rational
toRational :: Small a -> Rational
$ctoRational :: forall a. Real a => Small a -> Rational
Real, Int -> Small a
Small a -> Int
Small a -> [Small a]
Small a -> Small a
Small a -> Small a -> [Small a]
Small a -> Small a -> Small a -> [Small a]
forall a. Enum a => Int -> Small a
forall a. Enum a => Small a -> Int
forall a. Enum a => Small a -> [Small a]
forall a. Enum a => Small a -> Small a
forall a. Enum a => Small a -> Small a -> [Small a]
forall a. Enum a => Small a -> Small a -> Small a -> [Small a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Small a -> Small a -> Small a -> [Small a]
$cenumFromThenTo :: forall a. Enum a => Small a -> Small a -> Small a -> [Small a]
enumFromTo :: Small a -> Small a -> [Small a]
$cenumFromTo :: forall a. Enum a => Small a -> Small a -> [Small a]
enumFromThen :: Small a -> Small a -> [Small a]
$cenumFromThen :: forall a. Enum a => Small a -> Small a -> [Small a]
enumFrom :: Small a -> [Small a]
$cenumFrom :: forall a. Enum a => Small a -> [Small a]
fromEnum :: Small a -> Int
$cfromEnum :: forall a. Enum a => Small a -> Int
toEnum :: Int -> Small a
$ctoEnum :: forall a. Enum a => Int -> Small a
pred :: Small a -> Small a
$cpred :: forall a. Enum a => Small a -> Small a
succ :: Small a -> Small a
$csucc :: forall a. Enum a => Small a -> Small a
Enum, (Small a, Small a) -> Int
(Small a, Small a) -> [Small a]
(Small a, Small a) -> Small a -> Bool
(Small a, Small a) -> Small a -> Int
forall a.
Ord a
-> ((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
forall {a}. Ix a => Ord (Small a)
forall a. Ix a => (Small a, Small a) -> Int
forall a. Ix a => (Small a, Small a) -> [Small a]
forall a. Ix a => (Small a, Small a) -> Small a -> Bool
forall a. Ix a => (Small a, Small a) -> Small a -> Int
unsafeRangeSize :: (Small a, Small a) -> Int
$cunsafeRangeSize :: forall a. Ix a => (Small a, Small a) -> Int
rangeSize :: (Small a, Small a) -> Int
$crangeSize :: forall a. Ix a => (Small a, Small a) -> Int
inRange :: (Small a, Small a) -> Small a -> Bool
$cinRange :: forall a. Ix a => (Small a, Small a) -> Small a -> Bool
unsafeIndex :: (Small a, Small a) -> Small a -> Int
$cunsafeIndex :: forall a. Ix a => (Small a, Small a) -> Small a -> Int
index :: (Small a, Small a) -> Small a -> Int
$cindex :: forall a. Ix a => (Small a, Small a) -> Small a -> Int
range :: (Small a, Small a) -> [Small a]
$crange :: forall a. Ix a => (Small a, Small a) -> [Small a]
Ix
#endif
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor Small where
  fmap :: forall a b. (a -> b) -> Small a -> Small b
fmap a -> b
f (Small a
x) = forall a. a -> Small a
Small (a -> b
f a
x)

instance Integral a => Arbitrary (Small a) where
  arbitrary :: Gen (Small a)
arbitrary = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> Small a
Small forall a. Integral a => Gen a
arbitrarySizedIntegral
  shrink :: Small a -> [Small a]
shrink (Small a
x) = forall a b. (a -> b) -> [a] -> [b]
map forall a. a -> Small a
Small (forall a. Integral a => a -> [a]
shrinkIntegral a
x)

--------------------------------------------------------------------------
-- | @Shrink2 x@: allows 2 shrinking steps at the same time when shrinking x
newtype Shrink2 a = Shrink2 {forall a. Shrink2 a -> a
getShrink2 :: a}
 deriving ( Shrink2 a -> Shrink2 a -> Bool
forall a. Eq a => Shrink2 a -> Shrink2 a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Shrink2 a -> Shrink2 a -> Bool
$c/= :: forall a. Eq a => Shrink2 a -> Shrink2 a -> Bool
== :: Shrink2 a -> Shrink2 a -> Bool
$c== :: forall a. Eq a => Shrink2 a -> Shrink2 a -> Bool
Eq, Shrink2 a -> Shrink2 a -> Bool
Shrink2 a -> Shrink2 a -> Ordering
Shrink2 a -> Shrink2 a -> Shrink2 a
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
forall {a}. Ord a => Eq (Shrink2 a)
forall a. Ord a => Shrink2 a -> Shrink2 a -> Bool
forall a. Ord a => Shrink2 a -> Shrink2 a -> Ordering
forall a. Ord a => Shrink2 a -> Shrink2 a -> Shrink2 a
min :: Shrink2 a -> Shrink2 a -> Shrink2 a
$cmin :: forall a. Ord a => Shrink2 a -> Shrink2 a -> Shrink2 a
max :: Shrink2 a -> Shrink2 a -> Shrink2 a
$cmax :: forall a. Ord a => Shrink2 a -> Shrink2 a -> Shrink2 a
>= :: Shrink2 a -> Shrink2 a -> Bool
$c>= :: forall a. Ord a => Shrink2 a -> Shrink2 a -> Bool
> :: Shrink2 a -> Shrink2 a -> Bool
$c> :: forall a. Ord a => Shrink2 a -> Shrink2 a -> Bool
<= :: Shrink2 a -> Shrink2 a -> Bool
$c<= :: forall a. Ord a => Shrink2 a -> Shrink2 a -> Bool
< :: Shrink2 a -> Shrink2 a -> Bool
$c< :: forall a. Ord a => Shrink2 a -> Shrink2 a -> Bool
compare :: Shrink2 a -> Shrink2 a -> Ordering
$ccompare :: forall a. Ord a => Shrink2 a -> Shrink2 a -> Ordering
Ord, Int -> Shrink2 a -> ShowS
forall a. Show a => Int -> Shrink2 a -> ShowS
forall a. Show a => [Shrink2 a] -> ShowS
forall a. Show a => Shrink2 a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Shrink2 a] -> ShowS
$cshowList :: forall a. Show a => [Shrink2 a] -> ShowS
show :: Shrink2 a -> String
$cshow :: forall a. Show a => Shrink2 a -> String
showsPrec :: Int -> Shrink2 a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Shrink2 a -> ShowS
Show, ReadPrec [Shrink2 a]
ReadPrec (Shrink2 a)
ReadS [Shrink2 a]
forall a. Read a => ReadPrec [Shrink2 a]
forall a. Read a => ReadPrec (Shrink2 a)
forall a. Read a => Int -> ReadS (Shrink2 a)
forall a. Read a => ReadS [Shrink2 a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Shrink2 a]
$creadListPrec :: forall a. Read a => ReadPrec [Shrink2 a]
readPrec :: ReadPrec (Shrink2 a)
$creadPrec :: forall a. Read a => ReadPrec (Shrink2 a)
readList :: ReadS [Shrink2 a]
$creadList :: forall a. Read a => ReadS [Shrink2 a]
readsPrec :: Int -> ReadS (Shrink2 a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Shrink2 a)
Read
#ifndef NO_NEWTYPE_DERIVING
          , Integer -> Shrink2 a
Shrink2 a -> Shrink2 a
Shrink2 a -> Shrink2 a -> Shrink2 a
forall a. Num a => Integer -> Shrink2 a
forall a. Num a => Shrink2 a -> Shrink2 a
forall a. Num a => Shrink2 a -> Shrink2 a -> Shrink2 a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Shrink2 a
$cfromInteger :: forall a. Num a => Integer -> Shrink2 a
signum :: Shrink2 a -> Shrink2 a
$csignum :: forall a. Num a => Shrink2 a -> Shrink2 a
abs :: Shrink2 a -> Shrink2 a
$cabs :: forall a. Num a => Shrink2 a -> Shrink2 a
negate :: Shrink2 a -> Shrink2 a
$cnegate :: forall a. Num a => Shrink2 a -> Shrink2 a
* :: Shrink2 a -> Shrink2 a -> Shrink2 a
$c* :: forall a. Num a => Shrink2 a -> Shrink2 a -> Shrink2 a
- :: Shrink2 a -> Shrink2 a -> Shrink2 a
$c- :: forall a. Num a => Shrink2 a -> Shrink2 a -> Shrink2 a
+ :: Shrink2 a -> Shrink2 a -> Shrink2 a
$c+ :: forall a. Num a => Shrink2 a -> Shrink2 a -> Shrink2 a
Num, Shrink2 a -> Integer
Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a)
Shrink2 a -> Shrink2 a -> Shrink2 a
forall {a}. Integral a => Enum (Shrink2 a)
forall {a}. Integral a => Real (Shrink2 a)
forall a. Integral a => Shrink2 a -> Integer
forall a.
Integral a =>
Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a)
forall a. Integral a => Shrink2 a -> Shrink2 a -> Shrink2 a
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: Shrink2 a -> Integer
$ctoInteger :: forall a. Integral a => Shrink2 a -> Integer
divMod :: Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a)
$cdivMod :: forall a.
Integral a =>
Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a)
quotRem :: Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a)
$cquotRem :: forall a.
Integral a =>
Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a)
mod :: Shrink2 a -> Shrink2 a -> Shrink2 a
$cmod :: forall a. Integral a => Shrink2 a -> Shrink2 a -> Shrink2 a
div :: Shrink2 a -> Shrink2 a -> Shrink2 a
$cdiv :: forall a. Integral a => Shrink2 a -> Shrink2 a -> Shrink2 a
rem :: Shrink2 a -> Shrink2 a -> Shrink2 a
$crem :: forall a. Integral a => Shrink2 a -> Shrink2 a -> Shrink2 a
quot :: Shrink2 a -> Shrink2 a -> Shrink2 a
$cquot :: forall a. Integral a => Shrink2 a -> Shrink2 a -> Shrink2 a
Integral, Shrink2 a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall {a}. Real a => Num (Shrink2 a)
forall {a}. Real a => Ord (Shrink2 a)
forall a. Real a => Shrink2 a -> Rational
toRational :: Shrink2 a -> Rational
$ctoRational :: forall a. Real a => Shrink2 a -> Rational
Real, Int -> Shrink2 a
Shrink2 a -> Int
Shrink2 a -> [Shrink2 a]
Shrink2 a -> Shrink2 a
Shrink2 a -> Shrink2 a -> [Shrink2 a]
Shrink2 a -> Shrink2 a -> Shrink2 a -> [Shrink2 a]
forall a. Enum a => Int -> Shrink2 a
forall a. Enum a => Shrink2 a -> Int
forall a. Enum a => Shrink2 a -> [Shrink2 a]
forall a. Enum a => Shrink2 a -> Shrink2 a
forall a. Enum a => Shrink2 a -> Shrink2 a -> [Shrink2 a]
forall a.
Enum a =>
Shrink2 a -> Shrink2 a -> Shrink2 a -> [Shrink2 a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Shrink2 a -> Shrink2 a -> Shrink2 a -> [Shrink2 a]
$cenumFromThenTo :: forall a.
Enum a =>
Shrink2 a -> Shrink2 a -> Shrink2 a -> [Shrink2 a]
enumFromTo :: Shrink2 a -> Shrink2 a -> [Shrink2 a]
$cenumFromTo :: forall a. Enum a => Shrink2 a -> Shrink2 a -> [Shrink2 a]
enumFromThen :: Shrink2 a -> Shrink2 a -> [Shrink2 a]
$cenumFromThen :: forall a. Enum a => Shrink2 a -> Shrink2 a -> [Shrink2 a]
enumFrom :: Shrink2 a -> [Shrink2 a]
$cenumFrom :: forall a. Enum a => Shrink2 a -> [Shrink2 a]
fromEnum :: Shrink2 a -> Int
$cfromEnum :: forall a. Enum a => Shrink2 a -> Int
toEnum :: Int -> Shrink2 a
$ctoEnum :: forall a. Enum a => Int -> Shrink2 a
pred :: Shrink2 a -> Shrink2 a
$cpred :: forall a. Enum a => Shrink2 a -> Shrink2 a
succ :: Shrink2 a -> Shrink2 a
$csucc :: forall a. Enum a => Shrink2 a -> Shrink2 a
Enum
#endif
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor Shrink2 where
  fmap :: forall a b. (a -> b) -> Shrink2 a -> Shrink2 b
fmap a -> b
f (Shrink2 a
x) = forall a. a -> Shrink2 a
Shrink2 (a -> b
f a
x)

instance Arbitrary a => Arbitrary (Shrink2 a) where
  arbitrary :: Gen (Shrink2 a)
arbitrary =
    forall a. a -> Shrink2 a
Shrink2 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Arbitrary a => Gen a
arbitrary

  shrink :: Shrink2 a -> [Shrink2 a]
shrink (Shrink2 a
x) =
    [ forall a. a -> Shrink2 a
Shrink2 a
y | a
y <- [a]
shrink_x ] forall a. [a] -> [a] -> [a]
++
    [ forall a. a -> Shrink2 a
Shrink2 a
z
    | a
y <- [a]
shrink_x
    , a
z <- forall a. Arbitrary a => a -> [a]
shrink a
y
    ]
   where
    shrink_x :: [a]
shrink_x = forall a. Arbitrary a => a -> [a]
shrink a
x

--------------------------------------------------------------------------
-- | @Smart _ x@: tries a different order when shrinking.
data Smart a =
  Smart Int a

instance Functor Smart where
  fmap :: forall a b. (a -> b) -> Smart a -> Smart b
fmap a -> b
f (Smart Int
n a
x) = forall a. Int -> a -> Smart a
Smart Int
n (a -> b
f a
x)

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

instance Arbitrary a => Arbitrary (Smart a) where
  arbitrary :: Gen (Smart a)
arbitrary =
    do a
x <- forall a. Arbitrary a => Gen a
arbitrary
       forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. Int -> a -> Smart a
Smart Int
0 a
x)

  shrink :: Smart a -> [Smart a]
shrink (Smart Int
i a
x) = forall a. Int -> [a] -> [a]
take Int
i' [Smart a]
ys forall a. [a] -> [a] -> [a]
`ilv` forall a. Int -> [a] -> [a]
drop Int
i' [Smart a]
ys
   where
    ys :: [Smart a]
ys = [ forall a. Int -> a -> Smart a
Smart Int
j a
y | (Int
j,a
y) <- [Int
0..] forall a b. [a] -> [b] -> [(a, b)]
`zip` forall a. Arbitrary a => a -> [a]
shrink a
x ]
    i' :: Int
i' = Int
0 forall a. Ord a => a -> a -> a
`max` (Int
iforall a. Num a => a -> a -> a
-Int
2)

    []     ilv :: [a] -> [a] -> [a]
`ilv` [a]
bs     = [a]
bs
    [a]
as     `ilv` []     = [a]
as
    (a
a:[a]
as) `ilv` (a
b:[a]
bs) = a
a forall a. a -> [a] -> [a]
: a
b forall a. a -> [a] -> [a]
: ([a]
as [a] -> [a] -> [a]
`ilv` [a]
bs)

{-
  shrink (Smart i x) = part0 ++ part2 ++ part1
   where
    ys = [ Smart i y | (i,y) <- [0..] `zip` shrink x ]
    i' = 0 `max` (i-2)
    k  = i `div` 10

    part0 = take k ys
    part1 = take (i'-k) (drop k ys)
    part2 = drop i' ys
-}

    -- drop a (drop b xs) == drop (a+b) xs           | a,b >= 0
    -- take a (take b xs) == take (a `min` b) xs
    -- take a xs ++ drop a xs == xs

    --    take k ys ++ take (i'-k) (drop k ys) ++ drop i' ys
    -- == take k ys ++ take (i'-k) (drop k ys) ++ drop (i'-k) (drop k ys)
    -- == take k ys ++ take (i'-k) (drop k ys) ++ drop (i'-k) (drop k ys)
    -- == take k ys ++ drop k ys
    -- == ys

#ifndef NO_MULTI_PARAM_TYPE_CLASSES
--------------------------------------------------------------------------
-- | @Shrinking _ x@: allows for maintaining a state during shrinking.
data Shrinking s a =
  Shrinking s a

class ShrinkState s a where
  shrinkInit  :: a -> s
  shrinkState :: a -> s -> [(a,s)]

instance Functor (Shrinking s) where
  fmap :: forall a b. (a -> b) -> Shrinking s a -> Shrinking s b
fmap a -> b
f (Shrinking s
s a
x) = forall s a. s -> a -> Shrinking s a
Shrinking s
s (a -> b
f a
x)

instance Show a => Show (Shrinking s a) where
  showsPrec :: Int -> Shrinking s a -> ShowS
showsPrec Int
n (Shrinking s
_ a
x) = forall a. Show a => Int -> a -> ShowS
showsPrec Int
n a
x

instance (Arbitrary a, ShrinkState s a) => Arbitrary (Shrinking s a) where
  arbitrary :: Gen (Shrinking s a)
arbitrary =
    do a
x <- forall a. Arbitrary a => Gen a
arbitrary
       forall (m :: * -> *) a. Monad m => a -> m a
return (forall s a. s -> a -> Shrinking s a
Shrinking (forall s a. ShrinkState s a => a -> s
shrinkInit a
x) a
x)

  shrink :: Shrinking s a -> [Shrinking s a]
shrink (Shrinking s
s a
x) =
    [ forall s a. s -> a -> Shrinking s a
Shrinking s
s' a
x'
    | (a
x',s
s') <- forall s a. ShrinkState s a => a -> s -> [(a, s)]
shrinkState a
x s
s
    ]

#endif /* NO_MULTI_PARAM_TYPE_CLASSES */

--------------------------------------------------------------------------
-- | @ASCIIString@: generates an ASCII string.
newtype ASCIIString = ASCIIString {ASCIIString -> String
getASCIIString :: String}
  deriving ( ASCIIString -> ASCIIString -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ASCIIString -> ASCIIString -> Bool
$c/= :: ASCIIString -> ASCIIString -> Bool
== :: ASCIIString -> ASCIIString -> Bool
$c== :: ASCIIString -> ASCIIString -> Bool
Eq, Eq ASCIIString
ASCIIString -> ASCIIString -> Bool
ASCIIString -> ASCIIString -> Ordering
ASCIIString -> ASCIIString -> ASCIIString
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 :: ASCIIString -> ASCIIString -> ASCIIString
$cmin :: ASCIIString -> ASCIIString -> ASCIIString
max :: ASCIIString -> ASCIIString -> ASCIIString
$cmax :: ASCIIString -> ASCIIString -> ASCIIString
>= :: ASCIIString -> ASCIIString -> Bool
$c>= :: ASCIIString -> ASCIIString -> Bool
> :: ASCIIString -> ASCIIString -> Bool
$c> :: ASCIIString -> ASCIIString -> Bool
<= :: ASCIIString -> ASCIIString -> Bool
$c<= :: ASCIIString -> ASCIIString -> Bool
< :: ASCIIString -> ASCIIString -> Bool
$c< :: ASCIIString -> ASCIIString -> Bool
compare :: ASCIIString -> ASCIIString -> Ordering
$ccompare :: ASCIIString -> ASCIIString -> Ordering
Ord, Int -> ASCIIString -> ShowS
[ASCIIString] -> ShowS
ASCIIString -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ASCIIString] -> ShowS
$cshowList :: [ASCIIString] -> ShowS
show :: ASCIIString -> String
$cshow :: ASCIIString -> String
showsPrec :: Int -> ASCIIString -> ShowS
$cshowsPrec :: Int -> ASCIIString -> ShowS
Show, ReadPrec [ASCIIString]
ReadPrec ASCIIString
Int -> ReadS ASCIIString
ReadS [ASCIIString]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ASCIIString]
$creadListPrec :: ReadPrec [ASCIIString]
readPrec :: ReadPrec ASCIIString
$creadPrec :: ReadPrec ASCIIString
readList :: ReadS [ASCIIString]
$creadList :: ReadS [ASCIIString]
readsPrec :: Int -> ReadS ASCIIString
$creadsPrec :: Int -> ReadS ASCIIString
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
           )

instance Arbitrary ASCIIString where
  arbitrary :: Gen ASCIIString
arbitrary = String -> ASCIIString
ASCIIString forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Gen a -> Gen [a]
listOf Gen Char
arbitraryASCIIChar
  shrink :: ASCIIString -> [ASCIIString]
shrink (ASCIIString String
xs) = String -> ASCIIString
ASCIIString forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Arbitrary a => a -> [a]
shrink String
xs

--------------------------------------------------------------------------
-- | @UnicodeString@: generates a unicode String.
-- The string will not contain surrogate pairs.
newtype UnicodeString = UnicodeString {UnicodeString -> String
getUnicodeString :: String}
  deriving ( UnicodeString -> UnicodeString -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnicodeString -> UnicodeString -> Bool
$c/= :: UnicodeString -> UnicodeString -> Bool
== :: UnicodeString -> UnicodeString -> Bool
$c== :: UnicodeString -> UnicodeString -> Bool
Eq, Eq UnicodeString
UnicodeString -> UnicodeString -> Bool
UnicodeString -> UnicodeString -> Ordering
UnicodeString -> UnicodeString -> UnicodeString
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 :: UnicodeString -> UnicodeString -> UnicodeString
$cmin :: UnicodeString -> UnicodeString -> UnicodeString
max :: UnicodeString -> UnicodeString -> UnicodeString
$cmax :: UnicodeString -> UnicodeString -> UnicodeString
>= :: UnicodeString -> UnicodeString -> Bool
$c>= :: UnicodeString -> UnicodeString -> Bool
> :: UnicodeString -> UnicodeString -> Bool
$c> :: UnicodeString -> UnicodeString -> Bool
<= :: UnicodeString -> UnicodeString -> Bool
$c<= :: UnicodeString -> UnicodeString -> Bool
< :: UnicodeString -> UnicodeString -> Bool
$c< :: UnicodeString -> UnicodeString -> Bool
compare :: UnicodeString -> UnicodeString -> Ordering
$ccompare :: UnicodeString -> UnicodeString -> Ordering
Ord, Int -> UnicodeString -> ShowS
[UnicodeString] -> ShowS
UnicodeString -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnicodeString] -> ShowS
$cshowList :: [UnicodeString] -> ShowS
show :: UnicodeString -> String
$cshow :: UnicodeString -> String
showsPrec :: Int -> UnicodeString -> ShowS
$cshowsPrec :: Int -> UnicodeString -> ShowS
Show, ReadPrec [UnicodeString]
ReadPrec UnicodeString
Int -> ReadS UnicodeString
ReadS [UnicodeString]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnicodeString]
$creadListPrec :: ReadPrec [UnicodeString]
readPrec :: ReadPrec UnicodeString
$creadPrec :: ReadPrec UnicodeString
readList :: ReadS [UnicodeString]
$creadList :: ReadS [UnicodeString]
readsPrec :: Int -> ReadS UnicodeString
$creadsPrec :: Int -> ReadS UnicodeString
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
           )

instance Arbitrary UnicodeString where
  arbitrary :: Gen UnicodeString
arbitrary = String -> UnicodeString
UnicodeString forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Gen a -> Gen [a]
listOf Gen Char
arbitraryUnicodeChar
  shrink :: UnicodeString -> [UnicodeString]
shrink (UnicodeString String
xs) = String -> UnicodeString
UnicodeString forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Arbitrary a => a -> [a]
shrink String
xs

--------------------------------------------------------------------------
-- | @PrintableString@: generates a printable unicode String.
-- The string will not contain surrogate pairs.
newtype PrintableString = PrintableString {PrintableString -> String
getPrintableString :: String}
  deriving ( PrintableString -> PrintableString -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PrintableString -> PrintableString -> Bool
$c/= :: PrintableString -> PrintableString -> Bool
== :: PrintableString -> PrintableString -> Bool
$c== :: PrintableString -> PrintableString -> Bool
Eq, Eq PrintableString
PrintableString -> PrintableString -> Bool
PrintableString -> PrintableString -> Ordering
PrintableString -> PrintableString -> PrintableString
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 :: PrintableString -> PrintableString -> PrintableString
$cmin :: PrintableString -> PrintableString -> PrintableString
max :: PrintableString -> PrintableString -> PrintableString
$cmax :: PrintableString -> PrintableString -> PrintableString
>= :: PrintableString -> PrintableString -> Bool
$c>= :: PrintableString -> PrintableString -> Bool
> :: PrintableString -> PrintableString -> Bool
$c> :: PrintableString -> PrintableString -> Bool
<= :: PrintableString -> PrintableString -> Bool
$c<= :: PrintableString -> PrintableString -> Bool
< :: PrintableString -> PrintableString -> Bool
$c< :: PrintableString -> PrintableString -> Bool
compare :: PrintableString -> PrintableString -> Ordering
$ccompare :: PrintableString -> PrintableString -> Ordering
Ord, Int -> PrintableString -> ShowS
[PrintableString] -> ShowS
PrintableString -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PrintableString] -> ShowS
$cshowList :: [PrintableString] -> ShowS
show :: PrintableString -> String
$cshow :: PrintableString -> String
showsPrec :: Int -> PrintableString -> ShowS
$cshowsPrec :: Int -> PrintableString -> ShowS
Show, ReadPrec [PrintableString]
ReadPrec PrintableString
Int -> ReadS PrintableString
ReadS [PrintableString]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PrintableString]
$creadListPrec :: ReadPrec [PrintableString]
readPrec :: ReadPrec PrintableString
$creadPrec :: ReadPrec PrintableString
readList :: ReadS [PrintableString]
$creadList :: ReadS [PrintableString]
readsPrec :: Int -> ReadS PrintableString
$creadsPrec :: Int -> ReadS PrintableString
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
           )

instance Arbitrary PrintableString where
  arbitrary :: Gen PrintableString
arbitrary = String -> PrintableString
PrintableString forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Gen a -> Gen [a]
listOf Gen Char
arbitraryPrintableChar
  shrink :: PrintableString -> [PrintableString]
shrink (PrintableString String
xs) = String -> PrintableString
PrintableString forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Arbitrary a => a -> [a]
shrink String
xs

-- the end.