Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | sweirich@cis.upenn.edu |
A library of type-indexed functions
- subtrees :: forall a. Rep a => a -> [a]
- deepSeq :: Rep a => a -> b -> b
- rnf :: Rep a => a -> a
- class Rep1 GSumD a => GSum a where
- class Rep1 ZeroD a => Zero a where
- zero :: a
- class Rep1 GenerateD a => Generate a where
- class Rep1 EnumerateD a => Enumerate a where
- enumerate :: [a]
- class Rep1 ShrinkD a => Shrink a where
- shrink :: a -> [a]
- class Rep1 (LreduceD b) a => Lreduce b a where
- lreduce :: b -> a -> b
- class Rep1 (RreduceD b) a => Rreduce b a where
- rreduce :: a -> b -> b
- class Fold f where
- crush :: (Rep a, Fold t) => (a -> a -> a) -> a -> t a -> a
- gproduct :: (Rep a, Num a, Fold t) => t a -> a
- gand :: Fold t => t Bool -> Bool
- gor :: Fold t => t Bool -> Bool
- flatten :: (Rep a, Fold t) => t a -> [a]
- count :: (Rep a, Fold t) => t a -> Int
- comp :: (Rep a, Fold t) => t (a -> a) -> a -> a
- gconcat :: (Rep a, Fold t) => t [a] -> [a]
- gall :: (Rep a, Fold t) => (a -> Bool) -> t a -> Bool
- gany :: (Rep a, Fold t) => (a -> Bool) -> t a -> Bool
- gelem :: (Rep a, Eq a, Fold t) => a -> t a -> Bool
- data GSumD a = GSumD {}
- data ZeroD a = ZD {
- zeroD :: a
- data GenerateD a = GenerateD {}
- data EnumerateD a = EnumerateD {
- enumerateD :: [a]
- data ShrinkD a = ShrinkD {
- shrinkD :: a -> [a]
- data LreduceD b a = LreduceD {
- lreduceD :: b -> a -> b
- data RreduceD b a = RreduceD {
- rreduceD :: a -> b -> b
- rnfR :: R a -> a -> a
- deepSeqR :: R a -> a -> b -> b
- gsumR1 :: R1 GSumD a -> a -> Int
- zeroR1 :: R1 ZeroD a -> a
- generateR1 :: R1 GenerateD a -> Int -> [a]
- enumerateR1 :: R1 EnumerateD a -> [a]
- lreduceR1 :: R1 (LreduceD b) a -> b -> a -> b
- rreduceR1 :: R1 (RreduceD b) a -> a -> b -> b
Available for all representable types
subtrees :: forall a. Rep a => a -> [a]Source
Produce all children of a datastructure with the same type. Note that subtrees is available for all representable types. For those that are not recursive datatypes, subtrees will always return the empty list. But, these trivial instances are convenient to have for the Shrink operation below.
deepSeq :: Rep a => a -> b -> bSource
Recursively force the evaluation of the first
argument. For example,
deepSeq ( x , y ) z where
x = ...
y = ...
will evaluate both x
and y
then return z
Force the evaluation of *datatypes* to their normal forms. Other types are left alone and not forced.
Specializable type-indexed functions
class Rep1 GSumD a => GSum a whereSource
Add together all of the Int
s in a datastructure
For example:
gsum ( 1 , True, (a, Maybe 3, []) , Nothing)
4
class Rep1 ZeroD a => Zero a whereSource
Create a zero element of a type
( zero :: ((Int, Maybe Int), Float))
((0, Nothing), 0.0)
class Rep1 EnumerateD a => Enumerate a whereSource
enumerate the elements of a type, in DFS order.
class Rep1 ShrinkD a => Shrink a whereSource
Given an element, return smaller elements of the same type for example, to automatically find small counterexamples when testing
class Rep1 (LreduceD b) a => Lreduce b a whereSource
A general version of fold left, use for Fold class below
class Rep1 (RreduceD b) a => Rreduce b a whereSource
A general version of fold right, use for Fold class below
Generic operations based on Fold
All of the functions below are defined using instances of the following class
Fold [] |
crush :: (Rep a, Fold t) => (a -> a -> a) -> a -> t a -> aSource
Fold a bindary operation left over a datastructure
comp :: (Rep a, Fold t) => t (a -> a) -> a -> aSource
Compose all functions in the datastructure together
Auxiliary types and generators for derivable classes
generateR1 :: R1 GenerateD a -> Int -> [a]Source
enumerateR1 :: R1 EnumerateD a -> [a]Source