smartcheck-0.2: A smarter QuickCheck.

Safe HaskellNone

Test.SmartCheck.Types

Contents

Synopsis

Documentation

data SubT Source

Constructors

forall a . (Arbitrary a, SubTypes a) => SubT 

Fields

unSubT :: a
 

Instances

subT :: (Arbitrary a, SubTypes a) => a -> SubTSource

data Result a Source

Possible results of iterateArb.

Constructors

FailedPreCond

Couldn't satisfy the precondition of a QuickCheck property

FailedProp

Failed the property---either we expect failure and it passes or we expect to pass it and we fail.

Result a

Satisfied it, with the satisfying value.

Instances

class (Arbitrary a, Show a, Typeable a) => SubTypes a whereSource

This class covers algebraic datatypes that can be transformed into Trees. subTypes is the main method, placing values into trees.

for a datatype with constructors A and C,

 subTypes (A (C 0) 1)
 [Node {rootLabel = C 0, subForest = []}]

Methods

subTypes :: a -> Forest SubTSource

baseType :: a -> BoolSource

replaceChild :: Typeable b => a -> Forest Subst -> b -> Maybe aSource

Generically replace child i in m with value s. A total function: returns Nothing if you try to replace a child with an ill-typed child s. (Returns Just (the original data) if your index is out of bounds).

toConstr :: a -> StringSource

showForest :: a -> Forest StringSource

showForest generically shows a value while preserving its structure (in a Tree). You should always end up with either a singleton list containing the tree or an empty list for baseTypes. Also, it must be the case that for a value v,

null (subTypes v) iff null (showForest v) and if not . null (subTypes v), then subForest . head (showForest v) has the same structure as subTypes v.

We can't just return a Tree String or Maybe (Tree String). The reason is that in generically constructing the value, we have to deal with product types. There is no sane way to join them other than list-like concatenation (i.e., gsf (a :*: b) = gsf a ++ gsf b).

data Idx Source

Index into a Tree/Forest, where level is the depth from the root and column is the distance d is the dth value on the same level. Thus, all left-most nodes are in column 0. This is a matrix view of tree-structured data.

Constructors

Idx 

Fields

level :: Int
 
column :: Int
 

Instances

Eq Idx 
Ord Idx

Sort in order of depth first then left to right.

Show Idx 

data Subst Source

Keep or substitue a value in the tree.

Constructors

Keep 
Subst 

Instances

data Replace a Source

Nominally, a list for value generalization indexes and existential generalization.

Constructors

Replace 

Fields

unVals :: [a]
 
unConstrs :: [a]
 

Instances

Eq a => Eq (Replace a) 
Read a => Read (Replace a) 
Show a => Show (Replace a) 

For constructing new instances of SubTypes

gst :: GST f => f a -> Forest SubTSource

grc :: (GST f, Typeable b) => f a -> Forest Subst -> b -> Maybe (f a)Source

gtc :: GST f => f a -> StringSource

gsf :: GST f => f a -> Forest StringSource

gsz :: GST f => f a -> IntSource