fused-effects-mwc-random-0.1.0.0: High-quality random number generation as an effect.
Safe HaskellNone
LanguageHaskell2010

Control.Carrier.Random.Lifted

Description

This carrier lifts the internals of its random number generation into a LiftC constraint, assuming the parameter to that LiftC implements PrimMonad. In practice, this means that your effect stack must terminate with LiftC IO or LiftC (ST s).

Synopsis

Documentation

newtype RandomC prim m a Source #

Constructors

RandomC 

Fields

Instances

Instances details
Monad m => Monad (RandomC prim m) Source # 
Instance details

Defined in Control.Carrier.Random.Lifted

Methods

(>>=) :: RandomC prim m a -> (a -> RandomC prim m b) -> RandomC prim m b #

(>>) :: RandomC prim m a -> RandomC prim m b -> RandomC prim m b #

return :: a -> RandomC prim m a #

Functor m => Functor (RandomC prim m) Source # 
Instance details

Defined in Control.Carrier.Random.Lifted

Methods

fmap :: (a -> b) -> RandomC prim m a -> RandomC prim m b #

(<$) :: a -> RandomC prim m b -> RandomC prim m a #

MonadFail m => MonadFail (RandomC prim m) Source # 
Instance details

Defined in Control.Carrier.Random.Lifted

Methods

fail :: String -> RandomC prim m a #

Applicative m => Applicative (RandomC prim m) Source # 
Instance details

Defined in Control.Carrier.Random.Lifted

Methods

pure :: a -> RandomC prim m a #

(<*>) :: RandomC prim m (a -> b) -> RandomC prim m a -> RandomC prim m b #

liftA2 :: (a -> b -> c) -> RandomC prim m a -> RandomC prim m b -> RandomC prim m c #

(*>) :: RandomC prim m a -> RandomC prim m b -> RandomC prim m b #

(<*) :: RandomC prim m a -> RandomC prim m b -> RandomC prim m a #

MonadIO m => MonadIO (RandomC prim m) Source # 
Instance details

Defined in Control.Carrier.Random.Lifted

Methods

liftIO :: IO a -> RandomC prim m a #

(Algebra sig m, Member (Lift n) sig, PrimMonad n) => Algebra (Random :+: sig) (RandomC n m) Source # 
Instance details

Defined in Control.Carrier.Random.Lifted

Methods

alg :: forall ctx (n0 :: Type -> Type) a. Functor ctx => Handler ctx n0 (RandomC n m) -> (Random :+: sig) n0 a -> ctx () -> RandomC n m (ctx a) #

runRandomSystem :: MonadIO m => RandomC IO m a -> m a Source #

Run a computation, seeding its random values from the system random number generator.

This is the de facto standard way to use this carrier. Keep in mind that seeding the RNG may be a computationally intensive process.

runRandomSeeded :: forall m n sig a. (Has (Lift n) sig m, PrimMonad n) => Seed -> RandomC n m a -> m a Source #

Run a computation, seeding its random values from an existing Seed.

Random effect