StrictCheck-0.3.0: StrictCheck: Keep Your Laziness In Check

Safe HaskellNone
LanguageHaskell2010

Test.StrictCheck.Internal.Shrink

Contents

Description

Internal module: This module does not make any stability guarantees, and may not adhere to the PVP.

This module defines several utilities useful for shrinking demands and evaluations.

Of these, only axialShrinks and fairInterleave are used by StrictCheck; nevertheless, we expose the DZipper type and its associated functions in this internal module just in case.

Synopsis

Documentation

newtype Shrink a Source #

Newtype allowing us to construct NP n-ary products of shrinkers

Constructors

Shrink (a -> [a]) 

axialShrinks :: SListI xs => NP Shrink xs -> NP I xs -> [[NP I xs]] Source #

Given a list of shrinkers and a list of values-to-be-shrunk, generate a list of shrunken lists-of-values, each inner list being one potential "axis" for shrinking

That is, the first element of the result is all the ways the original product could be shrunken by only shrinking its first component, etc.

fairInterleave :: [[a]] -> [a] Source #

Fairly interleave a list of lists in a round-robin fashion

CPS-based zippers through heterogeneous products

data DZipper f whole where Source #

A DZipper is a suspended traversal through a non-empty NP n-ary product

The position of the traversal within that product is existentially quantified.

Constructors

DZipper :: (NP f (c ': rs) -> NP f whole) -> f c -> NP f rs -> DZipper f whole 

next :: DZipper f whole -> Maybe (DZipper f whole) Source #

Step one to the right in a DZipper, returning Nothing if this is not possible

positions :: NP f xs -> [DZipper f xs] Source #

Given an n-ary product of xs, get a list of DZippers, each focused in sequence on the values of the input product

This is similar to the duplicate operation on comonads.

dzipper :: NP f xs -> Maybe (DZipper f xs) Source #

Convert an n-ary product into a DZipper, returning Nothing if the input product is empty

dzip :: DZipper f xs -> NP f xs Source #

Collapse a DZipper back into the n-ary product it represents