Copyright | (c) 2023 GYELD GMBH |
---|---|
License | Apache 2.0 |
Maintainer | [email protected] |
Stability | develop |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
GeniusYield.TxBuilder.Random
Description
Synopsis
- class Monad m ⇒ MonadRandom (m ∷ Type → Type) where
- getRandomR ∷ Random a ⇒ (a, a) → m a
- getRandom ∷ Random a ⇒ m a
- getRandomRs ∷ Random a ⇒ (a, a) → m [a]
- getRandoms ∷ Random a ⇒ m [a]
- withRandomness ∷ GYTxMonad m ⇒ (∀ n. (GYTxMonad n, MonadRandom n) ⇒ n a) → m a
Documentation
class Monad m ⇒ MonadRandom (m ∷ Type → Type) where Source #
With a source of random number supply in hand, the MonadRandom
class
allows the programmer to extract random values of a variety of types.
Methods
getRandomR ∷ Random a ⇒ (a, a) → m a Source #
Takes a range (lo,hi) and a random number generator g, and returns a computation that returns a random value uniformly distributed in the closed interval [lo,hi], together with a new generator. It is unspecified what happens if lo>hi. For continuous types there is no requirement that the values lo and hi are ever produced, but they may be, depending on the implementation and the interval.
See randomR
for details.
getRandom ∷ Random a ⇒ m a Source #
The same as getRandomR
, but using a default range determined by the type:
- For bounded types (instances of
Bounded
, such asChar
), the range is normally the whole type. - For fractional types, the range is normally the semi-closed interval
[0,1)
. - For
Integer
, the range is (arbitrarily) the range ofInt
.
See random
for details.
getRandomRs ∷ Random a ⇒ (a, a) → m [a] Source #
Plural variant of getRandomR
, producing an infinite list of
random values instead of returning a new generator.
See randomRs
for details.
getRandoms ∷ Random a ⇒ m [a] Source #
Instances
withRandomness ∷ GYTxMonad m ⇒ (∀ n. (GYTxMonad n, MonadRandom n) ⇒ n a) → m a #
Convert a GYTxMonad
-computation using randomness into a deterministic one
by using one's own public key hash as seed for the random number generator.