Safe Haskell | None |
---|---|
Language | Haskell2010 |
Library functions about randomness
Synopsis
- pick :: RandomGen r => r -> [a] -> (Maybe a, r)
- pickM :: RandomGen r => MonadState r m => [a] -> m (Maybe a)
- shuffle :: RandomGen r => r -> [a] -> ([a], r)
- shuffleM :: RandomGen r => MonadState r m => [a] -> m [a]
- oneof :: RandomGen r => MonadState r m => NonEmpty a -> m a
- roll :: RandomGen r => MonadState r m => Random p => Ord p => p -> p -> m p
Documentation
:: RandomGen r | |
=> MonadState r m | |
=> [a] | The elements from which something must be picked |
-> m (Maybe a) |
Returns a random element from the list, if it is non empty. If
you a non-empty list at hand, call oneof
instead.
shuffle :: RandomGen r => r -> [a] -> ([a], r) #
Shuffles the second argument with the random generator. Returns the shuffle and the updated generator.
shuffleM :: RandomGen r => MonadState r m => [a] -> m [a] #
Shuffles the given list with a random generator
:: RandomGen r | |
=> MonadState r m | |
=> NonEmpty a | The elements from which something must be picked |
-> m a |
Returns a random element from the list. If you have a possibly empty list
at hand, call pickM
instead.