Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Random m k
- = Random a => Random (a -> m k)
- | Random a => RandomR (a, a) (a -> m k)
- | Interleave (m a) (a -> m k)
- getRandom :: (Has Random sig m, Random a) => m a
- getRandomR :: (Has Random sig m, Random a) => (a, a) -> m a
- interleave :: Has Random sig m => m a -> m a
- runRandom :: g -> RandomC g m a -> m (g, a)
- evalRandom :: Functor m => g -> RandomC g m a -> m a
- execRandom :: Functor m => g -> RandomC g m a -> m g
- evalRandomIO :: MonadIO m => RandomC StdGen m a -> m a
- newtype RandomC g m a = RandomC {
- runRandomC :: StateC g m a
- type Has (eff :: (Type -> Type) -> Type -> Type) (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) = (Members eff sig, Algebra sig m)
- run :: Identity a -> a
Random effect
Random a => Random (a -> m k) | |
Random a => RandomR (a, a) (a -> m k) | |
Interleave (m a) (a -> m k) |
interleave :: Has Random sig m => m a -> m a Source #
Random carrier
runRandom :: g -> RandomC g m a -> m (g, a) Source #
Run a random computation starting from a given generator.
run (runRandom (PureGen a) (pure b)) === (PureGen a, b)
evalRandom :: Functor m => g -> RandomC g m a -> m a Source #
Run a random computation starting from a given generator and discarding the final generator.
run (evalRandom (PureGen a) (pure b)) === b
execRandom :: Functor m => g -> RandomC g m a -> m g Source #
Run a random computation starting from a given generator and discarding the final result.
run (execRandom (PureGen a) (pure b)) === PureGen a
evalRandomIO :: MonadIO m => RandomC StdGen m a -> m a Source #
Run a random computation in IO
, splitting the global standard generator to get a new one for the computation.
newtype RandomC g m a Source #
RandomC | |
|
Instances
MonadTrans (RandomC g) Source # | |
Defined in Control.Effect.Random | |
Monad m => Monad (RandomC g m) Source # | |
Functor m => Functor (RandomC g m) Source # | |
MonadFix m => MonadFix (RandomC g m) Source # | |
Defined in Control.Effect.Random | |
MonadFail m => MonadFail (RandomC g m) Source # | |
Defined in Control.Effect.Random | |
Monad m => Applicative (RandomC g m) Source # | |
Defined in Control.Effect.Random | |
(Alternative m, Monad m) => MonadPlus (RandomC g m) Source # | |
MonadIO m => MonadIO (RandomC g m) Source # | |
Defined in Control.Effect.Random | |
(Algebra sig m, Effect sig, RandomGen g) => MonadRandom (RandomC g m) Source # | |
Defined in Control.Effect.Random | |
(Algebra sig m, Effect sig, RandomGen g) => MonadInterleave (RandomC g m) Source # | |
Defined in Control.Effect.Random interleave :: RandomC g m a -> RandomC g m a # | |
(Alternative m, Monad m) => Alternative (RandomC g m) Source # | |
(Algebra sig m, Effect sig, RandomGen g) => Algebra (Random :+: sig) (RandomC g m) Source # | |
Re-exports
type Has (eff :: (Type -> Type) -> Type -> Type) (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) = (Members eff sig, Algebra sig m) #
m
is a carrier for sig
containing eff
.
Note that if eff
is a sum, it will be decomposed into multiple Member
constraints. While this technically allows one to combine multiple unrelated effects into a single Has
constraint, doing so has two significant drawbacks:
- Due to a problem with recursive type families, this can lead to significantly slower compiles.
- It defeats
ghc
’s warnings for redundant constraints, and thus can lead to a proliferation of redundant constraints as code is changed.