iota-0.1.0.0
Safe HaskellSafe-Inferred
LanguageGHC2021

System.Random.Utils

Synopsis

Documentation

newStdGenPrim :: PrimMonad m => m StdGen Source #

global StdGen

newtype PrimGen g Source #

Constructors

PrimGen 

Fields

Instances

Instances details
RandomGen g => RandomGen (PrimGen g) Source # 
Instance details

Defined in System.Random.Utils

(RandomGen g, PrimMonad m) => FrozenGen (PrimGen g) m Source # 
Instance details

Defined in System.Random.Utils

Associated Types

type MutableGen (PrimGen g) m = (g :: Type)

Methods

freezeGen :: MutableGen (PrimGen g) m -> m (PrimGen g)

thawGen :: PrimGen g -> m (MutableGen (PrimGen g) m)

type MutableGen (PrimGen g) m Source # 
Instance details

Defined in System.Random.Utils

type MutableGen (PrimGen g) m = PrimGenM g (PrimState m)

newtype PrimGenM g s Source #

Constructors

PrimGenM 

Fields

Instances

Instances details
(RandomGen g, s ~ PrimState m, PrimMonad m) => StatefulGen (PrimGenM g s) m Source # 
Instance details

Defined in System.Random.Utils

(RandomGen g, s ~ PrimState m, PrimMonad m) => RandomGenM (PrimGenM g s) g m Source # 
Instance details

Defined in System.Random.Utils

Methods

applyRandomGenM :: (g -> (a, g)) -> PrimGenM g s -> m a

newPrimGenM :: PrimMonad m => g -> m (PrimGenM g (PrimState m)) Source #

applyPrimGen :: PrimMonad m => (g -> (a, g)) -> PrimGenM g (PrimState m) -> m a Source #

withGlobalStdGen :: PrimMonad m => (PrimGenM StdGen (PrimState m) -> m a) -> m (a, StdGen) Source #

withGlobalStdGen_ :: PrimMonad m => (PrimGenM StdGen (PrimState m) -> m a) -> m a Source #

withFixedStdGen :: PrimMonad m => Int -> (PrimGenM StdGen (PrimState m) -> m a) -> m (a, StdGen) Source #

>>> withFixedStdGen 123 (uniformRM @Int (1, 6))
(1,StdGen {unStdGen = SMGen 3794253433779795923 13032462758197477675})
>>> withFixedStdGen 1 (uniformRM @Int (1, 6))
(6,StdGen {unStdGen = SMGen 4999253871718377453 10451216379200822465})

withFixedStdGen_ :: PrimMonad m => Int -> (PrimGenM StdGen (PrimState m) -> m a) -> m a Source #

>>> withFixedStdGen_ 123 (uniformRM @Int (1, 6))
1
>>> withFixedStdGen_ 1 (uniformRM @Int (1, 6))
6

shuffle :: (PrimMonad m, MVector mv a, RandomGen g) => g -> mv (PrimState m) a -> m () Source #

>>> import qualified Data.Vector.Unboxed as U
>>> U.modify (shuffle (mkStdGen 123)) $ U.fromList "abcdef"
"fcdbea"