-- 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 xs -> nub xs == (xs::[Int]): -- -- @package extrapolate @version 0.2.0 -- | 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 argTypes0 :: a -> a argTypes1 :: (a -> b) -> a -> (a -> b) argTypes2 :: (a -> b -> c) -> a -> b -> (a -> b -> c) argTypes3 :: (a -> b -> c -> d) -> a -> b -> c -> (a -> b -> c -> d) argTypes4 :: (a -> b -> c -> d -> e) -> a -> b -> c -> d -> (a -> b -> c -> d -> e) argTypes5 :: (a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> (a -> b -> c -> d -> e -> f) argTypes6 :: (a -> b -> c -> d -> e -> f -> g) -> a -> b -> c -> d -> e -> f -> (a -> b -> c -> d -> e -> f -> g) argTypes7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> a -> b -> c -> d -> e -> f -> g -> (a -> b -> c -> d -> e -> f -> g -> h) argTypes8 :: (a -> b -> c -> d -> e -> f -> g -> h -> i) -> a -> b -> c -> d -> e -> f -> g -> h -> (a -> b -> c -> d -> e -> f -> g -> h -> i) argTypes9 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) argTypes10 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) argTypes11 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l) argTypes12 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m) argTys1 :: con a -> a -> con a argTys2 :: con a b -> a -> b -> con a b 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. -- -- 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 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. -- -- This is the core of extrapolate. module Test.Extrapolate.Core -- | 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: -- -- class (Listable a, Typeable a, Show a) => Generalizable a where name _ = "x" background _ = [] -- | Transforms a value into an manipulable expression tree. See -- constant and :$. expr :: Generalizable a => a -> Expr -- | Common name for a variable, defaults to "x". name :: Generalizable a => a -> String -- | List of symbols allowed to appear in side-conditions. Defaults to -- []. See constant. background :: Generalizable a => a -> [Expr] -- | Computes a list of reified instances. See this. 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] data Option MaxTests :: Int -> Option ExtraInstances :: Instances -> Option MaxConditionSize :: Int -> Option options :: Testable a => a -> Options 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 counterExampleGen :: Testable a => Int -> a -> Maybe ([Expr], Maybe [Expr]) counterExampleGens :: Testable a => Int -> a -> Maybe ([Expr], [[Expr]]) generalizationsCE :: Testable a => Int -> a -> [Expr] -> [[Expr]] generalizationsCEC :: Testable a => Int -> a -> [Expr] -> [(Expr, [Expr])] generalizationsCounts :: Testable a => Int -> a -> [Expr] -> [([Expr], Int)] conditionalGeneralization :: Testable a => Int -> a -> [Expr] -> [Expr] -> Maybe ([Expr], [Expr]) -- | 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
--   
matchList :: [Expr] -> [Expr] -> Maybe Binds newMatches :: [Expr] -> [Expr] -> Maybe Binds class Testable a where options _ = [] options :: Testable a => a -> Options results :: Testable a => a -> [([Expr], Bool)] areInstancesOf :: [Expr] -> [Expr] -> Bool expressionsT :: [Expr] -> [[Expr]] instance GHC.Show.Show Test.Extrapolate.Core.Option 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 [a] instance Test.Extrapolate.Core.Generalizable GHC.Types.Ordering 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) -- | This module is part of Extrapolate, a library for generalization of -- counter-examples. -- -- This is a module for deriving Generalizable 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 Generalizable instance for a given type Name. -- -- Consider the following Stack datatype: -- --
--   data Stack a = Stack a (Stack a) | Empty
--   
-- -- Writing -- --
--   deriveGeneralizable ''Stack
--   
-- -- will automatically derive the following Generalizable instance: -- --
--   instance Generalizable a => Generalizable (Stack a) where
--     expr s@(Stack x y) = constant "Stack" (Stack ->>: 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
--   
-- -- This function needs the TemplateHaskell extension. deriveGeneralizable :: Name -> DecsQ -- | Same as deriveGeneralizable but does not warn when instance -- already exists (deriveGeneralizable is preferable). deriveGeneralizableIfNeeded :: Name -> DecsQ -- | Derives a Generalizable instance for a given type Name -- 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. -- -- QuickCheck-like interface. module Test.Extrapolate.IO -- | Checks a property printing results on stdout -- --
--   > check $ \xs -> sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 360 tests.
--   
--   > check $ \xs ys -> xs `union` ys == ys `union` (xs::[Int])
--   *** Failed! Falsifiable (after 4 tests):
--   [] [0,0]
--   
--   Generalization:
--   [] (x:x:_)
--   
check :: Testable a => a -> IO () -- | Check a property printing results on stdout and returning -- True on success. -- -- There is no option to silence this function: for silence, you should -- use holds. checkResult :: Testable a => a -> IO Bool -- | Use for to configure the number of tests performed by -- check. -- --
--   > check `for` 10080 $ \xs -> sort (sort xs) == sort (xs :: [Int])
--   +++ OK, passed 10080 tests.
--   
-- -- Don't forget the dollar ($)! 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 withBackground to provide additional functions to -- appear in side-conditions. -- --
--   check `withBackground` [constant "isSpace" isSpace] $ \xs -> unwords (words xs) == xs
--   *** Failed! Falsifiable (after 4 tests):
--   " "
--   
--   Generalization:
--   ' ':_
--   
--   Conditional Generalization:
--   c:_  when  isSpace c
--   
withBackground :: Testable a => (WithOption a -> b) -> [Expr] -> a -> b -- | Use withConditionSize to configure the maximum -- condition size allowed. withConditionSize :: Testable a => (WithOption a -> b) -> 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 provides the basic functionality of extrapolate. You will have -- better luck importing Test.Extrapolate directly. module Test.Extrapolate.Basic instance (GHC.Real.Integral a, Test.Extrapolate.Core.Generalizable a) => Test.Extrapolate.Core.Generalizable (GHC.Real.Ratio a) -- | Extrapolate is a property-based testing library capable of reporting -- generalized counter-examples. -- -- Consider the following faulty implementation of sort: -- --
--   sort :: Ord a => [a] -> [a]
--   sort []      =  []
--   sort (x:xs)  =  sort (filter (< x) xs)
--                ++ [x]
--                ++ sort (filter (> x) xs)
--   
-- -- When tests pass, Extrapolate works like a regular property-based -- testing library. See: -- --
--   > check $ \xs -> sort (sort xs :: [Int]) == sort xs
--   +++ OK, passed 360 tests.
--   
-- -- When tests fail, Extrapolate reports a fully defined counter-example -- and a generalization of failing inputs. See: -- --
--   > > check $ \xs -> length (sort xs :: [Int]) == length xs
--   *** Failed! Falsifiable (after 3 tests):
--   [0,0]
--   
--   Generalization:
--   x:x:_
--   
-- -- The property fails for any integer x and for any list -- _ at the tail. module Test.Extrapolate -- | Checks a property printing results on stdout -- --
--   > check $ \xs -> sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 360 tests.
--   
--   > check $ \xs ys -> xs `union` ys == ys `union` (xs::[Int])
--   *** Failed! Falsifiable (after 4 tests):
--   [] [0,0]
--   
--   Generalization:
--   [] (x:x:_)
--   
check :: Testable a => a -> IO () -- | Check a property printing results on stdout and returning -- True on success. -- -- There is no option to silence this function: for silence, you should -- use holds. checkResult :: Testable a => a -> IO Bool -- | Use for to configure the number of tests performed by -- check. -- --
--   > check `for` 10080 $ \xs -> sort (sort xs) == sort (xs :: [Int])
--   +++ OK, passed 10080 tests.
--   
-- -- Don't forget the dollar ($)! for :: Testable a => (WithOption a -> b) -> Int -> a -> b -- | Use withBackground to provide additional functions to -- appear in side-conditions. -- --
--   check `withBackground` [constant "isSpace" isSpace] $ \xs -> unwords (words xs) == xs
--   *** Failed! Falsifiable (after 4 tests):
--   " "
--   
--   Generalization:
--   ' ':_
--   
--   Conditional Generalization:
--   c:_  when  isSpace c
--   
withBackground :: Testable a => (WithOption a -> b) -> [Expr] -> a -> b -- | Use withConditionSize to configure the maximum -- condition size allowed. withConditionSize :: Testable a => (WithOption a -> b) -> Int -> a -> b -- | 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: -- -- class (Listable a, Typeable a, Show a) => Generalizable a where name _ = "x" background _ = [] -- | Transforms a value into an manipulable expression tree. See -- constant and :$. expr :: Generalizable a => a -> Expr -- | Common name for a variable, defaults to "x". name :: Generalizable a => a -> String -- | List of symbols allowed to appear in side-conditions. Defaults to -- []. See constant. background :: Generalizable a => a -> [Expr] -- | Computes a list of reified instances. See this. 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 -- Expr. Examples: -- --
--   constant "0" 0
--   constant "'a'" 'a'
--   constant "True" True
--   constant "id" (id :: Int -> Int)
--   constant "(+)" ((+) :: Int -> Int -> Int)
--   constant "sort" (sort :: [Bool] -> [Bool])
--   
constant :: Typeable * a => String -> a -> Expr -- | A shorthand for constant to be used on values that are -- Show instances. Examples: -- --
--   showConstant 0     =  constant "0" 0
--   showConstant 'a'   =  constant "'a'" 'a' 
--   showConstant True  =  constant "True" True
--   
showConstant :: (Typeable * a, Show a) => a -> Expr bgEq :: (Eq a, Generalizable a) => a -> [Expr] bgOrd :: (Ord a, Generalizable a) => a -> [Expr] class Testable a where options _ = [] -- | Derives a Generalizable instance for a given type Name. -- -- Consider the following Stack datatype: -- --
--   data Stack a = Stack a (Stack a) | Empty
--   
-- -- Writing -- --
--   deriveGeneralizable ''Stack
--   
-- -- will automatically derive the following Generalizable instance: -- --
--   instance Generalizable a => Generalizable (Stack a) where
--     expr s@(Stack x y) = constant "Stack" (Stack ->>: 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
--   
-- -- This function needs the TemplateHaskell extension. deriveGeneralizable :: Name -> DecsQ -- | Same as deriveGeneralizable but does not warn when instance -- already exists (deriveGeneralizable is preferable). deriveGeneralizableIfNeeded :: Name -> DecsQ -- | Derives a Generalizable instance for a given type Name -- cascading derivation of type arguments as well. deriveGeneralizableCascading :: Name -> DecsQ ordering :: Ordering