Safe Haskell | None |
---|---|

Language | Haskell98 |

Functions for accessing the values of enumerations including compatibility with the property based testing framework QuickCheck

- optimal :: Enumerable a => Enumerate a
- index :: Enumerable a => Integer -> a
- select :: Enumerable a => Int -> Index -> a
- values :: Enumerable a => [(Integer, [a])]
- uniform :: Enumerable a => Int -> Gen a
- skipping :: Enumerate a -> Index -> Integer -> Enumerate a
- bounded :: Enumerate a -> Integer -> Enumerate a
- sizeRange :: Enumerate a -> (Int, Int) -> Enumerate a
- indexWith :: Enumerate a -> Integer -> a
- selectWith :: Enumerate a -> Int -> Index -> a
- valuesWith :: Enumerate a -> [(Integer, [a])]
- uniformWith :: Enumerate a -> Int -> Gen a

# Accessing functions

optimal :: Enumerable a => Enumerate a Source #

Memoised enumeration. Note that all cardinalities are kept in memory until your program terminates.

index :: Enumerable a => Integer -> a Source #

Index into an enumeration. Mainly used for party tricks (give it a really large number), since usually you want to distinguish values by size.

select :: Enumerable a => Int -> Index -> a Source #

A more fine grained version of index that takes a size and an
index into the values of that size. `select p i`

is only defined
for `i`

within bounds (meaning `i < fst (values !! p)`

).

values :: Enumerable a => [(Integer, [a])] Source #

All values of the enumeration by increasing cost (which is the number of constructors for most types). Also contains the length of each list.

# QuickCheck Compatibility

uniform :: Enumerable a => Int -> Gen a Source #

Compatibility with QuickCheck. Distribution is uniform generator over
values bounded by the given size. Typical use: `sized uniform`

.

# Combinators

skipping :: Enumerate a -> Index -> Integer -> Enumerate a Source #

Enumerates every nth value of the enumeration from a given starting index.
As a special case `striped 0 1`

gives all values (starts at index 0 and takes steps of 1).

Useful for running enumerations in parallel since e.g. `striped 0 2`

is
disjoint from `striped 1 2`

and the union of the two cover all values.

bounded :: Enumerate a -> Integer -> Enumerate a Source #

A version of values with a limited number of values in each inner list. If the list corresponds to a Part which is larger than the bound it evenly distributes the values across the enumeration of the Part.

sizeRange :: Enumerate a -> (Int, Int) -> Enumerate a Source #

Remove all sizes exept those in the given inclusive (low,high) range