-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | generalize counter-examples of test properties
--   
--   Extrapolate is a tool able to provide generalized counter-examples of
--   test properties where irrelevant sub-expressions are replaces with
--   variables.
--   
--   For the incorrect property <tt>\xs -&gt; nub xs == (xs::[Int])</tt>:
--   
--   <ul>
--   <li><tt>[0,0]</tt> is a counter-example;</li>
--   <li><tt>x:x:_</tt> is a generalized counter-example.</li>
--   </ul>
@package extrapolate
@version 0.3.1


-- | This module is part of Extrapolate, a library for generalization of
--   counter-examples.
--   
--   This module re-exports some functionality from Test.Speculate.Expr,
--   but instead of working on single expressions it works in lists of
--   expressions (the choosen representation for counter-examples).
module Test.Extrapolate.Exprs
type Exprs = [Expr]
canonicalizeWith :: Instances -> [Expr] -> [Expr]
grounds :: Instances -> [Expr] -> [[Expr]]
groundsAndBinds :: Instances -> [Expr] -> [(Binds, [Expr])]
vassignments :: [Expr] -> [[Expr]]
vars :: [Expr] -> [(TypeRep, String)]
fold :: [Expr] -> Expr
unfold :: Expr -> [Expr]
isAssignmentTest :: Instances -> Int -> Expr -> Bool
nameWith :: Typeable a => String -> a -> Instances


-- | This module is part of Extrapolate, a library for generalization of
--   counter-examples.
--   
--   Some type binding operators that are useful when defining
--   Generalizable instances.
module Test.Extrapolate.TypeBinding
argTy1of1 :: con a -> a
argTy1of2 :: con a b -> a
argTy2of2 :: con a b -> b
argTy1of3 :: con a b c -> a
argTy2of3 :: con a b c -> b
argTy3of3 :: con a b c -> c
argTy1of4 :: con a b c d -> a
argTy2of4 :: con a b c d -> b
argTy3of4 :: con a b c d -> c
argTy4of4 :: con a b c d -> d
argTy1of5 :: con a b c d e -> a
argTy2of5 :: con a b c d e -> b
argTy3of5 :: con a b c d e -> c
argTy4of5 :: con a b c d e -> d
argTy5of5 :: con a b c d e -> e
argTy1of6 :: con a b c d e f -> a
argTy2of6 :: con a b c d e f -> b
argTy3of6 :: con a b c d e f -> c
argTy4of6 :: con a b c d e f -> d
argTy5of6 :: con a b c d e f -> e
argTy6of6 :: con a b c d e f -> f


-- | This module is part of Extrapolate, a library for generalization of
--   counter-examples.
--   
--   Miscellaneous utility functions.
--   
--   This is not intended to be used by users of Extrapolate, only by
--   modules of Extrapolate itself. Expect symbols exported here to come
--   and go with every minor version.
module Test.Extrapolate.Utils
(+++) :: Ord a => [a] -> [a] -> [a]
infixr 5 +++
nubMerge :: Ord a => [a] -> [a] -> [a]
nubMergeOn :: Ord b => (a -> b) -> [a] -> [a] -> [a]
nubMergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a]
foldr0 :: (a -> a -> a) -> a -> [a] -> a
fromLeft :: Either a b -> a
fromRight :: Either a b -> b
elemBy :: (a -> a -> Bool) -> a -> [a] -> Bool
listEq :: (a -> a -> Bool) -> [a] -> [a] -> Bool
listOrd :: (a -> a -> Bool) -> [a] -> [a] -> Bool
maybeEq :: (a -> a -> Bool) -> Maybe a -> Maybe a -> Bool
maybeOrd :: (a -> a -> Bool) -> Maybe a -> Maybe a -> Bool
eitherEq :: (a -> a -> Bool) -> (b -> b -> Bool) -> Either a b -> Either a b -> Bool
eitherOrd :: (a -> a -> Bool) -> (b -> b -> Bool) -> Either a b -> Either a b -> Bool
pairEq :: (a -> a -> Bool) -> (b -> b -> Bool) -> (a, b) -> (a, b) -> Bool
pairOrd :: (a -> a -> Bool) -> (b -> b -> Bool) -> (a, b) -> (a, b) -> Bool
tripleEq :: (a -> a -> Bool) -> (b -> b -> Bool) -> (c -> c -> Bool) -> (a, b, c) -> (a, b, c) -> Bool
tripleOrd :: (a -> a -> Bool) -> (b -> b -> Bool) -> (c -> c -> Bool) -> (a, b, c) -> (a, b, c) -> Bool
quadrupleEq :: (a -> a -> Bool) -> (b -> b -> Bool) -> (c -> c -> Bool) -> (d -> d -> Bool) -> (a, b, c, d) -> (a, b, c, d) -> Bool
quadrupleOrd :: (a -> a -> Bool) -> (b -> b -> Bool) -> (c -> c -> Bool) -> (d -> d -> Bool) -> (a, b, c, d) -> (a, b, c, d) -> Bool
minimumOn :: Ord b => (a -> b) -> [a] -> a
maximumOn :: Ord b => (a -> b) -> [a] -> a
takeBound :: Maybe Int -> [a] -> [a]
nubMergeMap :: Ord b => (a -> [b]) -> [a] -> [b]

-- | For a given type, return all *-kinded types. (all non-function types)
--   
--   <pre>
--   typesIn (typeOf (undefined :: (Int -&gt; Int) -&gt; Int -&gt; Bool))
--     == [Bool,Int]
--   </pre>
typesIn :: TypeRep -> [TypeRep]
argumentTy :: TypeRep -> TypeRep
resultTy :: TypeRep -> TypeRep
discard :: (a -> Bool) -> [a] -> [a]
compareIndex :: Eq a => [a] -> a -> a -> Ordering
(.:) :: (c -> d) -> (a -> b -> c) -> (a -> b -> d)


-- | This module is part of Extrapolate, a library for generalization of
--   counter-examples.
--   
--   This is the core of extrapolate.
module Test.Extrapolate.Core

-- | Extrapolate can generalize counter-examples of any types that are
--   <a>Generalizable</a>.
--   
--   The core (and only required functions) of the generalizable typeclass
--   are the <a>expr</a> and <a>instances</a> functions.
--   
--   The following example shows a datatype and its instance:
--   
--   <pre>
--   data Stack a = Stack a (Stack a) | Empty
--   </pre>
--   
--   <pre>
--   instance Generalizable a =&gt; Generalizable (Stack a) where
--   name _ = "s"
--   expr s@(Stack x y) = constant "Stack" (Stack -&gt;&gt;: s) :$ expr x :$ expr y
--   expr s@Empty       = constant "Empty" (Empty   -: s)
--   instances s = this s $ instances (argTy1of1 s)
--   </pre>
--   
--   To declare <a>instances</a> and <a>expr</a> it may be useful to use:
--   
--   <ul>
--   <li>LeanCheck's <a>Test.LeanCheck.Utils.TypeBinding</a> operators:
--   <a>-:</a>, <a>-&gt;:</a>, <a>-&gt;&gt;:</a>, ...;</li>
--   <li>Extrapolate's <a>Test.Extrapolate.TypeBinding</a> operators:
--   <a>argTy1of1</a>, <a>argTy1of2</a>, <a>argTy2of2</a>, ....</li>
--   </ul>
class (Listable a, Typeable a, Show a) => Generalizable a

-- | Transforms a value into an manipulable expression tree. See
--   <a>constant</a> and <a>:$</a>.
expr :: Generalizable a => a -> Expr

-- | Common name for a variable, defaults to <tt>"x"</tt>.
name :: Generalizable a => a -> String

-- | List of symbols allowed to appear in side-conditions. Defaults to
--   <tt>[]</tt>. See <a>constant</a>.
background :: Generalizable a => a -> [Expr]

-- | Computes a list of reified instances. See <a>this</a>.
instances :: Generalizable a => a -> Instances -> Instances
this :: Generalizable a => a -> (Instances -> Instances) -> Instances -> Instances
backgroundWith :: Typeable a => [Expr] -> a -> Instances
(+++) :: Ord a => [a] -> [a] -> [a]
infixr 5 +++
backgroundOf :: Generalizable a => a -> [Expr]
bgEq :: (Eq a, Generalizable a) => a -> [Expr]
bgOrd :: (Ord a, Generalizable a) => a -> [Expr]
bgEqWith1 :: (Generalizable a, Generalizable b) => ((b -> b -> Bool) -> a -> a -> Bool) -> [Expr]
bgEqWith2 :: (Generalizable a, Generalizable b, Generalizable c) => ((b -> b -> Bool) -> (c -> c -> Bool) -> a -> a -> Bool) -> [Expr]
data Option
MaxTests :: Int -> Option
ExtraInstances :: Instances -> Option
MaxConditionSize :: Int -> Option
MinFailures :: (Ratio Int) -> Option
MaxSpeculateSize :: (Maybe Int) -> Option
ConditionBound :: (Maybe Int) -> Option
ConstantBound :: (Maybe Int) -> Option
DepthBound :: (Maybe Int) -> Option
data WithOption a
With :: a -> Option -> WithOption a
[property] :: WithOption a -> a
[option] :: WithOption a -> Option
maxTests :: Testable a => a -> Int
extraInstances :: Testable a => a -> Instances
maxConditionSize :: Testable a => a -> Int
hasEq :: Generalizable a => a -> Bool
(*==*) :: Generalizable a => a -> a -> Bool
(*/=*) :: Generalizable a => a -> a -> Bool
(*<=*) :: Generalizable a => a -> a -> Bool
(*<*) :: Generalizable a => a -> a -> Bool
tBackground :: Testable a => a -> [Expr]
counterExamples :: Testable a => Int -> a -> [[Expr]]
counterExampleGen :: Testable a => Int -> a -> Maybe ([Expr], Maybe [Expr])
counterExampleGens :: Testable a => Int -> a -> Maybe ([Expr], [[Expr]])
generalizations :: Instances -> [Expr] -> [[Expr]]
generalizationsCE :: Testable a => Int -> a -> [Expr] -> [[Expr]]
generalizationsCEC :: Testable a => a -> [Expr] -> [(Expr, [Expr])]
generalizationsCounts :: Testable a => Int -> a -> [Expr] -> [([Expr], Int)]
atoms :: Testable a => a -> [[Expr]]
theoryAndReprExprs :: Testable a => a -> (Thy, [Expr])
theoryAndReprConds :: Testable a => a -> (Thy, [Expr])
candidateConditions :: Testable a => (Thy, [Expr]) -> a -> [Expr] -> [Expr]
validConditions :: Testable a => (Thy, [Expr]) -> a -> [Expr] -> [(Expr, Int)]
weakestCondition :: Testable a => (Thy, [Expr]) -> a -> [Expr] -> Expr
getBackground :: Instances -> [Expr]
fullInstances :: Testable a => a -> Instances

-- | List matches of lists of expressions if possible
--   
--   <pre>
--   [0,1]   `matchList` [x,y]   = Just [x=0, y=1]
--   [0,1+2] `matchList` [x,y+y] = Nothing
--   </pre>
matchList :: [Expr] -> [Expr] -> Maybe Binds
newMatches :: [Expr] -> [Expr] -> Maybe Binds
class Testable a
resultiers :: Testable a => a -> [[([Expr], Bool)]]
($-|) :: Testable a => a -> [Expr] -> Bool
tinstances :: Testable a => a -> Instances
options :: Testable a => a -> Options
results :: Testable a => a -> [([Expr], Bool)]
areInstancesOf :: [Expr] -> [Expr] -> Bool
instance GHC.Show.Show Test.Extrapolate.Core.Option
instance Test.Extrapolate.Core.Testable a => Test.Extrapolate.Core.Testable (Test.Extrapolate.Core.WithOption a)
instance Test.Extrapolate.Core.Testable GHC.Types.Bool
instance (Test.Extrapolate.Core.Testable b, Test.Extrapolate.Core.Generalizable a, Test.LeanCheck.Core.Listable a) => Test.Extrapolate.Core.Testable (a -> b)
instance Test.Extrapolate.Core.Generalizable ()
instance Test.Extrapolate.Core.Generalizable GHC.Types.Bool
instance Test.Extrapolate.Core.Generalizable GHC.Types.Int
instance Test.Extrapolate.Core.Generalizable GHC.Integer.Type.Integer
instance Test.Extrapolate.Core.Generalizable GHC.Types.Char
instance Test.Extrapolate.Core.Generalizable a => Test.Extrapolate.Core.Generalizable (GHC.Base.Maybe a)
instance (Test.Extrapolate.Core.Generalizable a, Test.Extrapolate.Core.Generalizable b) => Test.Extrapolate.Core.Generalizable (Data.Either.Either a b)
instance (Test.Extrapolate.Core.Generalizable a, Test.Extrapolate.Core.Generalizable b) => Test.Extrapolate.Core.Generalizable (a, b)
instance (Test.Extrapolate.Core.Generalizable a, Test.Extrapolate.Core.Generalizable b, Test.Extrapolate.Core.Generalizable c) => Test.Extrapolate.Core.Generalizable (a, b, c)
instance (Test.Extrapolate.Core.Generalizable a, Test.Extrapolate.Core.Generalizable b, Test.Extrapolate.Core.Generalizable c, Test.Extrapolate.Core.Generalizable d) => Test.Extrapolate.Core.Generalizable (a, b, c, d)
instance Test.Extrapolate.Core.Generalizable a => Test.Extrapolate.Core.Generalizable [a]
instance Test.Extrapolate.Core.Generalizable GHC.Types.Ordering


-- | This module is otherwise unused in the code.
--   
--   This is a stub of a new algorithm that is smarter and generalizes from
--   several initial counter-examples rather than just one.
--   
--   When this gets finished, it should be moved into
--   <a>Test.Extrapolate.Core</a>.
module Test.Extrapolate.New
generalizedCounterExamples :: Testable a => Int -> a -> [Exprs]
lgg :: Exprs -> Exprs -> Exprs

-- | Computes the least general generalization of two expressions
--   
--   <pre>
--   lgg1 (expr [0,0]) (expr [1,1])
--   </pre>
--   
--   <ul>
--   <li><i>_,_</i> :: [Int] (holes: Int, Int) &gt; lgg1 (expr [1,1::Int])
--   (expr [2,2,2::Int]) _:_:_ :: [Int] (holes: Int, Int, [Int])</li>
--   </ul>
lgg1 :: Expr -> Expr -> Expr


-- | This module is part of Extrapolate, a library for generalization of
--   counter-examples.
--   
--   QuickCheck-like interface.
module Test.Extrapolate.IO

-- | Checks a property printing results on <tt>stdout</tt>
--   
--   <pre>
--   &gt; check $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 360 tests.
--   
--   &gt; check $ \xs ys -&gt; xs `union` ys == ys `union` (xs::[Int])
--   *** Failed! Falsifiable (after 4 tests):
--   [] [0,0]
--   
--   Generalization:
--   [] (x:x:_)
--   </pre>
check :: Testable a => a -> IO ()

-- | Check a property printing results on <tt>stdout</tt> and returning
--   <a>True</a> on success.
--   
--   There is no option to silence this function: for silence, you should
--   use <a>holds</a>.
checkResult :: Testable a => a -> IO Bool

-- | Use <tt><a>for</a></tt> to configure the number of tests performed by
--   <tt>check</tt>.
--   
--   <pre>
--   &gt; check `for` 10080 $ \xs -&gt; sort (sort xs) == sort (xs :: [Int])
--   +++ OK, passed 10080 tests.
--   </pre>
--   
--   Don't forget the dollar (<tt>$</tt>)!
for :: Testable a => (WithOption a -> b) -> Int -> a -> b

-- | Allows the user to customize instance information available when
--   generalized. (For advanced users.)
withInstances :: Testable a => (WithOption a -> b) -> Instances -> a -> b

-- | Use <tt><a>withBackground</a></tt> to provide additional functions to
--   appear in side-conditions.
--   
--   <pre>
--   check `withBackground` [constant "isSpace" isSpace] $ \xs -&gt; unwords (words xs) == xs
--   *** Failed! Falsifiable (after 4 tests):
--   " "
--   
--   Generalization:
--   ' ':_
--   
--   Conditional Generalization:
--   c:_  when  isSpace c
--   </pre>
withBackground :: Testable a => (WithOption a -> b) -> [Expr] -> a -> b

-- | Use <tt><a>withConditionSize</a></tt> to configure the maximum
--   condition size allowed.
withConditionSize :: Testable a => (WithOption a -> b) -> Int -> a -> b

-- | Use <tt><a>minFailures</a></tt> to configure the minimum number of
--   failures for a conditional generalization in function of the maximum
--   number of tests.
--   
--   To set that conditional generalizations should fail for 10% of cases:
--   &gt; check <a>minFailures</a> (<a>div</a> 10) $ prop
--   
--   To set that conditional generalizations should fail for 5% of cases:
--   &gt; check <a>minFailures</a> (<a>div</a> 20) $ prop
minFailures :: Testable a => (WithOption a -> b) -> Ratio Int -> a -> b
maxSpeculateSize :: Testable a => (WithOption a -> b) -> Maybe Int -> a -> b
conditionBound :: Testable a => (WithOption a -> b) -> Maybe Int -> a -> b

-- | Configures a bound on the number of constants allowed in expressions
--   that are considered when testing for equality in Speculate.
--   
--   Defaults to 2.
constantBound :: Testable a => (WithOption a -> b) -> Maybe Int -> a -> b

-- | Configures a bound on the depth of expressions that are considered
--   when testing for equality in Speculate.
--   
--   Default to 3.
depthBound :: Testable a => (WithOption a -> b) -> Maybe Int -> a -> b
instance GHC.Show.Show Test.Extrapolate.IO.Result
instance GHC.Classes.Eq Test.Extrapolate.IO.Result


-- | This module is part of Extrapolate, a library for generalization of
--   counter-examples.
--   
--   This is a module for deriving <a>Generalizable</a> instances.
--   
--   Needs GHC and Template Haskell (tested on GHC 8.0).
--   
--   If Extrapolate does not compile under later GHCs, this module is the
--   probable culprit.
module Test.Extrapolate.Derive

-- | Derives a <a>Generalizable</a> instance for a given type <a>Name</a>.
--   
--   Consider the following <tt>Stack</tt> datatype:
--   
--   <pre>
--   data Stack a = Stack a (Stack a) | Empty
--   </pre>
--   
--   Writing
--   
--   <pre>
--   deriveGeneralizable ''Stack
--   </pre>
--   
--   will automatically derive the following <a>Generalizable</a> instance:
--   
--   <pre>
--   instance Generalizable a =&gt; Generalizable (Stack a) where
--     expr s@(Stack x y) = constant "Stack" (Stack -&gt;&gt;: s) :$ expr x :$ expr y
--     expr s@Empty       = constant "Empty" (Empty   -: s)
--     instances s = this "s" s
--                 $ let Stack x y = Stack undefined undefined `asTypeOf` s
--                   in instances x
--                    . instances y
--   </pre>
--   
--   This function needs the <tt>TemplateHaskell</tt> extension.
deriveGeneralizable :: Name -> DecsQ

-- | Same as <a>deriveGeneralizable</a> but does not warn when instance
--   already exists (<a>deriveGeneralizable</a> is preferable).
deriveGeneralizableIfNeeded :: Name -> DecsQ

-- | Derives a <a>Generalizable</a> instance for a given type <a>Name</a>
--   cascading derivation of type arguments as well.
deriveGeneralizableCascading :: Name -> DecsQ
instance GHC.Show.Show Test.Extrapolate.Derive.Bla
instance GHC.Classes.Ord Test.Extrapolate.Derive.Bla
instance GHC.Classes.Eq Test.Extrapolate.Derive.Bla


-- | This module is part of Extrapolate, a library for generalization of
--   counter-examples.
--   
--   This provides the basic functionality of extrapolate. You will have
--   better luck importing <a>Test.Extrapolate</a> directly.
module Test.Extrapolate.Basic
instance (GHC.Real.Integral a, Test.Extrapolate.Core.Generalizable a) => Test.Extrapolate.Core.Generalizable (GHC.Real.Ratio a)
instance (Test.Extrapolate.Core.Generalizable a, Test.Extrapolate.Core.Generalizable b, Test.Extrapolate.Core.Generalizable c, Test.Extrapolate.Core.Generalizable d, Test.Extrapolate.Core.Generalizable e) => Test.Extrapolate.Core.Generalizable (a, b, c, d, e)
instance (Test.Extrapolate.Core.Generalizable a, Test.Extrapolate.Core.Generalizable b, Test.Extrapolate.Core.Generalizable c, Test.Extrapolate.Core.Generalizable d, Test.Extrapolate.Core.Generalizable e, Test.Extrapolate.Core.Generalizable f) => Test.Extrapolate.Core.Generalizable (a, b, c, d, e, f)
instance (Test.Extrapolate.Core.Generalizable a, Test.Extrapolate.Core.Generalizable b, Test.Extrapolate.Core.Generalizable c, Test.Extrapolate.Core.Generalizable d, Test.Extrapolate.Core.Generalizable e, Test.Extrapolate.Core.Generalizable f, Test.Extrapolate.Core.Generalizable g) => Test.Extrapolate.Core.Generalizable (a, b, c, d, e, f, g)
instance (Test.Extrapolate.Core.Generalizable a, Test.Extrapolate.Core.Generalizable b, Test.Extrapolate.Core.Generalizable c, Test.Extrapolate.Core.Generalizable d, Test.Extrapolate.Core.Generalizable e, Test.Extrapolate.Core.Generalizable f, Test.Extrapolate.Core.Generalizable g, Test.Extrapolate.Core.Generalizable h) => Test.Extrapolate.Core.Generalizable (a, b, c, d, e, f, g, h)


-- | Extrapolate is a property-based testing library capable of reporting
--   generalized counter-examples.
--   
--   Consider the following faulty implementation of sort:
--   
--   <pre>
--   sort :: Ord a =&gt; [a] -&gt; [a]
--   sort []      =  []
--   sort (x:xs)  =  sort (filter (&lt; x) xs)
--                ++ [x]
--                ++ sort (filter (&gt; x) xs)
--   </pre>
--   
--   When tests pass, Extrapolate works like a regular property-based
--   testing library. See:
--   
--   <pre>
--   &gt; check $ \xs -&gt; sort (sort xs :: [Int]) == sort xs
--   +++ OK, passed 360 tests.
--   </pre>
--   
--   When tests fail, Extrapolate reports a fully defined counter-example
--   and a generalization of failing inputs. See:
--   
--   <pre>
--   &gt; &gt; check $ \xs -&gt; length (sort xs :: [Int]) == length xs
--   *** Failed! Falsifiable (after 3 tests):
--   [0,0]
--   
--   Generalization:
--   x:x:_
--   </pre>
--   
--   The property fails for any integer <tt>x</tt> and for any list
--   <tt>_</tt> at the tail.
module Test.Extrapolate

-- | Checks a property printing results on <tt>stdout</tt>
--   
--   <pre>
--   &gt; check $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 360 tests.
--   
--   &gt; check $ \xs ys -&gt; xs `union` ys == ys `union` (xs::[Int])
--   *** Failed! Falsifiable (after 4 tests):
--   [] [0,0]
--   
--   Generalization:
--   [] (x:x:_)
--   </pre>
check :: Testable a => a -> IO ()

-- | Check a property printing results on <tt>stdout</tt> and returning
--   <a>True</a> on success.
--   
--   There is no option to silence this function: for silence, you should
--   use <a>holds</a>.
checkResult :: Testable a => a -> IO Bool

-- | Use <tt><a>for</a></tt> to configure the number of tests performed by
--   <tt>check</tt>.
--   
--   <pre>
--   &gt; check `for` 10080 $ \xs -&gt; sort (sort xs) == sort (xs :: [Int])
--   +++ OK, passed 10080 tests.
--   </pre>
--   
--   Don't forget the dollar (<tt>$</tt>)!
for :: Testable a => (WithOption a -> b) -> Int -> a -> b

-- | Use <tt><a>withBackground</a></tt> to provide additional functions to
--   appear in side-conditions.
--   
--   <pre>
--   check `withBackground` [constant "isSpace" isSpace] $ \xs -&gt; unwords (words xs) == xs
--   *** Failed! Falsifiable (after 4 tests):
--   " "
--   
--   Generalization:
--   ' ':_
--   
--   Conditional Generalization:
--   c:_  when  isSpace c
--   </pre>
withBackground :: Testable a => (WithOption a -> b) -> [Expr] -> a -> b

-- | Use <tt><a>withConditionSize</a></tt> to configure the maximum
--   condition size allowed.
withConditionSize :: Testable a => (WithOption a -> b) -> Int -> a -> b

-- | Use <tt><a>minFailures</a></tt> to configure the minimum number of
--   failures for a conditional generalization in function of the maximum
--   number of tests.
--   
--   To set that conditional generalizations should fail for 10% of cases:
--   &gt; check <a>minFailures</a> (<a>div</a> 10) $ prop
--   
--   To set that conditional generalizations should fail for 5% of cases:
--   &gt; check <a>minFailures</a> (<a>div</a> 20) $ prop
minFailures :: Testable a => (WithOption a -> b) -> Ratio Int -> a -> b

-- | Extrapolate can generalize counter-examples of any types that are
--   <a>Generalizable</a>.
--   
--   The core (and only required functions) of the generalizable typeclass
--   are the <a>expr</a> and <a>instances</a> functions.
--   
--   The following example shows a datatype and its instance:
--   
--   <pre>
--   data Stack a = Stack a (Stack a) | Empty
--   </pre>
--   
--   <pre>
--   instance Generalizable a =&gt; Generalizable (Stack a) where
--   name _ = "s"
--   expr s@(Stack x y) = constant "Stack" (Stack -&gt;&gt;: s) :$ expr x :$ expr y
--   expr s@Empty       = constant "Empty" (Empty   -: s)
--   instances s = this s $ instances (argTy1of1 s)
--   </pre>
--   
--   To declare <a>instances</a> and <a>expr</a> it may be useful to use:
--   
--   <ul>
--   <li>LeanCheck's <a>Test.LeanCheck.Utils.TypeBinding</a> operators:
--   <a>-:</a>, <a>-&gt;:</a>, <a>-&gt;&gt;:</a>, ...;</li>
--   <li>Extrapolate's <a>Test.Extrapolate.TypeBinding</a> operators:
--   <a>argTy1of1</a>, <a>argTy1of2</a>, <a>argTy2of2</a>, ....</li>
--   </ul>
class (Listable a, Typeable a, Show a) => Generalizable a

-- | Transforms a value into an manipulable expression tree. See
--   <a>constant</a> and <a>:$</a>.
expr :: Generalizable a => a -> Expr

-- | Common name for a variable, defaults to <tt>"x"</tt>.
name :: Generalizable a => a -> String

-- | List of symbols allowed to appear in side-conditions. Defaults to
--   <tt>[]</tt>. See <a>constant</a>.
background :: Generalizable a => a -> [Expr]

-- | Computes a list of reified instances. See <a>this</a>.
instances :: Generalizable a => a -> Instances -> Instances
this :: Generalizable a => a -> (Instances -> Instances) -> Instances -> Instances

-- | An encoded Haskell functional-application expression for use by
--   Speculate.
data Expr :: *
Constant :: String -> Dynamic -> Expr
Var :: String -> TypeRep -> Expr
(:$) :: Expr -> Expr -> Expr

-- | Encode a constant Haskell expression for use by Speculate. It takes a
--   string representation of a value and a value, returning an
--   <a>Expr</a>. Examples:
--   
--   <pre>
--   constant "0" 0
--   constant "'a'" 'a'
--   constant "True" True
--   constant "id" (id :: Int -&gt; Int)
--   constant "(+)" ((+) :: Int -&gt; Int -&gt; Int)
--   constant "sort" (sort :: [Bool] -&gt; [Bool])
--   </pre>
constant :: Typeable * a => String -> a -> Expr

-- | A shorthand for <a>constant</a> to be used on values that are
--   <a>Show</a> instances. Examples:
--   
--   <pre>
--   showConstant 0     =  constant "0" 0
--   showConstant 'a'   =  constant "'a'" 'a' 
--   showConstant True  =  constant "True" True
--   </pre>
showConstant :: (Typeable * a, Show a) => a -> Expr
bgEq :: (Eq a, Generalizable a) => a -> [Expr]
bgOrd :: (Ord a, Generalizable a) => a -> [Expr]
class Testable a

-- | Derives a <a>Generalizable</a> instance for a given type <a>Name</a>.
--   
--   Consider the following <tt>Stack</tt> datatype:
--   
--   <pre>
--   data Stack a = Stack a (Stack a) | Empty
--   </pre>
--   
--   Writing
--   
--   <pre>
--   deriveGeneralizable ''Stack
--   </pre>
--   
--   will automatically derive the following <a>Generalizable</a> instance:
--   
--   <pre>
--   instance Generalizable a =&gt; Generalizable (Stack a) where
--     expr s@(Stack x y) = constant "Stack" (Stack -&gt;&gt;: s) :$ expr x :$ expr y
--     expr s@Empty       = constant "Empty" (Empty   -: s)
--     instances s = this "s" s
--                 $ let Stack x y = Stack undefined undefined `asTypeOf` s
--                   in instances x
--                    . instances y
--   </pre>
--   
--   This function needs the <tt>TemplateHaskell</tt> extension.
deriveGeneralizable :: Name -> DecsQ

-- | Same as <a>deriveGeneralizable</a> but does not warn when instance
--   already exists (<a>deriveGeneralizable</a> is preferable).
deriveGeneralizableIfNeeded :: Name -> DecsQ

-- | Derives a <a>Generalizable</a> instance for a given type <a>Name</a>
--   cascading derivation of type arguments as well.
deriveGeneralizableCascading :: Name -> DecsQ
