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
Documentation
fromRange :: Random a => (a, a) -> Fake a Source #
Generates a random element in the given inclusive range.
suchThatMaybe :: Fake a -> (a -> Bool) -> Fake (Maybe a) Source #
Tries to generate 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.
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