fakedata-0.3.0: Library for producing fake data

Safe HaskellNone
LanguageHaskell2010

Faker.Combinators

Synopsis

Documentation

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

Generates a random element in the given inclusive range.

pickAny :: Random a => Fake a Source #

Generates a random element over the natural range of a.

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

Tries to generate a value that satisfies a predicate.

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

Generates a value that satisfies a predicate.

oneof :: Foldable t => t (Fake a) -> Fake a Source #

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

elements :: Foldable t => t a -> Fake a Source #

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

listOf :: Int -> Fake a -> Fake [a] Source #

Generates a random subsequence of the given list. todo : implemente generic interface subseqOf :: Foldable f => f a -> Fake (f a) subseqOf xs = filterM (_ -> fromRange (False, True)) (toList xs) | Generates a list of the given length.

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

Generates an ordered list.

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

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

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

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

λ> data Animal = Cat | Dog | Zebra | Elephant | Giarfee deriving (Eq,Ord,Enum, Show)
λ> generate (fakeEnumFromTo Cat Zebra)
Zebra