Functions for accessing the values of enumerations including compatibility with the property based testing frameworks QuickCheck and SmallCheck.
- index :: Enumerable a => Integer -> a
- values :: Enumerable a => [(Integer, [a])]
- striped :: Enumerable a => Index -> Integer -> [(Integer, [a])]
- bounded :: Enumerable a => Integer -> [(Integer, [a])]
- featCheck :: (Enumerable a, Show a) => Int -> (a -> Bool) -> IO ()
- ioFeat :: [(Integer, [a])] -> Report a -> IO ()
- ioAll :: Enumerable a => Int -> Report a -> IO ()
- ioBounded :: Enumerable a => Integer -> Int -> Report a -> IO ()
- type Report a = a -> IO ()
- inputRep :: Show a => (a -> Bool) -> Report a
- prePostRep :: (Show a, Show b) => (a -> b) -> (a -> b -> Bool) -> Report a
- uniform :: Enumerable a => Int -> Gen a
- toSeries :: Enumerable a => Int -> [a]
- valuesWith :: Enumerate a -> [(Integer, [a])]
- stripedWith :: Enumerate a -> Index -> Integer -> [(Integer, [a])]
- boundedWith :: Enumerate a -> Integer -> [(Integer, [a])]
- uniformWith :: Enumerate a -> Int -> Gen a
- toSeriesWith :: Enumerate a -> Int -> [a]
Mainly as a proof of concept (if this is repeated multiple times it might be very inefficient, depending on whether the dictionary for the Enumerable is shared or not) we define a function to index into an enumeration.
All values of the enumeration by increasing cost (which is the number of constructors for most types). Also contains the cardinality of each list.
A generalisation of
values that enumerates every nth value of the
enumeration from a given starting point.
As a special case
values = striped 0 1.
Useful for running enumerations in parallel since e.g.
striped 0 2 is
striped 0 1 2 and the union of the two cover all values.
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.
A simple property tester
A rather simple but general property testing driver. The property is an (funcurried) IO function that both tests and reports the error. The driver goes on forever or until the list is exhausted, reporting its progress and the number of tests before each new part.
Reports counterexamples to the given predicate by printing them
Takes a function and a predicate on its input/output pairs. Reports counterexamples by printing the failing input/output pair.
Compatibility with QuickCheck. Distribution is uniform generator over
values bounded by the given size. Typical use:
Non-class versions of the access functions
Non class version of