Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- fromRange :: Random a => (a, a) -> Fake a
- pickAny :: Random a => Fake a
- suchThatMaybe :: Fake a -> (a -> Bool) -> Fake (Maybe a)
- suchThat :: Fake a -> (a -> Bool) -> Fake a
- oneof :: Foldable t => t (Fake a) -> Fake a
- elements :: Foldable t => t a -> Fake a
- listOf :: Int -> Fake a -> Fake [a]
- orderedList :: Ord a => Int -> Fake a -> Fake [a]
- frequency :: [(Int, Fake a)] -> Fake a
- fakeEnumFromTo :: Enum a => a -> a -> Fake a
- fakeBoundedEnum :: (Enum a, Bounded a) => Fake a
Documentation
suchThatMaybe :: Fake a -> (a -> Bool) -> Fake (Maybe a) Source #
Tries to generate a value that satisfies a predicate.
λ> import qualified Faker.Address as AD λ> item :: Text <-generate
$suchThatMaybe
AD.country (x -> (T.length x > 5)) λ> item Just Ecuador
oneof :: Foldable t => t (Fake a) -> Fake a Source #
Randomly uses one of the given generators. The input structure must be non-empty.
λ> import qualified Faker.Address as FA λ> let fakes = [FA.country, FA.postcode, FA.state] λ> generate (oneof fakes) Montana
elements :: Foldable t => t a -> Fake a Source #
Generates one of the given values. The input list must be non-empty.
λ> let fakeInt = elements [1..100] λ> generate fakeInt 22
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].
λ> data Animal = Cat | Dog | Zebra | Elephant | Giarfee deriving (Eq,Ord,Enum, Show) λ> generate (fakeEnumFromTo Cat Zebra) Zebra
Since: 0.2.0
fakeBoundedEnum :: (Enum a, Bounded a) => Fake a Source #
A sumtype can just use this function directly. Defined as
fakeBoundedEnum = fakeEnumFromTo
minBound
maxBound
Since: 0.7.1