Copyright | © 2021 IOHK |
---|---|
License | Apache-2.0 |
Safe Haskell | None |
Language | Haskell2010 |
This module provides functions and types that extend those provided by
the
Random
module hierarchy.
Synopsis
-
newtype
StdGenSeed
=
StdGenSeed
{
- unStdGenSeed :: Word127
- stdGenSeed :: MonadRandom m => m StdGenSeed
- stdGenFromSeed :: StdGenSeed -> StdGen
- stdGenToSeed :: StdGen -> StdGenSeed
-
newtype
NonRandom
a =
NonRandom
{
- runNonRandom :: a
Random number generator seeds
newtype StdGenSeed Source #
A seed for the standard random number generator.
This type is equivalent to the internal state of a
StdGen
, but provides a
representation that is more convenient for construction and serialization.
The number of possible seeds is identical to the number of valid states of
the
StdGen
type, but unlike the
StdGen
type, whose state has an internal
invariant that must not be broken, values of the
StdGenSeed
type are
correct by construction.
StdGenSeed | |
|
Instances
stdGenSeed :: MonadRandom m => m StdGenSeed Source #
Creates a new
StdGenSeed
from within a random monadic context.
stdGenFromSeed :: StdGenSeed -> StdGen Source #
Converts a
StdGenSeed
value to a
StdGen
value.
This function satisfies the following properties:
>>>
stdGenFromSeed . stdGenToSeed == id
>>>
stdGenToSeed . stdGenFromSeed == id
stdGenToSeed :: StdGen -> StdGenSeed Source #
Converts a
StdGen
value to a
StdGenSeed
value.
This function satisfies the following properties:
>>>
stdGenFromSeed . stdGenToSeed == id
>>>
stdGenToSeed . stdGenFromSeed == id
Non-random contexts
Provides a stateless context for computations that must be non-random.
This type is useful for testing functions that require a
MonadRandom
context, but when actual randomness is not required or even desired.
NonRandom | |
|
Instances
Monad NonRandom Source # | |
Functor NonRandom Source # | |
Applicative NonRandom Source # | |
Defined in Control.Monad.Random.Extra |
|
MonadRandom NonRandom Source # | |
Eq a => Eq ( NonRandom a) Source # | |
Ord a => Ord ( NonRandom a) Source # | |
Defined in Control.Monad.Random.Extra compare :: NonRandom a -> NonRandom a -> Ordering Source # (<) :: NonRandom a -> NonRandom a -> Bool Source # (<=) :: NonRandom a -> NonRandom a -> Bool Source # (>) :: NonRandom a -> NonRandom a -> Bool Source # (>=) :: NonRandom a -> NonRandom a -> Bool Source # |
|
Show a => Show ( NonRandom a) Source # | |
Generic ( NonRandom a) Source # | |
type Rep ( NonRandom a) Source # | |
Defined in Control.Monad.Random.Extra
type
Rep
(
NonRandom
a) =
D1
('
MetaData
"NonRandom" "Control.Monad.Random.Extra" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" '
True
) (
C1
('
MetaCons
"NonRandom" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"runNonRandom") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
a)))
|