HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulegenvalidity-1.1.1.0Haskell2010

Data.GenValidity.Utils

  • 32 values

Helper functions for implementing generators

23 declarations
valuegenSplit :: Int -> Gen (Int, Int)
#

'genSplit a' generates a tuple '(b, c)' such that 'b + c' equals a.

valuegenSplit3 :: Int -> Gen (Int, Int, Int)
#

'genSplit3 a' generates a triple '(b, c, d)' such that 'b + c + d' equals a.

valuegenSplit4 :: Int -> Gen (Int, Int, Int, Int)
#

'genSplit4 a' generates a quadruple '(b, c, d, e)' such that 'b + c + d + e' equals a.

valuearbPartition :: Int -> Gen [Int]
#

'arbPartition n' generates a list ls such that 'sum ls' equals n, approximately.

valueshuffle :: [a] -> Gen [a]
#

Generates a random permutation of the given list.

valuegenListOf :: Gen a -> Gen [a]
#

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.

valuegenIntX :: (Integral a, Bounded a, Random a) => Gen a
#

Generate Int, Int8, Int16, Int32 and Int64 values smartly.

  • Some at the border

  • Some around zero

  • Mostly uniformly

valuegenWordX :: (Integral a, Bounded a, Random a) => Gen a
#

Generate Word, Word8, Word16, Word32 and Word64 values smartly.

  • Some at the border

  • Some around zero

  • Mostly uniformly

valuegenFloatX :: (Read a, RealFloat a, Bounded w, Random w) => (w -> a) -> Gen a
#

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.

Helper functions for implementing shrinking functions

9 declarations
valueshrinkTuple :: (a -> [a]) -> (b -> [b]) -> (a, b) -> [(a, b)]
#

Combine two shrinking functions to shrink a tuple.

valueshrinkQuadruple
  1. :: a -> [a]
  2. -> b -> [b]
  3. -> c -> [c]
  4. -> d -> [d]
  5. -> (a, b, c, d)
  6. -> [(a, b, c, d)]
#

Like shrinkTuple, but for quadruples

valueshrinkT2 :: (a -> [a]) -> (a, a) -> [(a, a)]
#

Turn a shrinking function into a function that shrinks tuples.

valueshrinkT3 :: (a -> [a]) -> (a, a, a) -> [(a, a, a)]
#

Turn a shrinking function into a function that shrinks triples.

valueshrinkT4 :: (a -> [a]) -> (a, a, a, a) -> [(a, a, a, a)]
#

Turn a shrinking function into a function that shrinks quadruples.

valueshrinkList :: (a -> [a]) -> [a] -> [[a]]
#

Shrink a list of values given a shrinking function for individual values.