Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- upTo :: Int -> Gen Int
- genSplit :: Int -> Gen (Int, Int)
- genSplit3 :: Int -> Gen (Int, Int, Int)
- genSplit4 :: Int -> Gen (Int, Int, Int, Int)
- genSplit5 :: Int -> Gen (Int, Int, Int, Int, Int)
- genSplit6 :: Int -> Gen (Int, Int, Int, Int, Int, Int)
- genSplit7 :: Int -> Gen (Int, Int, Int, Int, Int, Int, Int)
- genSplit8 :: Int -> Gen (Int, Int, Int, Int, Int, Int, Int, Int)
- arbPartition :: Int -> Gen [Int]
- shuffle :: [a] -> Gen [a]
- genListLength :: Gen Int
- genListOf :: Gen a -> Gen [a]
- genNonEmptyOf :: Gen a -> Gen (NonEmpty a)
- shrinkTuple :: (a -> [a]) -> (b -> [b]) -> (a, b) -> [(a, b)]
- shrinkT2 :: (a -> [a]) -> (a, a) -> [(a, a)]
- shrinkT3 :: (a -> [a]) -> (a, a, a) -> [(a, a, a)]
- shrinkT4 :: (a -> [a]) -> (a, a, a, a) -> [(a, a, a, a)]
- genIntX :: forall a. (Integral a, Bounded a, Random a) => Gen a
- genWordX :: forall a. (Integral a, Bounded a, Random a) => Gen a
- genFloat :: Gen Float
- genDouble :: Gen Double
- genFloatX :: forall a w. (Read a, RealFloat a, Bounded w, Random w) => (w -> a) -> Gen a
- genInteger :: Gen Integer
Helper functions for implementing generators
genSplit :: Int -> Gen (Int, Int) Source #
'genSplit a' generates a tuple '(b, c)' such that 'b + c' equals a
.
genSplit3 :: Int -> Gen (Int, Int, Int) Source #
'genSplit3 a' generates a triple '(b, c, d)' such that 'b + c + d' equals a
.
genSplit4 :: Int -> Gen (Int, Int, Int, Int) Source #
'genSplit4 a' generates a quadruple '(b, c, d, e)' such that 'b + c + d + e' equals a
.
genSplit5 :: Int -> Gen (Int, Int, Int, Int, Int) Source #
'genSplit5 a' generates a quintuple '(b, c, d, e, f)' such that 'b + c + d + e + f' equals a
.
genSplit6 :: Int -> Gen (Int, Int, Int, Int, Int, Int) Source #
'genSplit6 a' generates a sextuple '(b, c, d, e, f, g)' such that 'b + c + d + e + f + g' equals a
.
genSplit7 :: Int -> Gen (Int, Int, Int, Int, Int, Int, Int) Source #
'genSplit7 a' generates a septtuple '(b, c, d, e, f, g)' such that 'b + c + d + e + f + g' equals a
.
genSplit8 :: Int -> Gen (Int, Int, Int, Int, Int, Int, Int, Int) Source #
'genSplit8 a' generates a octtuple '(b, c, d, e, f, g, h)' such that 'b + c + d + e + f + g + h' equals a
.
arbPartition :: Int -> Gen [Int] Source #
'arbPartition n' generates a list ls
such that 'sum ls' equals n
, approximately.
genListLength :: Gen Int Source #
genListOf :: Gen a -> Gen [a] Source #
A version of listOf
that takes size into account more accurately.
This generator distributes the size that is is given among the values in the list that it generates.
Helper functions for implementing shrinking functions
shrinkTuple :: (a -> [a]) -> (b -> [b]) -> (a, b) -> [(a, b)] Source #
shrinkT2 :: (a -> [a]) -> (a, a) -> [(a, a)] Source #
Turn a shrinking function into a function that shrinks tuples.
shrinkT3 :: (a -> [a]) -> (a, a, a) -> [(a, a, a)] Source #
Turn a shrinking function into a function that shrinks triples.
shrinkT4 :: (a -> [a]) -> (a, a, a, a) -> [(a, a, a, a)] Source #
Turn a shrinking function into a function that shrinks quadruples.
genIntX :: forall a. (Integral a, Bounded a, Random a) => Gen a Source #
Generate Int, Int8, Int16, Int32 and Int64 values smartly.
- Some at the border
- Some around zero
- Mostly uniformly
genWordX :: forall a. (Integral a, Bounded a, Random a) => Gen a Source #
Generate Word, Word8, Word16, Word32 and Word64 values smartly.
- Some at the border
- Some around zero
- Mostly uniformly
genFloatX :: forall a w. (Read a, RealFloat a, Bounded w, Random w) => (w -> a) -> Gen a Source #
Generate floating point numbers smartly:
- Some denormalised
- Some around zero
- Some around the bounds
- Some by encoding an Integer and an Int to a floating point number.
- Some accross the entire range
- Mostly uniformly via the bitrepresentation
The function parameter is to go from the bitrepresentation to the floating point value.
genInteger :: Gen Integer Source #