{-# 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
(Blind a -> Blind a -> Bool)
-> (Blind a -> Blind a -> Bool) -> Eq (Blind a)
forall a. Eq a => Blind a -> Blind a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: Blind a -> Blind a -> Bool
Eq, Eq (Blind a)
Eq (Blind a) =>
(Blind a -> Blind a -> Ordering)
-> (Blind a -> Blind a -> Bool)
-> (Blind a -> Blind a -> Bool)
-> (Blind a -> Blind a -> Bool)
-> (Blind a -> Blind a -> Bool)
-> (Blind a -> Blind a -> Blind a)
-> (Blind a -> Blind a -> Blind a)
-> Ord (Blind a)
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
$ccompare :: forall a. Ord a => Blind a -> Blind a -> Ordering
compare :: Blind a -> Blind a -> Ordering
$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
>= :: Blind a -> Blind a -> Bool
$cmax :: forall a. Ord a => Blind a -> Blind a -> Blind a
max :: Blind a -> Blind a -> Blind a
$cmin :: forall a. Ord a => Blind a -> Blind a -> Blind a
min :: Blind a -> Blind a -> Blind a
Ord
#ifndef NO_NEWTYPE_DERIVING
          , Integer -> Blind a
Blind a -> Blind a
Blind a -> Blind a -> Blind a
(Blind a -> Blind a -> Blind a)
-> (Blind a -> Blind a -> Blind a)
-> (Blind a -> Blind a -> Blind a)
-> (Blind a -> Blind a)
-> (Blind a -> Blind a)
-> (Blind a -> Blind a)
-> (Integer -> Blind a)
-> Num (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
$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
* :: Blind a -> Blind a -> Blind a
$cnegate :: forall a. Num a => Blind a -> Blind a
negate :: Blind a -> Blind a
$cabs :: forall a. Num a => Blind a -> Blind a
abs :: Blind a -> Blind a
$csignum :: forall a. Num a => Blind a -> Blind a
signum :: Blind a -> Blind a
$cfromInteger :: forall a. Num a => Integer -> Blind a
fromInteger :: Integer -> Blind a
Num, Enum (Blind a)
Real (Blind a)
(Real (Blind a), Enum (Blind a)) =>
(Blind a -> Blind a -> Blind a)
-> (Blind a -> Blind a -> Blind a)
-> (Blind a -> Blind a -> Blind a)
-> (Blind a -> Blind a -> Blind a)
-> (Blind a -> Blind a -> (Blind a, Blind a))
-> (Blind a -> Blind a -> (Blind a, Blind a))
-> (Blind a -> Integer)
-> Integral (Blind a)
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
$cquot :: forall a. Integral a => Blind a -> Blind a -> Blind a
quot :: Blind a -> Blind a -> Blind a
$crem :: forall a. Integral a => Blind a -> Blind a -> Blind a
rem :: Blind a -> Blind a -> Blind a
$cdiv :: forall a. Integral a => Blind a -> Blind a -> Blind a
div :: Blind a -> Blind a -> Blind a
$cmod :: forall a. Integral a => Blind a -> Blind a -> Blind a
mod :: Blind a -> Blind a -> Blind a
$cquotRem :: forall a. Integral a => Blind a -> Blind a -> (Blind a, Blind a)
quotRem :: Blind a -> Blind a -> (Blind a, Blind a)
$cdivMod :: forall a. Integral a => Blind a -> Blind a -> (Blind a, Blind a)
divMod :: Blind a -> Blind a -> (Blind a, Blind a)
$ctoInteger :: forall a. Integral a => Blind a -> Integer
toInteger :: Blind a -> Integer
Integral, Num (Blind a)
Ord (Blind a)
(Num (Blind a), Ord (Blind a)) =>
(Blind a -> Rational) -> Real (Blind a)
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
$ctoRational :: forall a. Real a => Blind a -> Rational
toRational :: 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]
(Blind a -> Blind a)
-> (Blind a -> Blind a)
-> (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 -> [Blind a])
-> Enum (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
$csucc :: forall a. Enum a => Blind a -> Blind a
succ :: Blind a -> Blind a
$cpred :: forall a. Enum a => Blind a -> Blind a
pred :: Blind a -> Blind a
$ctoEnum :: forall a. Enum a => Int -> Blind a
toEnum :: Int -> Blind a
$cfromEnum :: forall a. Enum a => Blind a -> Int
fromEnum :: Blind a -> Int
$cenumFrom :: forall a. Enum a => Blind a -> [Blind a]
enumFrom :: Blind a -> [Blind a]
$cenumFromThen :: forall a. Enum a => Blind a -> Blind a -> [Blind a]
enumFromThen :: Blind a -> Blind a -> [Blind a]
$cenumFromTo :: forall a. Enum a => Blind a -> Blind a -> [Blind a]
enumFromTo :: Blind a -> Blind a -> [Blind a]
$cenumFromThenTo :: forall a. Enum a => Blind a -> Blind a -> Blind a -> [Blind a]
enumFromThenTo :: Blind a -> Blind 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) = b -> Blind b
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 = a -> Blind a
forall a. a -> Blind a
Blind (a -> Blind a) -> Gen a -> Gen (Blind a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen a
forall a. Arbitrary a => Gen a
arbitrary

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

instance Arbitrary a => Arbitrary (Fixed a) where
  arbitrary :: Gen (Fixed a)
arbitrary = a -> Fixed a
forall a. a -> Fixed a
Fixed (a -> Fixed a) -> Gen a -> Gen (Fixed a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen a
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
(OrderedList a -> OrderedList a -> Bool)
-> (OrderedList a -> OrderedList a -> Bool) -> Eq (OrderedList a)
forall a. Eq a => OrderedList a -> OrderedList a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: OrderedList a -> OrderedList a -> Bool
Eq, Eq (OrderedList a)
Eq (OrderedList a) =>
(OrderedList a -> OrderedList a -> Ordering)
-> (OrderedList a -> OrderedList a -> Bool)
-> (OrderedList a -> OrderedList a -> Bool)
-> (OrderedList a -> OrderedList a -> Bool)
-> (OrderedList a -> OrderedList a -> Bool)
-> (OrderedList a -> OrderedList a -> OrderedList a)
-> (OrderedList a -> OrderedList a -> OrderedList a)
-> Ord (OrderedList a)
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
$ccompare :: forall a. Ord a => OrderedList a -> OrderedList a -> Ordering
compare :: OrderedList a -> OrderedList a -> Ordering
$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
>= :: OrderedList a -> OrderedList a -> Bool
$cmax :: forall a. Ord a => OrderedList a -> OrderedList a -> OrderedList a
max :: OrderedList a -> OrderedList a -> OrderedList a
$cmin :: forall a. Ord a => OrderedList a -> OrderedList a -> OrderedList a
min :: OrderedList a -> OrderedList a -> OrderedList a
Ord, Int -> OrderedList a -> ShowS
[OrderedList a] -> ShowS
OrderedList a -> String
(Int -> OrderedList a -> ShowS)
-> (OrderedList a -> String)
-> ([OrderedList a] -> ShowS)
-> Show (OrderedList a)
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
$cshowsPrec :: forall a. Show a => Int -> OrderedList a -> ShowS
showsPrec :: Int -> OrderedList a -> ShowS
$cshow :: forall a. Show a => OrderedList a -> String
show :: OrderedList a -> String
$cshowList :: forall a. Show a => [OrderedList a] -> ShowS
showList :: [OrderedList a] -> ShowS
Show, ReadPrec [OrderedList a]
ReadPrec (OrderedList a)
Int -> ReadS (OrderedList a)
ReadS [OrderedList a]
(Int -> ReadS (OrderedList a))
-> ReadS [OrderedList a]
-> ReadPrec (OrderedList a)
-> ReadPrec [OrderedList a]
-> Read (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
$creadsPrec :: forall a. Read a => Int -> ReadS (OrderedList a)
readsPrec :: Int -> ReadS (OrderedList a)
$creadList :: forall a. Read a => ReadS [OrderedList a]
readList :: ReadS [OrderedList a]
$creadPrec :: forall a. Read a => ReadPrec (OrderedList a)
readPrec :: ReadPrec (OrderedList a)
$creadListPrec :: forall a. Read a => ReadPrec [OrderedList a]
readListPrec :: ReadPrec [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) = [b] -> OrderedList b
forall a. [a] -> OrderedList a
Ordered ((a -> b) -> [a] -> [b]
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 = [a] -> OrderedList a
forall a. [a] -> OrderedList a
Ordered ([a] -> OrderedList a) -> Gen [a] -> Gen (OrderedList a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen [a]
forall a. (Ord a, Arbitrary a) => Gen [a]
orderedList

  shrink :: OrderedList a -> [OrderedList a]
shrink (Ordered [a]
xs) =
    [ [a] -> OrderedList a
forall a. [a] -> OrderedList a
Ordered [a]
xs'
    | [a]
xs' <- [a] -> [[a]]
forall a. Arbitrary a => a -> [a]
shrink [a]
xs
    , [a] -> [a]
forall a. Ord a => [a] -> [a]
sort [a]
xs' [a] -> [a] -> Bool
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
(NonEmptyList a -> NonEmptyList a -> Bool)
-> (NonEmptyList a -> NonEmptyList a -> Bool)
-> Eq (NonEmptyList a)
forall a. Eq a => NonEmptyList a -> NonEmptyList a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: NonEmptyList a -> NonEmptyList a -> Bool
Eq, Eq (NonEmptyList a)
Eq (NonEmptyList a) =>
(NonEmptyList a -> NonEmptyList a -> Ordering)
-> (NonEmptyList a -> NonEmptyList a -> Bool)
-> (NonEmptyList a -> NonEmptyList a -> Bool)
-> (NonEmptyList a -> NonEmptyList a -> Bool)
-> (NonEmptyList a -> NonEmptyList a -> Bool)
-> (NonEmptyList a -> NonEmptyList a -> NonEmptyList a)
-> (NonEmptyList a -> NonEmptyList a -> NonEmptyList a)
-> Ord (NonEmptyList a)
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
$ccompare :: forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Ordering
compare :: NonEmptyList a -> NonEmptyList a -> Ordering
$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
>= :: NonEmptyList a -> NonEmptyList a -> Bool
$cmax :: forall a.
Ord a =>
NonEmptyList a -> NonEmptyList a -> NonEmptyList a
max :: NonEmptyList a -> NonEmptyList a -> NonEmptyList a
$cmin :: forall a.
Ord a =>
NonEmptyList a -> NonEmptyList a -> NonEmptyList a
min :: NonEmptyList a -> NonEmptyList a -> NonEmptyList a
Ord, Int -> NonEmptyList a -> ShowS
[NonEmptyList a] -> ShowS
NonEmptyList a -> String
(Int -> NonEmptyList a -> ShowS)
-> (NonEmptyList a -> String)
-> ([NonEmptyList a] -> ShowS)
-> Show (NonEmptyList a)
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
$cshowsPrec :: forall a. Show a => Int -> NonEmptyList a -> ShowS
showsPrec :: Int -> NonEmptyList a -> ShowS
$cshow :: forall a. Show a => NonEmptyList a -> String
show :: NonEmptyList a -> String
$cshowList :: forall a. Show a => [NonEmptyList a] -> ShowS
showList :: [NonEmptyList a] -> ShowS
Show, ReadPrec [NonEmptyList a]
ReadPrec (NonEmptyList a)
Int -> ReadS (NonEmptyList a)
ReadS [NonEmptyList a]
(Int -> ReadS (NonEmptyList a))
-> ReadS [NonEmptyList a]
-> ReadPrec (NonEmptyList a)
-> ReadPrec [NonEmptyList a]
-> Read (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
$creadsPrec :: forall a. Read a => Int -> ReadS (NonEmptyList a)
readsPrec :: Int -> ReadS (NonEmptyList a)
$creadList :: forall a. Read a => ReadS [NonEmptyList a]
readList :: ReadS [NonEmptyList a]
$creadPrec :: forall a. Read a => ReadPrec (NonEmptyList a)
readPrec :: ReadPrec (NonEmptyList a)
$creadListPrec :: forall a. Read a => ReadPrec [NonEmptyList a]
readListPrec :: ReadPrec [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) = [b] -> NonEmptyList b
forall a. [a] -> NonEmptyList a
NonEmpty ((a -> b) -> [a] -> [b]
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 = [a] -> NonEmptyList a
forall a. [a] -> NonEmptyList a
NonEmpty ([a] -> NonEmptyList a) -> Gen [a] -> Gen (NonEmptyList a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` (Gen [a]
forall a. Arbitrary a => Gen a
arbitrary Gen [a] -> ([a] -> Bool) -> Gen [a]
forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (Bool -> Bool
not (Bool -> Bool) -> ([a] -> Bool) -> [a] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null))

  shrink :: NonEmptyList a -> [NonEmptyList a]
shrink (NonEmpty [a]
xs) =
    [ [a] -> NonEmptyList a
forall a. [a] -> NonEmptyList a
NonEmpty [a]
xs'
    | [a]
xs' <- [a] -> [[a]]
forall a. Arbitrary a => a -> [a]
shrink [a]
xs
    , Bool -> Bool
not ([a] -> Bool
forall a. [a] -> Bool
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) = [a] -> InfiniteListInternalData a -> InfiniteList a
forall a. [a] -> InfiniteListInternalData a -> InfiniteList a
InfiniteList [a]
xs InfiniteListInternalData a
info
infiniteListFromData info :: InfiniteListInternalData a
info@(FinitePrefix [a]
xs) =
  [a] -> InfiniteListInternalData a -> InfiniteList a
forall a. [a] -> InfiniteListInternalData a -> InfiniteList a
InfiniteList ([a]
xs [a] -> [a] -> [a]
forall a. [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>" String -> ShowS
forall a. [a] -> [a] -> [a]
++)
  showsPrec Int
n (InfiniteList [a]
_ (FinitePrefix [a]
xs)) =
    (if Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10 then (Char
'('Char -> ShowS
forall a. a -> [a] -> [a]
:) else ShowS
forall a. a -> a
id) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
    Int -> [a] -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
0 [a]
xs ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
    (String
" ++ ..." String -> ShowS
forall a. [a] -> [a] -> [a]
++) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
    (if Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10 then (Char
')'Char -> ShowS
forall a. a -> [a] -> [a]
:) else ShowS
forall a. a -> a
id)

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

instance Arbitrary a => Arbitrary (InfiniteListInternalData a) where
  arbitrary :: Gen (InfiniteListInternalData a)
arbitrary = ([a] -> InfiniteListInternalData a)
-> Gen [a] -> Gen (InfiniteListInternalData a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [a] -> InfiniteListInternalData a
forall a. [a] -> InfiniteListInternalData a
Infinite Gen [a]
forall a. Arbitrary a => Gen [a]
infiniteList
  shrink :: InfiniteListInternalData a -> [InfiniteListInternalData a]
shrink (Infinite [a]
xs) =
    [[a] -> InfiniteListInternalData a
forall a. [a] -> InfiniteListInternalData a
FinitePrefix (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
take Int
n [a]
xs) | Int
n <- (Integer -> Int) -> [Integer] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map (Int
2Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^) [Integer
0..]]
  shrink (FinitePrefix [a]
xs) =
    ([a] -> InfiniteListInternalData a)
-> [[a]] -> [InfiniteListInternalData a]
forall a b. (a -> b) -> [a] -> [b]
map [a] -> InfiniteListInternalData a
forall a. [a] -> InfiniteListInternalData a
FinitePrefix ([a] -> [[a]]
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
(SortedList a -> SortedList a -> Bool)
-> (SortedList a -> SortedList a -> Bool) -> Eq (SortedList a)
forall a. Eq a => SortedList a -> SortedList a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: SortedList a -> SortedList a -> Bool
Eq, Eq (SortedList a)
Eq (SortedList a) =>
(SortedList a -> SortedList a -> Ordering)
-> (SortedList a -> SortedList a -> Bool)
-> (SortedList a -> SortedList a -> Bool)
-> (SortedList a -> SortedList a -> Bool)
-> (SortedList a -> SortedList a -> Bool)
-> (SortedList a -> SortedList a -> SortedList a)
-> (SortedList a -> SortedList a -> SortedList a)
-> Ord (SortedList a)
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
$ccompare :: forall a. Ord a => SortedList a -> SortedList a -> Ordering
compare :: SortedList a -> SortedList a -> Ordering
$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
>= :: SortedList a -> SortedList a -> Bool
$cmax :: forall a. Ord a => SortedList a -> SortedList a -> SortedList a
max :: SortedList a -> SortedList a -> SortedList a
$cmin :: forall a. Ord a => SortedList a -> SortedList a -> SortedList a
min :: SortedList a -> SortedList a -> SortedList a
Ord, Int -> SortedList a -> ShowS
[SortedList a] -> ShowS
SortedList a -> String
(Int -> SortedList a -> ShowS)
-> (SortedList a -> String)
-> ([SortedList a] -> ShowS)
-> Show (SortedList a)
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
$cshowsPrec :: forall a. Show a => Int -> SortedList a -> ShowS
showsPrec :: Int -> SortedList a -> ShowS
$cshow :: forall a. Show a => SortedList a -> String
show :: SortedList a -> String
$cshowList :: forall a. Show a => [SortedList a] -> ShowS
showList :: [SortedList a] -> ShowS
Show, ReadPrec [SortedList a]
ReadPrec (SortedList a)
Int -> ReadS (SortedList a)
ReadS [SortedList a]
(Int -> ReadS (SortedList a))
-> ReadS [SortedList a]
-> ReadPrec (SortedList a)
-> ReadPrec [SortedList a]
-> Read (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
$creadsPrec :: forall a. Read a => Int -> ReadS (SortedList a)
readsPrec :: Int -> ReadS (SortedList a)
$creadList :: forall a. Read a => ReadS [SortedList a]
readList :: ReadS [SortedList a]
$creadPrec :: forall a. Read a => ReadPrec (SortedList a)
readPrec :: ReadPrec (SortedList a)
$creadListPrec :: forall a. Read a => ReadPrec [SortedList a]
readListPrec :: ReadPrec [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) = [b] -> SortedList b
forall a. [a] -> SortedList a
Sorted ((a -> b) -> [a] -> [b]
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 = ([a] -> SortedList a) -> Gen [a] -> Gen (SortedList a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([a] -> SortedList a
forall a. [a] -> SortedList a
Sorted ([a] -> SortedList a) -> ([a] -> [a]) -> [a] -> SortedList a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> [a]
forall a. Ord a => [a] -> [a]
sort) Gen [a]
forall a. Arbitrary a => Gen a
arbitrary

  shrink :: SortedList a -> [SortedList a]
shrink (Sorted [a]
xs) =
    [ [a] -> SortedList a
forall a. [a] -> SortedList a
Sorted [a]
xs'
    | [a]
xs' <- ([a] -> [a]) -> [[a]] -> [[a]]
forall a b. (a -> b) -> [a] -> [b]
map [a] -> [a]
forall a. Ord a => [a] -> [a]
sort ([a] -> [[a]]
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
(Positive a -> Positive a -> Bool)
-> (Positive a -> Positive a -> Bool) -> Eq (Positive a)
forall a. Eq a => Positive a -> Positive a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: Positive a -> Positive a -> Bool
Eq, Eq (Positive a)
Eq (Positive a) =>
(Positive a -> Positive a -> Ordering)
-> (Positive a -> Positive a -> Bool)
-> (Positive a -> Positive a -> Bool)
-> (Positive a -> Positive a -> Bool)
-> (Positive a -> Positive a -> Bool)
-> (Positive a -> Positive a -> Positive a)
-> (Positive a -> Positive a -> Positive a)
-> Ord (Positive a)
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
$ccompare :: forall a. Ord a => Positive a -> Positive a -> Ordering
compare :: Positive a -> Positive a -> Ordering
$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
>= :: Positive a -> Positive a -> Bool
$cmax :: forall a. Ord a => Positive a -> Positive a -> Positive a
max :: Positive a -> Positive a -> Positive a
$cmin :: forall a. Ord a => Positive a -> Positive a -> Positive a
min :: Positive a -> Positive a -> Positive a
Ord, Int -> Positive a -> ShowS
[Positive a] -> ShowS
Positive a -> String
(Int -> Positive a -> ShowS)
-> (Positive a -> String)
-> ([Positive a] -> ShowS)
-> Show (Positive a)
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
$cshowsPrec :: forall a. Show a => Int -> Positive a -> ShowS
showsPrec :: Int -> Positive a -> ShowS
$cshow :: forall a. Show a => Positive a -> String
show :: Positive a -> String
$cshowList :: forall a. Show a => [Positive a] -> ShowS
showList :: [Positive a] -> ShowS
Show, ReadPrec [Positive a]
ReadPrec (Positive a)
Int -> ReadS (Positive a)
ReadS [Positive a]
(Int -> ReadS (Positive a))
-> ReadS [Positive a]
-> ReadPrec (Positive a)
-> ReadPrec [Positive a]
-> Read (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
$creadsPrec :: forall a. Read a => Int -> ReadS (Positive a)
readsPrec :: Int -> ReadS (Positive a)
$creadList :: forall a. Read a => ReadS [Positive a]
readList :: ReadS [Positive a]
$creadPrec :: forall a. Read a => ReadPrec (Positive a)
readPrec :: ReadPrec (Positive a)
$creadListPrec :: forall a. Read a => ReadPrec [Positive a]
readListPrec :: ReadPrec [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]
(Positive a -> Positive a)
-> (Positive a -> Positive a)
-> (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 -> [Positive a])
-> Enum (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
$csucc :: forall a. Enum a => Positive a -> Positive a
succ :: Positive a -> Positive a
$cpred :: forall a. Enum a => Positive a -> Positive a
pred :: Positive a -> Positive a
$ctoEnum :: forall a. Enum a => Int -> Positive a
toEnum :: Int -> Positive a
$cfromEnum :: forall a. Enum a => Positive a -> Int
fromEnum :: Positive a -> Int
$cenumFrom :: forall a. Enum a => Positive a -> [Positive a]
enumFrom :: Positive a -> [Positive a]
$cenumFromThen :: forall a. Enum a => Positive a -> Positive a -> [Positive a]
enumFromThen :: Positive a -> Positive a -> [Positive a]
$cenumFromTo :: forall a. Enum a => Positive a -> Positive a -> [Positive a]
enumFromTo :: Positive a -> Positive a -> [Positive a]
$cenumFromThenTo :: forall a.
Enum a =>
Positive a -> Positive a -> Positive a -> [Positive a]
enumFromThenTo :: Positive a -> Positive 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) = b -> Positive b
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 = (a -> Positive a) -> Gen a -> Gen (Positive a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Positive a
forall a. a -> Positive a
Positive ((a -> a) -> Gen a -> Gen a
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
abs Gen a
forall a. Arbitrary a => Gen a
arbitrary Gen a -> (a -> Bool) -> Gen a
forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (a -> a -> Bool
forall a. Ord a => a -> a -> Bool
> a
0))
  shrink :: Positive a -> [Positive a]
shrink (Positive a
x) = [ a -> Positive a
forall a. a -> Positive a
Positive a
x' | a
x' <- a -> [a]
forall a. Arbitrary a => a -> [a]
shrink a
x , a
x' a -> a -> Bool
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
(Negative a -> Negative a -> Bool)
-> (Negative a -> Negative a -> Bool) -> Eq (Negative a)
forall a. Eq a => Negative a -> Negative a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: Negative a -> Negative a -> Bool
Eq, Eq (Negative a)
Eq (Negative a) =>
(Negative a -> Negative a -> Ordering)
-> (Negative a -> Negative a -> Bool)
-> (Negative a -> Negative a -> Bool)
-> (Negative a -> Negative a -> Bool)
-> (Negative a -> Negative a -> Bool)
-> (Negative a -> Negative a -> Negative a)
-> (Negative a -> Negative a -> Negative a)
-> Ord (Negative a)
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
$ccompare :: forall a. Ord a => Negative a -> Negative a -> Ordering
compare :: Negative a -> Negative a -> Ordering
$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
>= :: Negative a -> Negative a -> Bool
$cmax :: forall a. Ord a => Negative a -> Negative a -> Negative a
max :: Negative a -> Negative a -> Negative a
$cmin :: forall a. Ord a => Negative a -> Negative a -> Negative a
min :: Negative a -> Negative a -> Negative a
Ord, Int -> Negative a -> ShowS
[Negative a] -> ShowS
Negative a -> String
(Int -> Negative a -> ShowS)
-> (Negative a -> String)
-> ([Negative a] -> ShowS)
-> Show (Negative a)
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
$cshowsPrec :: forall a. Show a => Int -> Negative a -> ShowS
showsPrec :: Int -> Negative a -> ShowS
$cshow :: forall a. Show a => Negative a -> String
show :: Negative a -> String
$cshowList :: forall a. Show a => [Negative a] -> ShowS
showList :: [Negative a] -> ShowS
Show, ReadPrec [Negative a]
ReadPrec (Negative a)
Int -> ReadS (Negative a)
ReadS [Negative a]
(Int -> ReadS (Negative a))
-> ReadS [Negative a]
-> ReadPrec (Negative a)
-> ReadPrec [Negative a]
-> Read (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
$creadsPrec :: forall a. Read a => Int -> ReadS (Negative a)
readsPrec :: Int -> ReadS (Negative a)
$creadList :: forall a. Read a => ReadS [Negative a]
readList :: ReadS [Negative a]
$creadPrec :: forall a. Read a => ReadPrec (Negative a)
readPrec :: ReadPrec (Negative a)
$creadListPrec :: forall a. Read a => ReadPrec [Negative a]
readListPrec :: ReadPrec [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]
(Negative a -> Negative a)
-> (Negative a -> Negative a)
-> (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 -> [Negative a])
-> Enum (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
$csucc :: forall a. Enum a => Negative a -> Negative a
succ :: Negative a -> Negative a
$cpred :: forall a. Enum a => Negative a -> Negative a
pred :: Negative a -> Negative a
$ctoEnum :: forall a. Enum a => Int -> Negative a
toEnum :: Int -> Negative a
$cfromEnum :: forall a. Enum a => Negative a -> Int
fromEnum :: Negative a -> Int
$cenumFrom :: forall a. Enum a => Negative a -> [Negative a]
enumFrom :: Negative a -> [Negative a]
$cenumFromThen :: forall a. Enum a => Negative a -> Negative a -> [Negative a]
enumFromThen :: Negative a -> Negative a -> [Negative a]
$cenumFromTo :: forall a. Enum a => Negative a -> Negative a -> [Negative a]
enumFromTo :: Negative a -> Negative a -> [Negative a]
$cenumFromThenTo :: forall a.
Enum a =>
Negative a -> Negative a -> Negative a -> [Negative a]
enumFromThenTo :: Negative a -> Negative 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) = b -> Negative b
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 = (a -> Negative a) -> Gen a -> Gen (Negative a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Negative a
forall a. a -> Negative a
Negative ((a -> a) -> Gen a -> Gen a
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> a
forall a. Num a => a -> a
negate (a -> a) -> (a -> a) -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a
forall a. Num a => a -> a
abs) Gen a
forall a. Arbitrary a => Gen a
arbitrary Gen a -> (a -> Bool) -> Gen a
forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
0))
  shrink :: Negative a -> [Negative a]
shrink (Negative a
x) = [ a -> Negative a
forall a. a -> Negative a
Negative a
x' | a
x' <- a -> [a]
forall a. Arbitrary a => a -> [a]
shrink a
x , a
x' a -> a -> Bool
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
(NonZero a -> NonZero a -> Bool)
-> (NonZero a -> NonZero a -> Bool) -> Eq (NonZero a)
forall a. Eq a => NonZero a -> NonZero a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: NonZero a -> NonZero a -> Bool
Eq, Eq (NonZero a)
Eq (NonZero a) =>
(NonZero a -> NonZero a -> Ordering)
-> (NonZero a -> NonZero a -> Bool)
-> (NonZero a -> NonZero a -> Bool)
-> (NonZero a -> NonZero a -> Bool)
-> (NonZero a -> NonZero a -> Bool)
-> (NonZero a -> NonZero a -> NonZero a)
-> (NonZero a -> NonZero a -> NonZero a)
-> Ord (NonZero a)
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
$ccompare :: forall a. Ord a => NonZero a -> NonZero a -> Ordering
compare :: NonZero a -> NonZero a -> Ordering
$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
>= :: NonZero a -> NonZero a -> Bool
$cmax :: forall a. Ord a => NonZero a -> NonZero a -> NonZero a
max :: NonZero a -> NonZero a -> NonZero a
$cmin :: forall a. Ord a => NonZero a -> NonZero a -> NonZero a
min :: NonZero a -> NonZero a -> NonZero a
Ord, Int -> NonZero a -> ShowS
[NonZero a] -> ShowS
NonZero a -> String
(Int -> NonZero a -> ShowS)
-> (NonZero a -> String)
-> ([NonZero a] -> ShowS)
-> Show (NonZero a)
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
$cshowsPrec :: forall a. Show a => Int -> NonZero a -> ShowS
showsPrec :: Int -> NonZero a -> ShowS
$cshow :: forall a. Show a => NonZero a -> String
show :: NonZero a -> String
$cshowList :: forall a. Show a => [NonZero a] -> ShowS
showList :: [NonZero a] -> ShowS
Show, ReadPrec [NonZero a]
ReadPrec (NonZero a)
Int -> ReadS (NonZero a)
ReadS [NonZero a]
(Int -> ReadS (NonZero a))
-> ReadS [NonZero a]
-> ReadPrec (NonZero a)
-> ReadPrec [NonZero a]
-> Read (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
$creadsPrec :: forall a. Read a => Int -> ReadS (NonZero a)
readsPrec :: Int -> ReadS (NonZero a)
$creadList :: forall a. Read a => ReadS [NonZero a]
readList :: ReadS [NonZero a]
$creadPrec :: forall a. Read a => ReadPrec (NonZero a)
readPrec :: ReadPrec (NonZero a)
$creadListPrec :: forall a. Read a => ReadPrec [NonZero a]
readListPrec :: ReadPrec [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]
(NonZero a -> NonZero a)
-> (NonZero a -> NonZero a)
-> (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 -> [NonZero a])
-> Enum (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
$csucc :: forall a. Enum a => NonZero a -> NonZero a
succ :: NonZero a -> NonZero a
$cpred :: forall a. Enum a => NonZero a -> NonZero a
pred :: NonZero a -> NonZero a
$ctoEnum :: forall a. Enum a => Int -> NonZero a
toEnum :: Int -> NonZero a
$cfromEnum :: forall a. Enum a => NonZero a -> Int
fromEnum :: NonZero a -> Int
$cenumFrom :: forall a. Enum a => NonZero a -> [NonZero a]
enumFrom :: NonZero a -> [NonZero a]
$cenumFromThen :: forall a. Enum a => NonZero a -> NonZero a -> [NonZero a]
enumFromThen :: NonZero a -> NonZero a -> [NonZero a]
$cenumFromTo :: forall a. Enum a => NonZero a -> NonZero a -> [NonZero a]
enumFromTo :: NonZero a -> NonZero a -> [NonZero a]
$cenumFromThenTo :: forall a.
Enum a =>
NonZero a -> NonZero a -> NonZero a -> [NonZero a]
enumFromThenTo :: NonZero a -> NonZero 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) = b -> NonZero b
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 = (a -> NonZero a) -> Gen a -> Gen (NonZero a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> NonZero a
forall a. a -> NonZero a
NonZero (Gen a -> Gen (NonZero a)) -> Gen a -> Gen (NonZero a)
forall a b. (a -> b) -> a -> b
$ Gen a
forall a. Arbitrary a => Gen a
arbitrary Gen a -> (a -> Bool) -> Gen a
forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (a -> a -> Bool
forall a. Eq a => a -> a -> Bool
/= a
0)

  shrink :: NonZero a -> [NonZero a]
shrink (NonZero a
x) = [ a -> NonZero a
forall a. a -> NonZero a
NonZero a
x' | a
x' <- a -> [a]
forall a. Arbitrary a => a -> [a]
shrink a
x, a
x' a -> a -> Bool
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
(NonNegative a -> NonNegative a -> Bool)
-> (NonNegative a -> NonNegative a -> Bool) -> Eq (NonNegative a)
forall a. Eq a => NonNegative a -> NonNegative a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: NonNegative a -> NonNegative a -> Bool
Eq, Eq (NonNegative a)
Eq (NonNegative a) =>
(NonNegative a -> NonNegative a -> Ordering)
-> (NonNegative a -> NonNegative a -> Bool)
-> (NonNegative a -> NonNegative a -> Bool)
-> (NonNegative a -> NonNegative a -> Bool)
-> (NonNegative a -> NonNegative a -> Bool)
-> (NonNegative a -> NonNegative a -> NonNegative a)
-> (NonNegative a -> NonNegative a -> NonNegative a)
-> Ord (NonNegative a)
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
$ccompare :: forall a. Ord a => NonNegative a -> NonNegative a -> Ordering
compare :: NonNegative a -> NonNegative a -> Ordering
$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
>= :: NonNegative a -> NonNegative a -> Bool
$cmax :: forall a. Ord a => NonNegative a -> NonNegative a -> NonNegative a
max :: NonNegative a -> NonNegative a -> NonNegative a
$cmin :: forall a. Ord a => NonNegative a -> NonNegative a -> NonNegative a
min :: NonNegative a -> NonNegative a -> NonNegative a
Ord, Int -> NonNegative a -> ShowS
[NonNegative a] -> ShowS
NonNegative a -> String
(Int -> NonNegative a -> ShowS)
-> (NonNegative a -> String)
-> ([NonNegative a] -> ShowS)
-> Show (NonNegative a)
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
$cshowsPrec :: forall a. Show a => Int -> NonNegative a -> ShowS
showsPrec :: Int -> NonNegative a -> ShowS
$cshow :: forall a. Show a => NonNegative a -> String
show :: NonNegative a -> String
$cshowList :: forall a. Show a => [NonNegative a] -> ShowS
showList :: [NonNegative a] -> ShowS
Show, ReadPrec [NonNegative a]
ReadPrec (NonNegative a)
Int -> ReadS (NonNegative a)
ReadS [NonNegative a]
(Int -> ReadS (NonNegative a))
-> ReadS [NonNegative a]
-> ReadPrec (NonNegative a)
-> ReadPrec [NonNegative a]
-> Read (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
$creadsPrec :: forall a. Read a => Int -> ReadS (NonNegative a)
readsPrec :: Int -> ReadS (NonNegative a)
$creadList :: forall a. Read a => ReadS [NonNegative a]
readList :: ReadS [NonNegative a]
$creadPrec :: forall a. Read a => ReadPrec (NonNegative a)
readPrec :: ReadPrec (NonNegative a)
$creadListPrec :: forall a. Read a => ReadPrec [NonNegative a]
readListPrec :: ReadPrec [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]
(NonNegative a -> NonNegative a)
-> (NonNegative a -> NonNegative a)
-> (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 -> [NonNegative a])
-> Enum (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
$csucc :: forall a. Enum a => NonNegative a -> NonNegative a
succ :: NonNegative a -> NonNegative a
$cpred :: forall a. Enum a => NonNegative a -> NonNegative a
pred :: NonNegative a -> NonNegative a
$ctoEnum :: forall a. Enum a => Int -> NonNegative a
toEnum :: Int -> NonNegative a
$cfromEnum :: forall a. Enum a => NonNegative a -> Int
fromEnum :: NonNegative a -> Int
$cenumFrom :: forall a. Enum a => NonNegative a -> [NonNegative a]
enumFrom :: NonNegative a -> [NonNegative a]
$cenumFromThen :: forall a.
Enum a =>
NonNegative a -> NonNegative a -> [NonNegative a]
enumFromThen :: NonNegative a -> NonNegative a -> [NonNegative a]
$cenumFromTo :: forall a.
Enum a =>
NonNegative a -> NonNegative a -> [NonNegative a]
enumFromTo :: NonNegative a -> NonNegative a -> [NonNegative a]
$cenumFromThenTo :: forall a.
Enum a =>
NonNegative a -> NonNegative a -> NonNegative a -> [NonNegative a]
enumFromThenTo :: NonNegative a -> NonNegative 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) = b -> NonNegative b
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 = (a -> NonNegative a) -> Gen a -> Gen (NonNegative a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> NonNegative a
forall a. a -> NonNegative a
NonNegative ((a -> a) -> Gen a -> Gen a
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
abs Gen a
forall a. Arbitrary a => Gen a
arbitrary Gen a -> (a -> Bool) -> Gen a
forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
0))
  shrink :: NonNegative a -> [NonNegative a]
shrink (NonNegative a
x) = [ a -> NonNegative a
forall a. a -> NonNegative a
NonNegative a
x' | a
x' <- a -> [a]
forall a. Arbitrary a => a -> [a]
shrink a
x , a
x' a -> a -> Bool
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
(NonPositive a -> NonPositive a -> Bool)
-> (NonPositive a -> NonPositive a -> Bool) -> Eq (NonPositive a)
forall a. Eq a => NonPositive a -> NonPositive a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: NonPositive a -> NonPositive a -> Bool
Eq, Eq (NonPositive a)
Eq (NonPositive a) =>
(NonPositive a -> NonPositive a -> Ordering)
-> (NonPositive a -> NonPositive a -> Bool)
-> (NonPositive a -> NonPositive a -> Bool)
-> (NonPositive a -> NonPositive a -> Bool)
-> (NonPositive a -> NonPositive a -> Bool)
-> (NonPositive a -> NonPositive a -> NonPositive a)
-> (NonPositive a -> NonPositive a -> NonPositive a)
-> Ord (NonPositive a)
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
$ccompare :: forall a. Ord a => NonPositive a -> NonPositive a -> Ordering
compare :: NonPositive a -> NonPositive a -> Ordering
$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
>= :: NonPositive a -> NonPositive a -> Bool
$cmax :: forall a. Ord a => NonPositive a -> NonPositive a -> NonPositive a
max :: NonPositive a -> NonPositive a -> NonPositive a
$cmin :: forall a. Ord a => NonPositive a -> NonPositive a -> NonPositive a
min :: NonPositive a -> NonPositive a -> NonPositive a
Ord, Int -> NonPositive a -> ShowS
[NonPositive a] -> ShowS
NonPositive a -> String
(Int -> NonPositive a -> ShowS)
-> (NonPositive a -> String)
-> ([NonPositive a] -> ShowS)
-> Show (NonPositive a)
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
$cshowsPrec :: forall a. Show a => Int -> NonPositive a -> ShowS
showsPrec :: Int -> NonPositive a -> ShowS
$cshow :: forall a. Show a => NonPositive a -> String
show :: NonPositive a -> String
$cshowList :: forall a. Show a => [NonPositive a] -> ShowS
showList :: [NonPositive a] -> ShowS
Show, ReadPrec [NonPositive a]
ReadPrec (NonPositive a)
Int -> ReadS (NonPositive a)
ReadS [NonPositive a]
(Int -> ReadS (NonPositive a))
-> ReadS [NonPositive a]
-> ReadPrec (NonPositive a)
-> ReadPrec [NonPositive a]
-> Read (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
$creadsPrec :: forall a. Read a => Int -> ReadS (NonPositive a)
readsPrec :: Int -> ReadS (NonPositive a)
$creadList :: forall a. Read a => ReadS [NonPositive a]
readList :: ReadS [NonPositive a]
$creadPrec :: forall a. Read a => ReadPrec (NonPositive a)
readPrec :: ReadPrec (NonPositive a)
$creadListPrec :: forall a. Read a => ReadPrec [NonPositive a]
readListPrec :: ReadPrec [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]
(NonPositive a -> NonPositive a)
-> (NonPositive a -> NonPositive a)
-> (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 -> [NonPositive a])
-> Enum (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
$csucc :: forall a. Enum a => NonPositive a -> NonPositive a
succ :: NonPositive a -> NonPositive a
$cpred :: forall a. Enum a => NonPositive a -> NonPositive a
pred :: NonPositive a -> NonPositive a
$ctoEnum :: forall a. Enum a => Int -> NonPositive a
toEnum :: Int -> NonPositive a
$cfromEnum :: forall a. Enum a => NonPositive a -> Int
fromEnum :: NonPositive a -> Int
$cenumFrom :: forall a. Enum a => NonPositive a -> [NonPositive a]
enumFrom :: NonPositive a -> [NonPositive a]
$cenumFromThen :: forall a.
Enum a =>
NonPositive a -> NonPositive a -> [NonPositive a]
enumFromThen :: NonPositive a -> NonPositive a -> [NonPositive a]
$cenumFromTo :: forall a.
Enum a =>
NonPositive a -> NonPositive a -> [NonPositive a]
enumFromTo :: NonPositive a -> NonPositive a -> [NonPositive a]
$cenumFromThenTo :: forall a.
Enum a =>
NonPositive a -> NonPositive a -> NonPositive a -> [NonPositive a]
enumFromThenTo :: NonPositive a -> NonPositive 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) = b -> NonPositive b
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 = (a -> NonPositive a) -> Gen a -> Gen (NonPositive a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> NonPositive a
forall a. a -> NonPositive a
NonPositive (Gen a
forall a. Arbitrary a => Gen a
arbitrary Gen a -> (a -> Bool) -> Gen a
forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
0))
  shrink :: NonPositive a -> [NonPositive a]
shrink (NonPositive a
x) = [ a -> NonPositive a
forall a. a -> NonPositive a
NonPositive a
x' | a
x' <- a -> [a]
forall a. Arbitrary a => a -> [a]
shrink a
x , a
x' a -> a -> Bool
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
(Large a -> Large a -> Bool)
-> (Large a -> Large a -> Bool) -> Eq (Large a)
forall a. Eq a => Large a -> Large a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: Large a -> Large a -> Bool
Eq, Eq (Large a)
Eq (Large a) =>
(Large a -> Large a -> Ordering)
-> (Large a -> Large a -> Bool)
-> (Large a -> Large a -> Bool)
-> (Large a -> Large a -> Bool)
-> (Large a -> Large a -> Bool)
-> (Large a -> Large a -> Large a)
-> (Large a -> Large a -> Large a)
-> Ord (Large a)
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
$ccompare :: forall a. Ord a => Large a -> Large a -> Ordering
compare :: Large a -> Large a -> Ordering
$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
>= :: Large a -> Large a -> Bool
$cmax :: forall a. Ord a => Large a -> Large a -> Large a
max :: Large a -> Large a -> Large a
$cmin :: forall a. Ord a => Large a -> Large a -> Large a
min :: Large a -> Large a -> Large a
Ord, Int -> Large a -> ShowS
[Large a] -> ShowS
Large a -> String
(Int -> Large a -> ShowS)
-> (Large a -> String) -> ([Large a] -> ShowS) -> Show (Large a)
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
$cshowsPrec :: forall a. Show a => Int -> Large a -> ShowS
showsPrec :: Int -> Large a -> ShowS
$cshow :: forall a. Show a => Large a -> String
show :: Large a -> String
$cshowList :: forall a. Show a => [Large a] -> ShowS
showList :: [Large a] -> ShowS
Show, ReadPrec [Large a]
ReadPrec (Large a)
Int -> ReadS (Large a)
ReadS [Large a]
(Int -> ReadS (Large a))
-> ReadS [Large a]
-> ReadPrec (Large a)
-> ReadPrec [Large a]
-> Read (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
$creadsPrec :: forall a. Read a => Int -> ReadS (Large a)
readsPrec :: Int -> ReadS (Large a)
$creadList :: forall a. Read a => ReadS [Large a]
readList :: ReadS [Large a]
$creadPrec :: forall a. Read a => ReadPrec (Large a)
readPrec :: ReadPrec (Large a)
$creadListPrec :: forall a. Read a => ReadPrec [Large a]
readListPrec :: ReadPrec [Large a]
Read
#ifndef NO_NEWTYPE_DERIVING
          , Integer -> Large a
Large a -> Large a
Large a -> Large a -> Large a
(Large a -> Large a -> Large a)
-> (Large a -> Large a -> Large a)
-> (Large a -> Large a -> Large a)
-> (Large a -> Large a)
-> (Large a -> Large a)
-> (Large a -> Large a)
-> (Integer -> Large a)
-> Num (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
$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
* :: Large a -> Large a -> Large a
$cnegate :: forall a. Num a => Large a -> Large a
negate :: Large a -> Large a
$cabs :: forall a. Num a => Large a -> Large a
abs :: Large a -> Large a
$csignum :: forall a. Num a => Large a -> Large a
signum :: Large a -> Large a
$cfromInteger :: forall a. Num a => Integer -> Large a
fromInteger :: Integer -> Large a
Num, Enum (Large a)
Real (Large a)
(Real (Large a), Enum (Large a)) =>
(Large a -> Large a -> Large a)
-> (Large a -> Large a -> Large a)
-> (Large a -> Large a -> Large a)
-> (Large a -> Large a -> Large a)
-> (Large a -> Large a -> (Large a, Large a))
-> (Large a -> Large a -> (Large a, Large a))
-> (Large a -> Integer)
-> Integral (Large a)
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
$cquot :: forall a. Integral a => Large a -> Large a -> Large a
quot :: Large a -> Large a -> Large a
$crem :: forall a. Integral a => Large a -> Large a -> Large a
rem :: Large a -> Large a -> Large a
$cdiv :: forall a. Integral a => Large a -> Large a -> Large a
div :: Large a -> Large a -> Large a
$cmod :: forall a. Integral a => Large a -> Large a -> Large a
mod :: Large a -> Large a -> Large a
$cquotRem :: forall a. Integral a => Large a -> Large a -> (Large a, Large a)
quotRem :: Large a -> Large a -> (Large a, Large a)
$cdivMod :: forall a. Integral a => Large a -> Large a -> (Large a, Large a)
divMod :: Large a -> Large a -> (Large a, Large a)
$ctoInteger :: forall a. Integral a => Large a -> Integer
toInteger :: Large a -> Integer
Integral, Num (Large a)
Ord (Large a)
(Num (Large a), Ord (Large a)) =>
(Large a -> Rational) -> Real (Large a)
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
$ctoRational :: forall a. Real a => Large a -> Rational
toRational :: 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]
(Large a -> Large a)
-> (Large a -> Large a)
-> (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 -> [Large a])
-> Enum (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
$csucc :: forall a. Enum a => Large a -> Large a
succ :: Large a -> Large a
$cpred :: forall a. Enum a => Large a -> Large a
pred :: Large a -> Large a
$ctoEnum :: forall a. Enum a => Int -> Large a
toEnum :: Int -> Large a
$cfromEnum :: forall a. Enum a => Large a -> Int
fromEnum :: Large a -> Int
$cenumFrom :: forall a. Enum a => Large a -> [Large a]
enumFrom :: Large a -> [Large a]
$cenumFromThen :: forall a. Enum a => Large a -> Large a -> [Large a]
enumFromThen :: Large a -> Large a -> [Large a]
$cenumFromTo :: forall a. Enum a => Large a -> Large a -> [Large a]
enumFromTo :: Large a -> Large a -> [Large a]
$cenumFromThenTo :: forall a. Enum a => Large a -> Large a -> Large a -> [Large a]
enumFromThenTo :: Large a -> Large a -> Large a -> [Large a]
Enum, Ord (Large a)
Ord (Large a) =>
((Large a, Large a) -> [Large a])
-> ((Large a, Large a) -> Large a -> Int)
-> ((Large a, Large a) -> Large a -> Int)
-> ((Large a, Large a) -> Large a -> Bool)
-> ((Large a, Large a) -> Int)
-> ((Large a, Large a) -> Int)
-> Ix (Large a)
(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
$crange :: forall a. Ix a => (Large a, Large a) -> [Large a]
range :: (Large a, Large a) -> [Large a]
$cindex :: forall a. Ix a => (Large a, Large a) -> Large a -> Int
index :: (Large a, Large a) -> Large a -> Int
$cunsafeIndex :: forall a. Ix a => (Large a, Large a) -> Large a -> Int
unsafeIndex :: (Large a, Large a) -> Large a -> Int
$cinRange :: forall a. Ix a => (Large a, Large a) -> Large a -> Bool
inRange :: (Large a, Large a) -> Large a -> Bool
$crangeSize :: forall a. Ix a => (Large a, Large a) -> Int
rangeSize :: (Large a, Large a) -> Int
$cunsafeRangeSize :: forall a. Ix a => (Large a, Large a) -> Int
unsafeRangeSize :: (Large a, Large a) -> Int
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) = b -> Large b
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 = (a -> Large a) -> Gen a -> Gen (Large a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Large a
forall a. a -> Large a
Large Gen a
forall a. (Bounded a, Integral a) => Gen a
arbitrarySizedBoundedIntegral
  shrink :: Large a -> [Large a]
shrink (Large a
x) = (a -> Large a) -> [a] -> [Large a]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Large a
forall a. a -> Large a
Large (a -> [a]
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
(Small a -> Small a -> Bool)
-> (Small a -> Small a -> Bool) -> Eq (Small a)
forall a. Eq a => Small a -> Small a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: Small a -> Small a -> Bool
Eq, Eq (Small a)
Eq (Small a) =>
(Small a -> Small a -> Ordering)
-> (Small a -> Small a -> Bool)
-> (Small a -> Small a -> Bool)
-> (Small a -> Small a -> Bool)
-> (Small a -> Small a -> Bool)
-> (Small a -> Small a -> Small a)
-> (Small a -> Small a -> Small a)
-> Ord (Small a)
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
$ccompare :: forall a. Ord a => Small a -> Small a -> Ordering
compare :: Small a -> Small a -> Ordering
$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
>= :: Small a -> Small a -> Bool
$cmax :: forall a. Ord a => Small a -> Small a -> Small a
max :: Small a -> Small a -> Small a
$cmin :: forall a. Ord a => Small a -> Small a -> Small a
min :: Small a -> Small a -> Small a
Ord, Int -> Small a -> ShowS
[Small a] -> ShowS
Small a -> String
(Int -> Small a -> ShowS)
-> (Small a -> String) -> ([Small a] -> ShowS) -> Show (Small a)
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
$cshowsPrec :: forall a. Show a => Int -> Small a -> ShowS
showsPrec :: Int -> Small a -> ShowS
$cshow :: forall a. Show a => Small a -> String
show :: Small a -> String
$cshowList :: forall a. Show a => [Small a] -> ShowS
showList :: [Small a] -> ShowS
Show, ReadPrec [Small a]
ReadPrec (Small a)
Int -> ReadS (Small a)
ReadS [Small a]
(Int -> ReadS (Small a))
-> ReadS [Small a]
-> ReadPrec (Small a)
-> ReadPrec [Small a]
-> Read (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
$creadsPrec :: forall a. Read a => Int -> ReadS (Small a)
readsPrec :: Int -> ReadS (Small a)
$creadList :: forall a. Read a => ReadS [Small a]
readList :: ReadS [Small a]
$creadPrec :: forall a. Read a => ReadPrec (Small a)
readPrec :: ReadPrec (Small a)
$creadListPrec :: forall a. Read a => ReadPrec [Small a]
readListPrec :: ReadPrec [Small a]
Read
#ifndef NO_NEWTYPE_DERIVING
          , Integer -> Small a
Small a -> Small a
Small a -> Small a -> Small a
(Small a -> Small a -> Small a)
-> (Small a -> Small a -> Small a)
-> (Small a -> Small a -> Small a)
-> (Small a -> Small a)
-> (Small a -> Small a)
-> (Small a -> Small a)
-> (Integer -> Small a)
-> Num (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
$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
* :: Small a -> Small a -> Small a
$cnegate :: forall a. Num a => Small a -> Small a
negate :: Small a -> Small a
$cabs :: forall a. Num a => Small a -> Small a
abs :: Small a -> Small a
$csignum :: forall a. Num a => Small a -> Small a
signum :: Small a -> Small a
$cfromInteger :: forall a. Num a => Integer -> Small a
fromInteger :: Integer -> Small a
Num, Enum (Small a)
Real (Small a)
(Real (Small a), Enum (Small a)) =>
(Small a -> Small a -> Small a)
-> (Small a -> Small a -> Small a)
-> (Small a -> Small a -> Small a)
-> (Small a -> Small a -> Small a)
-> (Small a -> Small a -> (Small a, Small a))
-> (Small a -> Small a -> (Small a, Small a))
-> (Small a -> Integer)
-> Integral (Small a)
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
$cquot :: forall a. Integral a => Small a -> Small a -> Small a
quot :: Small a -> Small a -> Small a
$crem :: forall a. Integral a => Small a -> Small a -> Small a
rem :: Small a -> Small a -> Small a
$cdiv :: forall a. Integral a => Small a -> Small a -> Small a
div :: Small a -> Small a -> Small a
$cmod :: forall a. Integral a => Small a -> Small a -> Small a
mod :: Small a -> Small a -> Small a
$cquotRem :: forall a. Integral a => Small a -> Small a -> (Small a, Small a)
quotRem :: Small a -> Small a -> (Small a, Small a)
$cdivMod :: forall a. Integral a => Small a -> Small a -> (Small a, Small a)
divMod :: Small a -> Small a -> (Small a, Small a)
$ctoInteger :: forall a. Integral a => Small a -> Integer
toInteger :: Small a -> Integer
Integral, Num (Small a)
Ord (Small a)
(Num (Small a), Ord (Small a)) =>
(Small a -> Rational) -> Real (Small a)
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
$ctoRational :: forall a. Real a => Small a -> Rational
toRational :: 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]
(Small a -> Small a)
-> (Small a -> Small a)
-> (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 -> [Small a])
-> Enum (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
$csucc :: forall a. Enum a => Small a -> Small a
succ :: Small a -> Small a
$cpred :: forall a. Enum a => Small a -> Small a
pred :: Small a -> Small a
$ctoEnum :: forall a. Enum a => Int -> Small a
toEnum :: Int -> Small a
$cfromEnum :: forall a. Enum a => Small a -> Int
fromEnum :: Small a -> Int
$cenumFrom :: forall a. Enum a => Small a -> [Small a]
enumFrom :: Small a -> [Small a]
$cenumFromThen :: forall a. Enum a => Small a -> Small a -> [Small a]
enumFromThen :: Small a -> Small a -> [Small a]
$cenumFromTo :: forall a. Enum a => Small a -> Small a -> [Small a]
enumFromTo :: Small a -> Small a -> [Small a]
$cenumFromThenTo :: forall a. Enum a => Small a -> Small a -> Small a -> [Small a]
enumFromThenTo :: Small a -> Small a -> Small a -> [Small a]
Enum, Ord (Small a)
Ord (Small a) =>
((Small a, Small a) -> [Small a])
-> ((Small a, Small a) -> Small a -> Int)
-> ((Small a, Small a) -> Small a -> Int)
-> ((Small a, Small a) -> Small a -> Bool)
-> ((Small a, Small a) -> Int)
-> ((Small a, Small a) -> Int)
-> Ix (Small a)
(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
$crange :: forall a. Ix a => (Small a, Small a) -> [Small a]
range :: (Small a, Small a) -> [Small a]
$cindex :: forall a. Ix a => (Small a, Small a) -> Small a -> Int
index :: (Small a, Small a) -> Small a -> Int
$cunsafeIndex :: forall a. Ix a => (Small a, Small a) -> Small a -> Int
unsafeIndex :: (Small a, Small a) -> Small a -> Int
$cinRange :: forall a. Ix a => (Small a, Small a) -> Small a -> Bool
inRange :: (Small a, Small a) -> Small a -> Bool
$crangeSize :: forall a. Ix a => (Small a, Small a) -> Int
rangeSize :: (Small a, Small a) -> Int
$cunsafeRangeSize :: forall a. Ix a => (Small a, Small a) -> Int
unsafeRangeSize :: (Small a, Small a) -> Int
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) = b -> Small b
forall a. a -> Small a
Small (a -> b
f a
x)

instance Integral a => Arbitrary (Small a) where
  arbitrary :: Gen (Small a)
arbitrary = (a -> Small a) -> Gen a -> Gen (Small a)
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Small a
forall a. a -> Small a
Small Gen a
forall a. Integral a => Gen a
arbitrarySizedIntegral
  shrink :: Small a -> [Small a]
shrink (Small a
x) = (a -> Small a) -> [a] -> [Small a]
forall a b. (a -> b) -> [a] -> [b]
map a -> Small a
forall a. a -> Small a
Small (a -> [a]
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
(Shrink2 a -> Shrink2 a -> Bool)
-> (Shrink2 a -> Shrink2 a -> Bool) -> Eq (Shrink2 a)
forall a. Eq a => Shrink2 a -> Shrink2 a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: Shrink2 a -> Shrink2 a -> Bool
Eq, Eq (Shrink2 a)
Eq (Shrink2 a) =>
(Shrink2 a -> Shrink2 a -> Ordering)
-> (Shrink2 a -> Shrink2 a -> Bool)
-> (Shrink2 a -> Shrink2 a -> Bool)
-> (Shrink2 a -> Shrink2 a -> Bool)
-> (Shrink2 a -> Shrink2 a -> Bool)
-> (Shrink2 a -> Shrink2 a -> Shrink2 a)
-> (Shrink2 a -> Shrink2 a -> Shrink2 a)
-> Ord (Shrink2 a)
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
$ccompare :: forall a. Ord a => Shrink2 a -> Shrink2 a -> Ordering
compare :: Shrink2 a -> Shrink2 a -> Ordering
$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
>= :: Shrink2 a -> Shrink2 a -> Bool
$cmax :: forall a. Ord a => Shrink2 a -> Shrink2 a -> Shrink2 a
max :: Shrink2 a -> Shrink2 a -> Shrink2 a
$cmin :: forall a. Ord a => Shrink2 a -> Shrink2 a -> Shrink2 a
min :: Shrink2 a -> Shrink2 a -> Shrink2 a
Ord, Int -> Shrink2 a -> ShowS
[Shrink2 a] -> ShowS
Shrink2 a -> String
(Int -> Shrink2 a -> ShowS)
-> (Shrink2 a -> String)
-> ([Shrink2 a] -> ShowS)
-> Show (Shrink2 a)
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
$cshowsPrec :: forall a. Show a => Int -> Shrink2 a -> ShowS
showsPrec :: Int -> Shrink2 a -> ShowS
$cshow :: forall a. Show a => Shrink2 a -> String
show :: Shrink2 a -> String
$cshowList :: forall a. Show a => [Shrink2 a] -> ShowS
showList :: [Shrink2 a] -> ShowS
Show, ReadPrec [Shrink2 a]
ReadPrec (Shrink2 a)
Int -> ReadS (Shrink2 a)
ReadS [Shrink2 a]
(Int -> ReadS (Shrink2 a))
-> ReadS [Shrink2 a]
-> ReadPrec (Shrink2 a)
-> ReadPrec [Shrink2 a]
-> Read (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
$creadsPrec :: forall a. Read a => Int -> ReadS (Shrink2 a)
readsPrec :: Int -> ReadS (Shrink2 a)
$creadList :: forall a. Read a => ReadS [Shrink2 a]
readList :: ReadS [Shrink2 a]
$creadPrec :: forall a. Read a => ReadPrec (Shrink2 a)
readPrec :: ReadPrec (Shrink2 a)
$creadListPrec :: forall a. Read a => ReadPrec [Shrink2 a]
readListPrec :: ReadPrec [Shrink2 a]
Read
#ifndef NO_NEWTYPE_DERIVING
          , Integer -> Shrink2 a
Shrink2 a -> Shrink2 a
Shrink2 a -> Shrink2 a -> Shrink2 a
(Shrink2 a -> Shrink2 a -> Shrink2 a)
-> (Shrink2 a -> Shrink2 a -> Shrink2 a)
-> (Shrink2 a -> Shrink2 a -> Shrink2 a)
-> (Shrink2 a -> Shrink2 a)
-> (Shrink2 a -> Shrink2 a)
-> (Shrink2 a -> Shrink2 a)
-> (Integer -> Shrink2 a)
-> Num (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
$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
* :: Shrink2 a -> Shrink2 a -> Shrink2 a
$cnegate :: forall a. Num a => Shrink2 a -> Shrink2 a
negate :: Shrink2 a -> Shrink2 a
$cabs :: forall a. Num a => Shrink2 a -> Shrink2 a
abs :: Shrink2 a -> Shrink2 a
$csignum :: forall a. Num a => Shrink2 a -> Shrink2 a
signum :: Shrink2 a -> Shrink2 a
$cfromInteger :: forall a. Num a => Integer -> Shrink2 a
fromInteger :: Integer -> Shrink2 a
Num, Enum (Shrink2 a)
Real (Shrink2 a)
(Real (Shrink2 a), Enum (Shrink2 a)) =>
(Shrink2 a -> Shrink2 a -> Shrink2 a)
-> (Shrink2 a -> Shrink2 a -> Shrink2 a)
-> (Shrink2 a -> Shrink2 a -> Shrink2 a)
-> (Shrink2 a -> Shrink2 a -> Shrink2 a)
-> (Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a))
-> (Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a))
-> (Shrink2 a -> Integer)
-> Integral (Shrink2 a)
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
$cquot :: forall a. Integral a => Shrink2 a -> Shrink2 a -> Shrink2 a
quot :: Shrink2 a -> Shrink2 a -> Shrink2 a
$crem :: forall a. Integral a => Shrink2 a -> Shrink2 a -> Shrink2 a
rem :: Shrink2 a -> Shrink2 a -> Shrink2 a
$cdiv :: forall a. Integral a => Shrink2 a -> Shrink2 a -> Shrink2 a
div :: Shrink2 a -> Shrink2 a -> Shrink2 a
$cmod :: forall a. Integral a => Shrink2 a -> Shrink2 a -> Shrink2 a
mod :: Shrink2 a -> Shrink2 a -> Shrink2 a
$cquotRem :: forall a.
Integral a =>
Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a)
quotRem :: Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a)
$cdivMod :: forall a.
Integral a =>
Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a)
divMod :: Shrink2 a -> Shrink2 a -> (Shrink2 a, Shrink2 a)
$ctoInteger :: forall a. Integral a => Shrink2 a -> Integer
toInteger :: Shrink2 a -> Integer
Integral, Num (Shrink2 a)
Ord (Shrink2 a)
(Num (Shrink2 a), Ord (Shrink2 a)) =>
(Shrink2 a -> Rational) -> Real (Shrink2 a)
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
$ctoRational :: forall a. Real a => Shrink2 a -> Rational
toRational :: 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]
(Shrink2 a -> Shrink2 a)
-> (Shrink2 a -> Shrink2 a)
-> (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 -> [Shrink2 a])
-> Enum (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
$csucc :: forall a. Enum a => Shrink2 a -> Shrink2 a
succ :: Shrink2 a -> Shrink2 a
$cpred :: forall a. Enum a => Shrink2 a -> Shrink2 a
pred :: Shrink2 a -> Shrink2 a
$ctoEnum :: forall a. Enum a => Int -> Shrink2 a
toEnum :: Int -> Shrink2 a
$cfromEnum :: forall a. Enum a => Shrink2 a -> Int
fromEnum :: Shrink2 a -> Int
$cenumFrom :: forall a. Enum a => Shrink2 a -> [Shrink2 a]
enumFrom :: Shrink2 a -> [Shrink2 a]
$cenumFromThen :: forall a. Enum a => Shrink2 a -> Shrink2 a -> [Shrink2 a]
enumFromThen :: Shrink2 a -> Shrink2 a -> [Shrink2 a]
$cenumFromTo :: forall a. Enum a => Shrink2 a -> Shrink2 a -> [Shrink2 a]
enumFromTo :: Shrink2 a -> Shrink2 a -> [Shrink2 a]
$cenumFromThenTo :: forall a.
Enum a =>
Shrink2 a -> Shrink2 a -> Shrink2 a -> [Shrink2 a]
enumFromThenTo :: Shrink2 a -> Shrink2 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) = b -> Shrink2 b
forall a. a -> Shrink2 a
Shrink2 (a -> b
f a
x)

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

  shrink :: Shrink2 a -> [Shrink2 a]
shrink (Shrink2 a
x) =
    [ a -> Shrink2 a
forall a. a -> Shrink2 a
Shrink2 a
y | a
y <- [a]
shrink_x ] [Shrink2 a] -> [Shrink2 a] -> [Shrink2 a]
forall a. [a] -> [a] -> [a]
++
    [ a -> Shrink2 a
forall a. a -> Shrink2 a
Shrink2 a
z
    | a
y <- [a]
shrink_x
    , a
z <- a -> [a]
forall a. Arbitrary a => a -> [a]
shrink a
y
    ]
   where
    shrink_x :: [a]
shrink_x = a -> [a]
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) = Int -> b -> Smart b
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) = Int -> a -> ShowS
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 <- Gen a
forall a. Arbitrary a => Gen a
arbitrary
       Smart a -> Gen (Smart a)
forall a. a -> Gen a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> a -> Smart a
forall a. Int -> a -> Smart a
Smart Int
0 a
x)

  shrink :: Smart a -> [Smart a]
shrink (Smart Int
i a
x) = Int -> [Smart a] -> [Smart a]
forall a. Int -> [a] -> [a]
take Int
i' [Smart a]
ys [Smart a] -> [Smart a] -> [Smart a]
forall a. [a] -> [a] -> [a]
`ilv` Int -> [Smart a] -> [Smart a]
forall a. Int -> [a] -> [a]
drop Int
i' [Smart a]
ys
   where
    ys :: [Smart a]
ys = [ Int -> a -> Smart a
forall a. Int -> a -> Smart a
Smart Int
j a
y | (Int
j,a
y) <- [Int
0..] [Int] -> [a] -> [(Int, a)]
forall a b. [a] -> [b] -> [(a, b)]
`zip` a -> [a]
forall a. Arbitrary a => a -> [a]
shrink a
x ]
    i' :: Int
i' = Int
0 Int -> Int -> Int
forall a. Ord a => a -> a -> a
`max` (Int
iInt -> Int -> Int
forall 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 a -> [a] -> [a]
forall a. a -> [a] -> [a]
: a
b a -> [a] -> [a]
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) = s -> b -> Shrinking s b
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) = Int -> a -> ShowS
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 <- Gen a
forall a. Arbitrary a => Gen a
arbitrary
       Shrinking s a -> Gen (Shrinking s a)
forall a. a -> Gen a
forall (m :: * -> *) a. Monad m => a -> m a
return (s -> a -> Shrinking s a
forall s a. s -> a -> Shrinking s a
Shrinking (a -> s
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) =
    [ s -> a -> Shrinking s a
forall s a. s -> a -> Shrinking s a
Shrinking s
s' a
x'
    | (a
x',s
s') <- a -> s -> [(a, 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
(ASCIIString -> ASCIIString -> Bool)
-> (ASCIIString -> ASCIIString -> Bool) -> Eq ASCIIString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ASCIIString -> ASCIIString -> Bool
== :: ASCIIString -> ASCIIString -> Bool
$c/= :: ASCIIString -> ASCIIString -> Bool
/= :: ASCIIString -> ASCIIString -> Bool
Eq, Eq ASCIIString
Eq ASCIIString =>
(ASCIIString -> ASCIIString -> Ordering)
-> (ASCIIString -> ASCIIString -> Bool)
-> (ASCIIString -> ASCIIString -> Bool)
-> (ASCIIString -> ASCIIString -> Bool)
-> (ASCIIString -> ASCIIString -> Bool)
-> (ASCIIString -> ASCIIString -> ASCIIString)
-> (ASCIIString -> ASCIIString -> ASCIIString)
-> Ord 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
$ccompare :: ASCIIString -> ASCIIString -> Ordering
compare :: ASCIIString -> ASCIIString -> Ordering
$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
>= :: ASCIIString -> ASCIIString -> Bool
$cmax :: ASCIIString -> ASCIIString -> ASCIIString
max :: ASCIIString -> ASCIIString -> ASCIIString
$cmin :: ASCIIString -> ASCIIString -> ASCIIString
min :: ASCIIString -> ASCIIString -> ASCIIString
Ord, Int -> ASCIIString -> ShowS
[ASCIIString] -> ShowS
ASCIIString -> String
(Int -> ASCIIString -> ShowS)
-> (ASCIIString -> String)
-> ([ASCIIString] -> ShowS)
-> Show ASCIIString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ASCIIString -> ShowS
showsPrec :: Int -> ASCIIString -> ShowS
$cshow :: ASCIIString -> String
show :: ASCIIString -> String
$cshowList :: [ASCIIString] -> ShowS
showList :: [ASCIIString] -> ShowS
Show, ReadPrec [ASCIIString]
ReadPrec ASCIIString
Int -> ReadS ASCIIString
ReadS [ASCIIString]
(Int -> ReadS ASCIIString)
-> ReadS [ASCIIString]
-> ReadPrec ASCIIString
-> ReadPrec [ASCIIString]
-> Read ASCIIString
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ASCIIString
readsPrec :: Int -> ReadS ASCIIString
$creadList :: ReadS [ASCIIString]
readList :: ReadS [ASCIIString]
$creadPrec :: ReadPrec ASCIIString
readPrec :: ReadPrec ASCIIString
$creadListPrec :: ReadPrec [ASCIIString]
readListPrec :: ReadPrec [ASCIIString]
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
           )

instance Arbitrary ASCIIString where
  arbitrary :: Gen ASCIIString
arbitrary = String -> ASCIIString
ASCIIString (String -> ASCIIString) -> Gen String -> Gen ASCIIString
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen Char -> Gen String
forall a. Gen a -> Gen [a]
listOf Gen Char
arbitraryASCIIChar
  shrink :: ASCIIString -> [ASCIIString]
shrink (ASCIIString String
xs) = String -> ASCIIString
ASCIIString (String -> ASCIIString) -> [String] -> [ASCIIString]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` String -> [String]
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
(UnicodeString -> UnicodeString -> Bool)
-> (UnicodeString -> UnicodeString -> Bool) -> Eq UnicodeString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UnicodeString -> UnicodeString -> Bool
== :: UnicodeString -> UnicodeString -> Bool
$c/= :: UnicodeString -> UnicodeString -> Bool
/= :: UnicodeString -> UnicodeString -> Bool
Eq, Eq UnicodeString
Eq UnicodeString =>
(UnicodeString -> UnicodeString -> Ordering)
-> (UnicodeString -> UnicodeString -> Bool)
-> (UnicodeString -> UnicodeString -> Bool)
-> (UnicodeString -> UnicodeString -> Bool)
-> (UnicodeString -> UnicodeString -> Bool)
-> (UnicodeString -> UnicodeString -> UnicodeString)
-> (UnicodeString -> UnicodeString -> UnicodeString)
-> Ord 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
$ccompare :: UnicodeString -> UnicodeString -> Ordering
compare :: UnicodeString -> UnicodeString -> Ordering
$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
>= :: UnicodeString -> UnicodeString -> Bool
$cmax :: UnicodeString -> UnicodeString -> UnicodeString
max :: UnicodeString -> UnicodeString -> UnicodeString
$cmin :: UnicodeString -> UnicodeString -> UnicodeString
min :: UnicodeString -> UnicodeString -> UnicodeString
Ord, Int -> UnicodeString -> ShowS
[UnicodeString] -> ShowS
UnicodeString -> String
(Int -> UnicodeString -> ShowS)
-> (UnicodeString -> String)
-> ([UnicodeString] -> ShowS)
-> Show UnicodeString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UnicodeString -> ShowS
showsPrec :: Int -> UnicodeString -> ShowS
$cshow :: UnicodeString -> String
show :: UnicodeString -> String
$cshowList :: [UnicodeString] -> ShowS
showList :: [UnicodeString] -> ShowS
Show, ReadPrec [UnicodeString]
ReadPrec UnicodeString
Int -> ReadS UnicodeString
ReadS [UnicodeString]
(Int -> ReadS UnicodeString)
-> ReadS [UnicodeString]
-> ReadPrec UnicodeString
-> ReadPrec [UnicodeString]
-> Read UnicodeString
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS UnicodeString
readsPrec :: Int -> ReadS UnicodeString
$creadList :: ReadS [UnicodeString]
readList :: ReadS [UnicodeString]
$creadPrec :: ReadPrec UnicodeString
readPrec :: ReadPrec UnicodeString
$creadListPrec :: ReadPrec [UnicodeString]
readListPrec :: ReadPrec [UnicodeString]
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
           )

instance Arbitrary UnicodeString where
  arbitrary :: Gen UnicodeString
arbitrary = String -> UnicodeString
UnicodeString (String -> UnicodeString) -> Gen String -> Gen UnicodeString
forall a b. (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen Char -> Gen String
forall a. Gen a -> Gen [a]
listOf Gen Char
arbitraryUnicodeChar
  shrink :: UnicodeString -> [UnicodeString]
shrink (UnicodeString String
xs) = String -> UnicodeString
UnicodeString (String -> UnicodeString) -> [String] -> [UnicodeString]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` String -> [String]
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
(PrintableString -> PrintableString -> Bool)
-> (PrintableString -> PrintableString -> Bool)
-> Eq PrintableString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PrintableString -> PrintableString -> Bool
== :: PrintableString -> PrintableString -> Bool
$c/= :: PrintableString -> PrintableString -> Bool
/= :: PrintableString -> PrintableString -> Bool
Eq, Eq PrintableString
Eq PrintableString =>
(PrintableString -> PrintableString -> Ordering)
-> (PrintableString -> PrintableString -> Bool)
-> (PrintableString -> PrintableString -> Bool)
-> (PrintableString -> PrintableString -> Bool)
-> (PrintableString -> PrintableString -> Bool)
-> (PrintableString -> PrintableString -> PrintableString)
-> (PrintableString -> PrintableString -> PrintableString)
-> Ord 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
$ccompare :: PrintableString -> PrintableString -> Ordering
compare :: PrintableString -> PrintableString -> Ordering
$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
>= :: PrintableString -> PrintableString -> Bool
$cmax :: PrintableString -> PrintableString -> PrintableString
max :: PrintableString -> PrintableString -> PrintableString
$cmin :: PrintableString -> PrintableString -> PrintableString
min :: PrintableString -> PrintableString -> PrintableString
Ord, Int -> PrintableString -> ShowS
[PrintableString] -> ShowS
PrintableString -> String
(Int -> PrintableString -> ShowS)
-> (PrintableString -> String)
-> ([PrintableString] -> ShowS)
-> Show PrintableString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PrintableString -> ShowS
showsPrec :: Int -> PrintableString -> ShowS
$cshow :: PrintableString -> String
show :: PrintableString -> String
$cshowList :: [PrintableString] -> ShowS
showList :: [PrintableString] -> ShowS
Show, ReadPrec [PrintableString]
ReadPrec PrintableString
Int -> ReadS PrintableString
ReadS [PrintableString]
(Int -> ReadS PrintableString)
-> ReadS [PrintableString]
-> ReadPrec PrintableString
-> ReadPrec [PrintableString]
-> Read PrintableString
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS PrintableString
readsPrec :: Int -> ReadS PrintableString
$creadList :: ReadS [PrintableString]
readList :: ReadS [PrintableString]
$creadPrec :: ReadPrec PrintableString
readPrec :: ReadPrec PrintableString
$creadListPrec :: ReadPrec [PrintableString]
readListPrec :: ReadPrec [PrintableString]
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
           )

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

-- the end.