Module

Jack.Tree

Package
purescript-jack
Repository
jystic/purescript-jack

#Tree Source

data Tree a

A rose tree which represents a random generated outcome, and all the ways in which it can be made smaller.

This tree is exactly the same as 'Data.Tree' in every way except that Applicative '<*>' and Monad '>>=' walk the tree in the reverse order. This modification is critical for shrinking to reach a minimal counterexample.

Constructors

Instances

#outcome Source

outcome :: forall a. Tree a -> a

The generated outcome.

#shrinks Source

shrinks :: forall a. Tree a -> List (Tree a)

All the possible shrinks of this outcome. This should be ordered smallest to largest as if property still fails with the first shrink in the list then we will commit to that path and none of the others will be tried (i.e. there is no backtracking).

#foldTree Source

foldTree :: forall x b a. (a -> x -> b) -> (List b -> x) -> Tree a -> b

Fold over a 'Tree'.

#foldForest Source

foldForest :: forall x b a. (a -> x -> b) -> (List b -> x) -> List (Tree a) -> x

Fold over a list of trees.

#unfoldTree Source

unfoldTree :: forall b a. (b -> a) -> (b -> List b) -> b -> Tree a

Build a 'Tree' from an unfolding function and a seed value.

#unfoldForest Source

unfoldForest :: forall b a. (b -> a) -> (b -> List b) -> b -> List (Tree a)

Build a list of trees from an unfolding function and a seed value.

#expandTree Source

expandTree :: forall a. (a -> List a) -> Tree a -> Tree a

Apply an additional unfolding function to an existing tree.

The root outcome remains intact, only the shrinks are affected, this applies recursively, so shrinks can only ever be added using this function.

If you want to replace the shrinks altogether, try:

unfoldTree f (outcome oldTree)

#filterTree Source

filterTree :: forall a. (a -> Boolean) -> Tree a -> Tree a

Recursively discard any shrinks whose outcome does not pass the predicate. /Note that the root outcome can never be discarded./

#filterForest Source

filterForest :: forall a. (a -> Boolean) -> List (Tree a) -> List (Tree a)

Recursively discard any trees whose outcome does not pass the predicate.