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

instance Functor Blind where
  fmap :: (a -> b) -> Blind a -> Blind b
fmap f :: a -> b
f (Blind x :: 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 _ = "(*)"

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

instance Functor Fixed where
  fmap :: (a -> b) -> Fixed a -> Fixed b
fmap f :: a -> b
f (Fixed x :: 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 (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 {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
/= :: OrderedList a -> OrderedList a -> Bool
$c/= :: forall a. Eq a => OrderedList a -> OrderedList a -> Bool
== :: OrderedList a -> OrderedList a -> Bool
$c== :: forall a. Eq a => OrderedList a -> OrderedList a -> Bool
Eq, 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
min :: OrderedList a -> OrderedList a -> OrderedList a
$cmin :: forall a. Ord a => OrderedList a -> OrderedList a -> OrderedList a
max :: OrderedList a -> OrderedList a -> OrderedList a
$cmax :: forall a. Ord a => OrderedList a -> OrderedList a -> OrderedList a
>= :: OrderedList a -> OrderedList a -> Bool
$c>= :: forall a. Ord a => OrderedList a -> OrderedList a -> Bool
> :: OrderedList a -> OrderedList a -> Bool
$c> :: forall a. Ord a => OrderedList a -> OrderedList a -> Bool
<= :: OrderedList a -> OrderedList a -> Bool
$c<= :: forall a. Ord a => OrderedList a -> OrderedList a -> Bool
< :: OrderedList a -> OrderedList a -> Bool
$c< :: forall a. Ord a => OrderedList a -> OrderedList a -> Bool
compare :: OrderedList a -> OrderedList a -> Ordering
$ccompare :: forall a. Ord a => OrderedList a -> OrderedList a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (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
showList :: [OrderedList a] -> ShowS
$cshowList :: forall a. Show a => [OrderedList a] -> ShowS
show :: OrderedList a -> String
$cshow :: forall a. Show a => OrderedList a -> String
showsPrec :: Int -> OrderedList a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> OrderedList a -> ShowS
Show, ReadPrec [OrderedList a]
ReadPrec (OrderedList a)
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
readListPrec :: ReadPrec [OrderedList a]
$creadListPrec :: forall a. Read a => ReadPrec [OrderedList a]
readPrec :: ReadPrec (OrderedList a)
$creadPrec :: forall a. Read a => ReadPrec (OrderedList a)
readList :: ReadS [OrderedList a]
$creadList :: forall a. Read a => ReadS [OrderedList a]
readsPrec :: Int -> ReadS (OrderedList a)
$creadsPrec :: forall a. Read a => Int -> ReadS (OrderedList a)
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor OrderedList where
  fmap :: (a -> b) -> OrderedList a -> OrderedList b
fmap f :: a -> b
f (Ordered x :: [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 (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 xs :: [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 {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
/= :: NonEmptyList a -> NonEmptyList a -> Bool
$c/= :: forall a. Eq a => NonEmptyList a -> NonEmptyList a -> Bool
== :: NonEmptyList a -> NonEmptyList a -> Bool
$c== :: forall a. Eq a => NonEmptyList a -> NonEmptyList a -> Bool
Eq, 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
min :: NonEmptyList a -> NonEmptyList a -> NonEmptyList a
$cmin :: forall a.
Ord a =>
NonEmptyList a -> NonEmptyList a -> NonEmptyList a
max :: NonEmptyList a -> NonEmptyList a -> NonEmptyList a
$cmax :: forall a.
Ord a =>
NonEmptyList a -> NonEmptyList a -> NonEmptyList a
>= :: NonEmptyList a -> NonEmptyList a -> Bool
$c>= :: forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Bool
> :: NonEmptyList a -> NonEmptyList a -> Bool
$c> :: forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Bool
<= :: NonEmptyList a -> NonEmptyList a -> Bool
$c<= :: forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Bool
< :: NonEmptyList a -> NonEmptyList a -> Bool
$c< :: forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Bool
compare :: NonEmptyList a -> NonEmptyList a -> Ordering
$ccompare :: forall a. Ord a => NonEmptyList a -> NonEmptyList a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (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
showList :: [NonEmptyList a] -> ShowS
$cshowList :: forall a. Show a => [NonEmptyList a] -> ShowS
show :: NonEmptyList a -> String
$cshow :: forall a. Show a => NonEmptyList a -> String
showsPrec :: Int -> NonEmptyList a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> NonEmptyList a -> ShowS
Show, ReadPrec [NonEmptyList a]
ReadPrec (NonEmptyList a)
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
readListPrec :: ReadPrec [NonEmptyList a]
$creadListPrec :: forall a. Read a => ReadPrec [NonEmptyList a]
readPrec :: ReadPrec (NonEmptyList a)
$creadPrec :: forall a. Read a => ReadPrec (NonEmptyList a)
readList :: ReadS [NonEmptyList a]
$creadList :: forall a. Read a => ReadS [NonEmptyList a]
readsPrec :: Int -> ReadS (NonEmptyList a)
$creadsPrec :: forall a. Read a => Int -> ReadS (NonEmptyList a)
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

instance Functor NonEmptyList where
  fmap :: (a -> b) -> NonEmptyList a -> NonEmptyList b
fmap f :: a -> b
f (NonEmpty x :: [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 (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 (t :: * -> *) a. Foldable t => t a -> Bool
null))

  shrink :: NonEmptyList a -> [NonEmptyList a]
shrink (NonEmpty xs :: [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 (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 {
    InfiniteList a -> [a]
getInfiniteList :: [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 :: InfiniteListInternalData a -> InfiniteList a
infiniteListFromData info :: InfiniteListInternalData a
info@(Infinite xs :: [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 xs :: [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 _ (InfiniteList _ (Infinite _)) =
    ("<infinite list>" String -> ShowS
forall a. [a] -> [a] -> [a]
++)
  showsPrec n :: Int
n (InfiniteList _ (FinitePrefix xs :: [a]
xs)) =
    (if Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 10 then ('('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 0 [a]
xs ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
    (" ++ ..." 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
> 10 then (')'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 (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 _ info :: 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 (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 xs :: [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 (2Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^) [0..]]
  shrink (FinitePrefix xs :: [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 {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
/= :: SortedList a -> SortedList a -> Bool
$c/= :: forall a. Eq a => SortedList a -> SortedList a -> Bool
== :: SortedList a -> SortedList a -> Bool
$c== :: forall a. Eq a => SortedList a -> SortedList a -> Bool
Eq, 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
min :: SortedList a -> SortedList a -> SortedList a
$cmin :: forall a. Ord a => SortedList a -> SortedList a -> SortedList a
max :: SortedList a -> SortedList a -> SortedList a
$cmax :: forall a. Ord a => SortedList a -> SortedList a -> SortedList a
>= :: SortedList a -> SortedList a -> Bool
$c>= :: forall a. Ord a => SortedList a -> SortedList a -> Bool
> :: SortedList a -> SortedList a -> Bool
$c> :: forall a. Ord a => SortedList a -> SortedList a -> Bool
<= :: SortedList a -> SortedList a -> Bool
$c<= :: forall a. Ord a => SortedList a -> SortedList a -> Bool
< :: SortedList a -> SortedList a -> Bool
$c< :: forall a. Ord a => SortedList a -> SortedList a -> Bool
compare :: SortedList a -> SortedList a -> Ordering
$ccompare :: forall a. Ord a => SortedList a -> SortedList a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (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
showList :: [SortedList a] -> ShowS
$cshowList :: forall a. Show a => [SortedList a] -> ShowS
show :: SortedList a -> String
$cshow :: forall a. Show a => SortedList a -> String
showsPrec :: Int -> SortedList a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> SortedList a -> ShowS
Show, ReadPrec [SortedList a]
ReadPrec (SortedList a)
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
readListPrec :: ReadPrec [SortedList a]
$creadListPrec :: forall a. Read a => ReadPrec [SortedList a]
readPrec :: ReadPrec (SortedList a)
$creadPrec :: forall a. Read a => ReadPrec (SortedList a)
readList :: ReadS [SortedList a]
$creadList :: forall a. Read a => ReadS [SortedList a]
readsPrec :: Int -> ReadS (SortedList a)
$creadsPrec :: forall a. Read a => Int -> ReadS (SortedList a)
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
          )

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

instance Functor Positive where
  fmap :: (a -> b) -> Positive a -> Positive b
fmap f :: a -> b
f (Positive x :: 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 (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 (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
> 0))
  shrink :: Positive a -> [Positive a]
shrink (Positive x :: 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
> 0 ]

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

instance Functor Negative where
  fmap :: (a -> b) -> Negative a -> Negative b
fmap f :: a -> b
f (Negative x :: 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 (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Negative a
forall a. a -> Negative a
Negative (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
< 0))
  shrink :: Negative a -> [Negative a]
shrink (Negative x :: 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
< 0 ]

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

instance Functor NonZero where
  fmap :: (a -> b) -> NonZero a -> NonZero b
fmap f :: a -> b
f (NonZero x :: 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 (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
/= 0)

  shrink :: NonZero a -> [NonZero a]
shrink (NonZero x :: 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
/= 0 ]

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

instance Functor NonNegative where
  fmap :: (a -> b) -> NonNegative a -> NonNegative b
fmap f :: a -> b
f (NonNegative x :: 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 (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 (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
>= 0))
  shrink :: NonNegative a -> [NonNegative a]
shrink (NonNegative x :: 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
>= 0 ]

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

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

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

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

instance Functor Shrink2 where
  fmap :: (a -> b) -> Shrink2 a -> Shrink2 b
fmap f :: a -> b
f (Shrink2 x :: 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 (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 x :: 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 :: (a -> b) -> Smart a -> Smart b
fmap f :: a -> b
f (Smart n :: Int
n x :: 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 n :: Int
n (Smart _ x :: 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 (m :: * -> *) a. Monad m => a -> m a
return (Int -> a -> Smart a
forall a. Int -> a -> Smart a
Smart 0 a
x)

  shrink :: Smart a -> [Smart a]
shrink (Smart i :: Int
i x :: 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 | (j :: Int
j,y :: a
y) <- [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' = 0 Int -> Int -> Int
forall a. Ord a => a -> a -> a
`max` (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-2)

    []     ilv :: [a] -> [a] -> [a]
`ilv` bs :: [a]
bs     = [a]
bs
    as :: [a]
as     `ilv` []     = [a]
as
    (a :: a
a:as :: [a]
as) `ilv` (b :: a
b:bs :: [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 :: (a -> b) -> Shrinking s a -> Shrinking s b
fmap f :: a -> b
f (Shrinking s :: s
s x :: 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 n :: Int
n (Shrinking _ x :: 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 (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
s x :: a
x) =
    [ s -> a -> Shrinking s a
forall s a. s -> a -> Shrinking s a
Shrinking s
s' a
x'
    | (x' :: a
x',s' :: 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
/= :: ASCIIString -> ASCIIString -> Bool
$c/= :: ASCIIString -> ASCIIString -> Bool
== :: ASCIIString -> ASCIIString -> Bool
$c== :: 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
min :: ASCIIString -> ASCIIString -> ASCIIString
$cmin :: ASCIIString -> ASCIIString -> ASCIIString
max :: ASCIIString -> ASCIIString -> ASCIIString
$cmax :: ASCIIString -> ASCIIString -> ASCIIString
>= :: ASCIIString -> ASCIIString -> Bool
$c>= :: ASCIIString -> ASCIIString -> Bool
> :: ASCIIString -> ASCIIString -> Bool
$c> :: ASCIIString -> ASCIIString -> Bool
<= :: ASCIIString -> ASCIIString -> Bool
$c<= :: ASCIIString -> ASCIIString -> Bool
< :: ASCIIString -> ASCIIString -> Bool
$c< :: ASCIIString -> ASCIIString -> Bool
compare :: ASCIIString -> ASCIIString -> Ordering
$ccompare :: ASCIIString -> ASCIIString -> Ordering
$cp1Ord :: Eq 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
showList :: [ASCIIString] -> ShowS
$cshowList :: [ASCIIString] -> ShowS
show :: ASCIIString -> String
$cshow :: ASCIIString -> String
showsPrec :: Int -> ASCIIString -> ShowS
$cshowsPrec :: Int -> ASCIIString -> ShowS
Show, ReadPrec [ASCIIString]
ReadPrec ASCIIString
Int -> ReadS ASCIIString
ReadS [ASCIIString]
(Int -> ReadS ASCIIString)
-> ReadS [ASCIIString]
-> ReadPrec ASCIIString
-> ReadPrec [ASCIIString]
-> Read ASCIIString
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ASCIIString]
$creadListPrec :: ReadPrec [ASCIIString]
readPrec :: ReadPrec ASCIIString
$creadPrec :: ReadPrec ASCIIString
readList :: ReadS [ASCIIString]
$creadList :: ReadS [ASCIIString]
readsPrec :: Int -> ReadS ASCIIString
$creadsPrec :: Int -> ReadS ASCIIString
Read
#ifndef NO_TYPEABLE
          , Typeable
#endif
           )

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

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

instance Arbitrary PrintableString where
  arbitrary :: Gen PrintableString
arbitrary = String -> PrintableString
PrintableString (String -> PrintableString) -> Gen String -> Gen PrintableString
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 xs :: String
xs) = String -> PrintableString
PrintableString (String -> PrintableString) -> [String] -> [PrintableString]
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.