fake-0.1: Randomly generated fake data

Safe HaskellSafe
LanguageHaskell2010

Fake.Combinators

Contents

Synopsis

Common generators and combinators

fromRange :: Random a => (a, a) -> FGen a Source #

Generates a random element in the given inclusive range.

pickAny :: Random a => FGen a Source #

Generates a random element over the natural range of a.

suchThat :: FGen a -> (a -> Bool) -> FGen a Source #

Generates a value that satisfies a predicate.

suchThatMaybe :: FGen a -> (a -> Bool) -> FGen (Maybe a) Source #

Tries to generate a value that satisfies a predicate.

oneof :: [FGen a] -> FGen a Source #

Randomly uses one of the given generators. The input list must be non-empty.

frequency :: [(Int, FGen a)] -> FGen a Source #

Chooses one of the given generators, with a weighted random distribution. The input list must be non-empty.

elements :: [a] -> FGen a Source #

Generates one of the given values. The input list must be non-empty.

sublistOf :: [a] -> FGen [a] Source #

Generates a random subsequence of the given list.

shuffle :: [a] -> FGen [a] Source #

Generates a random permutation of the given list.

listUpTo :: Int -> FGen a -> FGen [a] Source #

Generates a list of random length.

listUpTo1 :: Int -> FGen a -> FGen [a] Source #

Generates a non-empty list of random length. The maximum length depends on the size parameter.

vectorOf :: Int -> FGen a -> FGen [a] Source #

Generates a list of the given length.

infiniteListOf :: FGen a -> FGen [a] Source #

Generates an infinite list.

orderedList :: Ord a => Int -> FGen a -> FGen [a] Source #

Generates an ordered list.

fakeEnumFromTo :: Enum a => a -> a -> FGen a Source #

Generate a value of an enumeration in the range [from, to].

fakeEnum :: (Enum a, Bounded a) => FGen a Source #

Generate a value of an enumeration in the range [minBound, maxBound].

fakeInt :: Int -> Int -> FGen Int Source #

fakeEnumFromTo specialized to Int.