StrictCheck-0.1.0: StrictCheck: Keep Your Laziness In Check

Safe HaskellNone
LanguageHaskell2010

Test.StrictCheck.Consume

Contents

Description

This module defines the Consume typeclass, used for incrementally destructing inputs to random non-strict functions.

Calling consume on some value lazily returns an abstract type of Input, which contains all the entropy present in the original value. Paired with Produce, these Input values can be used to generate random non-strict functions, whose strictness behavior is dependent on the values given to them.

Synopsis

Incrementally consuming input

data Input Source #

A tree representing all possible destruction sequences for a value Unfolding the contained lists forces a particular random control path for destructing the datatype.

data Inputs Source #

A list of inputs given to a function, in abstract form. This lazy structure is evaluated piecewise during the course of producing a function, thus triggering the partial evaluation of the original input to the function.

class Consume a where Source #

Lazily monomorphize some input value, by converting it into an Input. This is an incremental version of QuickCheck's CoArbitrary typeclass. It can also be seen as a generalization of the NFData class.

Instances of Consume can be derived automatically for any type implementing the Generic class from GHC.Generics. Using the DeriveAnyClass extension, we can say:

import GHC.Generics as GHC
import Generics.SOP as SOP

data D x y
  = A
  | B (x, y)
  deriving (GHC.Generic, SOP.Generic, Consume)

This automatic derivation follows these rules, which you can follow too if you're manually writing an instance for some type which is not Generic:

For each distinct constructor, make a single call to constructor with a distinct Int, and a list of Inputs, each created by recursively calling consume on every field in that constructor. For abstract types (e.g. sets), the same procedure can be used upon an extracted list representation of the contents.

Methods

consume :: a -> Input Source #

Convert an a into an Input by recursively destructing it using calls to consume

consume :: GConsume a => a -> Input Source #

Convert an a into an Input by recursively destructing it using calls to consume

Instances

Consume Bool Source # 

Methods

consume :: Bool -> Input Source #

Consume Char Source # 

Methods

consume :: Char -> Input Source #

Consume Double Source # 

Methods

consume :: Double -> Input Source #

Consume Float Source # 

Methods

consume :: Float -> Input Source #

Consume Int Source # 

Methods

consume :: Int -> Input Source #

Consume Integer Source # 
Consume Ordering Source # 
Consume Rational Source # 
Consume Word Source # 

Methods

consume :: Word -> Input Source #

Consume () Source # 

Methods

consume :: () -> Input Source #

Consume IntSet Source # 

Methods

consume :: IntSet -> Input Source #

Consume Key Source # 

Methods

consume :: Key -> Input Source #

Consume a => Consume [a] Source # 

Methods

consume :: [a] -> Input Source #

Consume a => Consume (Maybe a) Source # 

Methods

consume :: Maybe a -> Input Source #

(CoArbitrary a, RealFloat a) => Consume (Complex a) Source # 

Methods

consume :: Complex a -> Input Source #

Consume a => Consume (NonEmpty a) Source # 

Methods

consume :: NonEmpty a -> Input Source #

Consume v => Consume (IntMap v) Source # 

Methods

consume :: IntMap v -> Input Source #

Consume a => Consume (Tree a) Source # 

Methods

consume :: Tree a -> Input Source #

Consume v => Consume (Seq v) Source # 

Methods

consume :: Seq v -> Input Source #

Consume v => Consume (Set v) Source # 

Methods

consume :: Set v -> Input Source #

Consume (a -> b) Source # 

Methods

consume :: (a -> b) -> Input Source #

(Consume a, Consume b) => Consume (Either a b) Source # 

Methods

consume :: Either a b -> Input Source #

(Consume a, Consume b) => Consume (a, b) Source # 

Methods

consume :: (a, b) -> Input Source #

Consume (Proxy k p) Source # 

Methods

consume :: Proxy k p -> Input Source #

Consume v => Consume (Map k v) Source # 

Methods

consume :: Map k v -> Input Source #

(Consume v, Consume k) => Consume (Map k v) Source # 

Methods

consume :: Map k v -> Input Source #

(Consume a, Consume b, Consume c) => Consume (a, b, c) Source # 

Methods

consume :: (a, b, c) -> Input Source #

(Consume a, Consume b, Consume c, Consume d) => Consume (a, b, c, d) Source # 

Methods

consume :: (a, b, c, d) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e) => Consume (a, b, c, d, e) Source # 

Methods

consume :: (a, b, c, d, e) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f) => Consume (a, b, c, d, e, f) Source # 

Methods

consume :: (a, b, c, d, e, f) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g) => Consume (a, b, c, d, e, f, g) Source # 

Methods

consume :: (a, b, c, d, e, f, g) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h) => Consume (a, b, c, d, e, f, g, h) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i) => Consume (a, b, c, d, e, f, g, h, i) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j) => Consume (a, b, c, d, e, f, g, h, i, j) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k) => Consume (a, b, c, d, e, f, g, h, i, j, k) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l) => Consume (a, b, c, d, e, f, g, h, i, j, k, l) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o, Consume p) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o, Consume p, Consume q) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o, Consume p, Consume q, Consume r) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o, Consume p, Consume q, Consume r, Consume s) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o, Consume p, Consume q, Consume r, Consume s, Consume t) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o, Consume p, Consume q, Consume r, Consume s, Consume t, Consume u) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o, Consume p, Consume q, Consume r, Consume s, Consume t, Consume u, Consume v) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o, Consume p, Consume q, Consume r, Consume s, Consume t, Consume u, Consume v, Consume w) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o, Consume p, Consume q, Consume r, Consume s, Consume t, Consume u, Consume v, Consume w, Consume x) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o, Consume p, Consume q, Consume r, Consume s, Consume t, Consume u, Consume v, Consume w, Consume x, Consume y) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y) -> Input Source #

(Consume a, Consume b, Consume c, Consume d, Consume e, Consume f, Consume g, Consume h, Consume i, Consume j, Consume k, Consume l, Consume m, Consume n, Consume o, Consume p, Consume q, Consume r, Consume s, Consume t, Consume u, Consume v, Consume w, Consume x, Consume y, Consume z) => Consume (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) Source # 

Methods

consume :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) -> Input Source #

Manually writing Consume instances

constructor :: Int -> [Input] -> Input Source #

Reassemble pieces of input into a larger Input: this is to be called on the result of consume-ing subparts of input

normalize :: Consume a => a -> () Source #

Fully normalize something which can be consumed

consumeTrivial :: a -> Input Source #

Consume a type which has no observable structure whatsoever

This should only be used for types for which there is only one inhabitant, or for which inhabitants cannot be distinguished at all.

consumePrimitive :: CoArbitrary a => a -> Input Source #

Use the CoArbitrary instance for a type to consume it

This should only be used for "flat" types, i.e. those which contain no interesting consumable substructure, as it's fully strict (non-incremental)

Generically deriving Consume instances

type GConsume a = (Generic a, All2 Consume (Code a)) Source #

The constraints necessary to generically consume something

gConsume :: GConsume a => a -> Input Source #

Generic consume