| Copyright | (c) 2017 Rudy Matela |
|---|---|
| License | 3-Clause BSD (see the file LICENSE) |
| Maintainer | Rudy Matela <rudy@matela.com.br> |
| Safe Haskell | None |
| Language | Haskell2010 |
Test.Extrapolate.Core
Description
This module is part of Extrapolate, a library for generalization of counter-examples.
This is the core of extrapolate.
- module Test.LeanCheck
- module Test.LeanCheck.Utils.TypeBinding
- module Test.Extrapolate.Exprs
- class (Listable a, Typeable a, Show a) => Generalizable a where
- this :: Generalizable a => a -> (Instances -> Instances) -> Instances -> Instances
- backgroundWith :: Typeable a => [Expr] -> a -> Instances
- (+++) :: Ord a => [a] -> [a] -> [a]
- 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
- data WithOption a = With {}
- 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
- matchList :: [Expr] -> [Expr] -> Maybe Binds
- newMatches :: [Expr] -> [Expr] -> Maybe Binds
- class Testable a where
- results :: Testable a => a -> [([Expr], Bool)]
- areInstancesOf :: [Expr] -> [Expr] -> Bool
Documentation
module Test.LeanCheck
module Test.Extrapolate.Exprs
class (Listable a, Typeable a, Show a) => Generalizable a where #
Extrapolate can generalize counter-examples of any types that are
Generalizable.
The core (and only required functions) of the generalizable typeclass are
the expr and instances functions.
The following example shows a datatype and its instance:
data Stack a = Stack a (Stack a) | Empty
instance Generalizable a => Generalizable (Stack a) where name _ = "s" expr s@(Stack x y) = constant "Stack" (Stack ->>: s) :$ expr x :$ expr y expr s@Empty = constant "Empty" (Empty -: s) instances s = this s $ instances (argTy1of1 s)
To declare instances and expr it may be useful to use:
- LeanCheck's Test.LeanCheck.Utils.TypeBinding operators:
-:,->:,->>:, ...; - Extrapolate's Test.Extrapolate.TypeBinding operators:
argTy1of1,argTy1of2,argTy2of2, ....
Methods
Common name for a variable, defaults to "x".
background :: a -> [Expr] #
List of symbols allowed to appear in side-conditions.
Defaults to []. See constant.
instances :: a -> Instances -> Instances #
Computes a list of reified instances. See this.
Instances
| Generalizable Bool # | |
| Generalizable Char # | |
| Generalizable Int # | |
| Generalizable Integer # | |
| Generalizable Ordering # | |
| Generalizable () # | |
| Generalizable a => Generalizable [a] # | |
| Generalizable a => Generalizable (Maybe a) # | |
| (Generalizable a, Generalizable b) => Generalizable (Either a b) # | |
| (Generalizable a, Generalizable b) => Generalizable (a, b) # | |
| (Generalizable a, Generalizable b, Generalizable c) => Generalizable (a, b, c) # | |
| (Generalizable a, Generalizable b, Generalizable c, Generalizable d) => Generalizable (a, b, c, d) # | |
backgroundWith :: Typeable a => [Expr] -> a -> Instances #
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] #
Constructors
| MaxTests Int | |
| ExtraInstances Instances | |
| MaxConditionSize Int | |
| MinFailures (Ratio Int) | |
| MaxSpeculateSize (Maybe Int) | |
| ConditionBound (Maybe Int) | |
| ConstantBound (Maybe Int) | |
| DepthBound (Maybe Int) |
data WithOption a #
Instances
| Testable a => Testable (WithOption a) # | |
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]] #
generalizations :: Instances -> [Expr] -> [[Expr]] #
theoryAndReprExprs :: Testable a => a -> (Thy, [Expr]) #
theoryAndReprConds :: Testable a => a -> (Thy, [Expr]) #
getBackground :: Instances -> [Expr] #
fullInstances :: Testable a => a -> Instances #
matchList :: [Expr] -> [Expr] -> Maybe Binds #
List matches of lists of expressions if possible
[0,1] `matchList` [x,y] = Just [x=0, y=1] [0,1+2] `matchList` [x,y+y] = Nothing
Minimal complete definition
areInstancesOf :: [Expr] -> [Expr] -> Bool #