| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Falsify.SampleTree
Description
Sample tree
Intended for qualified import.
import Test.Falsify.SampleTree (SampleTree(..), pattern Inf, Sample(..)) import qualified Test.Falsify.SampleTree as SampleTree
Synopsis
- data SampleTree
- data Sample
- pattern Inf :: Sample -> SampleTree -> SampleTree -> SampleTree
- sampleValue :: Sample -> Word64
- fromPRNG :: SMGen -> SampleTree
- fromSeed :: Word64 -> SampleTree
- minimal :: SampleTree
- constant :: Word64 -> SampleTree
- map :: (Word64 -> Word64) -> SampleTree -> SampleTree
- mod :: Word64 -> SampleTree -> SampleTree
Definition
data SampleTree Source #
Sample tree
A sample tree is a (conceptually and sometimes actually) infinite tree representing drawing values from and splitting a PRNG.
Constructors
| SampleTree Sample SampleTree SampleTree | Default constructor The type of ST is really ST :: Word64 & (SampleTree * SampleTree) -> SampleTree where |
| Minimal | Minimal tree (0 everywhere) This constructor allows us to represent an infinite tree in a finite way and, importantly, recognize a tree that is minimal everywhere. This is necessary when shrinking in the context of generators that generate infinitely large values. |
Instances
| Show SampleTree Source # | |
Defined in Test.Falsify.SampleTree Methods showsPrec :: Int -> SampleTree -> ShowS # show :: SampleTree -> String # showList :: [SampleTree] -> ShowS # | |
Sample
The samples in the SampleTree record if they were the originally produced
sample, or whether they have been shrunk.
pattern Inf :: Sample -> SampleTree -> SampleTree -> SampleTree Source #
Pattern synonym for treating the sample tree as infinite
sampleValue :: Sample -> Word64 Source #
Construction
fromPRNG :: SMGen -> SampleTree Source #
Construct SampleTree from splittable PRNG
fromSeed :: Word64 -> SampleTree Source #
Consruct SampleTree from initial seed
The seed will be used to initialize an SMGen
minimal :: SampleTree Source #
Minimal sample tree
Generators should produce the "simplest" value when given this tree, for some suitable application-specific definition of "simple".
constant :: Word64 -> SampleTree Source #
Sample tree that is the given value everywhere
This is primarily useful for debugging.
Combinators
map :: (Word64 -> Word64) -> SampleTree -> SampleTree Source #
Map function over all random samples in the tree
Precondition: the function must preserve zeros:
f 0 == 0
This means that we have
map f M == M
This is primarily useful for debugging.
mod :: Word64 -> SampleTree -> SampleTree Source #
Apply mod m at every sample in the tree
This is primarily useful for debugging.