Safe Haskell | None |
---|---|
Language | Haskell2010 |
- target :: Testable f => f -> String -> FilePath -> IO ()
- targetResult :: Testable f => f -> String -> FilePath -> IO Result
- targetWith :: Testable f => f -> String -> FilePath -> TargetOpts -> IO ()
- targetResultWith :: Testable f => f -> String -> FilePath -> TargetOpts -> IO Result
- targetTH :: Name -> FilePath -> ExpQ
- targetResultTH :: Name -> FilePath -> ExpQ
- targetWithTH :: Name -> FilePath -> TargetOpts -> ExpQ
- targetResultWithTH :: Name -> FilePath -> TargetOpts -> ExpQ
- data Result
- class (AllHave Targetable (Args f), Targetable (Res f), AllHave Show (Args f)) => Testable f
- class Targetable a where
- data TargetOpts = TargetOpts {}
- defaultOpts :: TargetOpts
- data Test = forall t . Testable t => T t
- monomorphic :: Name -> ExpQ
Documentation
:: Testable f | |
=> f | the function |
-> String | the name of the function |
-> FilePath | the path to the module that defines the function |
-> IO () |
Test whether a function inhabits its refinement type by enumerating valid inputs and calling the function.
targetWith :: Testable f => f -> String -> FilePath -> TargetOpts -> IO () Source
Like target
, but accepts options to control the enumeration depth,
solver, and verbosity.
targetResultWith :: Testable f => f -> String -> FilePath -> TargetOpts -> IO Result Source
Like targetWith
, but returns the Result
instead of printing to standard out.
targetResultTH :: Name -> FilePath -> ExpQ Source
targetWithTH :: Name -> FilePath -> TargetOpts -> ExpQ Source
targetResultWithTH :: Name -> FilePath -> TargetOpts -> ExpQ Source
class (AllHave Targetable (Args f), Targetable (Res f), AllHave Show (Args f)) => Testable f Source
A class of functions that Target can test. A function is Testable
iff
all of its component types are Targetable
and all of its argument types are
Show
able.
You should never have to define a new Testable
instance.
queryArgs, decodeArgs, apply, mkExprs
(Targetable a, (~) [*] (Args a) ([] *), (~) * (Res a) a) => Testable a | |
(Show a, Targetable a, Testable b) => Testable (a -> b) |
class Targetable a where Source
A class of datatypes for which we can efficiently generate constrained values by querying an SMT solver.
If possible, instances should not be written by hand, but rather by using the default implementations via GHC.Generics, e.g.
import GHC.Generics import Test.Target.Targetable data Foo = ... deriving Generic instance Targetable Foo
Nothing
query :: Proxy a -> Depth -> SpecType -> Target Symbol Source
Construct an SMT query describing all values of the given type up to the
given Depth
.
:: Symbol | the symbolic variable corresponding to the root of the value |
-> SpecType | the type of values we're generating (you can probably ignore this) |
-> Target a |
Reconstruct a Haskell value from the SMT model.
check :: a -> SpecType -> Target (Bool, Expr) Source
Check whether a Haskell value inhabits the given type. Also returns a logical expression corresponding to the Haskell value.
Translate a Haskell value into a logical expression.
getType :: Proxy a -> Sort Source
What is the Haskell type? (Mainly used to make the SMT queries more readable).
Targetable Bool | |
Targetable Char | |
Targetable Int | |
Targetable Integer | |
Targetable Word8 | |
Targetable () | |
Targetable a => Targetable [a] | |
Targetable a => Targetable (Maybe a) | |
(Targetable a, Targetable b, Targetable c, Targetable d, (~) * d (Res (a -> b -> c -> d))) => Targetable (a -> b -> c -> d) | |
(Targetable a, Targetable b, Targetable c, (~) * c (Res (a -> b -> c))) => Targetable (a -> b -> c) | |
(Targetable a, Targetable b, (~) * b (Res (a -> b))) => Targetable (a -> b) | |
(Targetable a, Targetable b) => Targetable (Either a b) | |
(Targetable a, Targetable b) => Targetable (a, b) | |
(Targetable a, Targetable b, Targetable c) => Targetable (a, b, c) | |
(Targetable a, Targetable b, Targetable c, Targetable d) => Targetable (a, b, c, d) |
data TargetOpts Source
TargetOpts | |
|
monomorphic :: Name -> ExpQ
Monomorphise an arbitrary property by defaulting all type variables to Integer
.
For example, if f
has type
then Ord
a => [a] -> [a]$(
has type monomorphic
'f)[
.Integer
] -> [Integer
]
If you want to use monomorphic
in the same file where you defined the
property, the same scoping problems pop up as in quickCheckAll
:
see the note there about return []
.