fused-effects-0.5.0.0: A fast, flexible, fused effect system.

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Random

Contents

Synopsis

Random effect

data Random m k Source #

Constructors

Random a => Random (a -> m k) 
Random a => RandomR (a, a) (a -> m k) 
Interleave (m a) (a -> m k) 
Instances
Effect Random Source # 
Instance details

Defined in Control.Effect.Random

Methods

handle :: (Functor f, Monad m) => f () -> (forall x. f (m x) -> n (f x)) -> Random m a -> Random n (f a) Source #

HFunctor Random Source # 
Instance details

Defined in Control.Effect.Random

Methods

fmap' :: Functor (Random f) => (a -> b) -> Random f a -> Random f b Source #

hmap :: Functor m => (forall x. m x -> n x) -> Random m a -> Random n a Source #

Functor m => Functor (Random m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

fmap :: (a -> b) -> Random m a -> Random m b #

(<$) :: a -> Random m b -> Random m a #

(Carrier sig m, Effect sig, RandomGen g) => Carrier (Random :+: sig) (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

eff :: (Random :+: sig) (RandomC g m) a -> RandomC g 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 #

Constructors

RandomC 

Fields

Instances
MonadTrans (RandomC g) Source # 
Instance details

Defined in Control.Effect.Random

Methods

lift :: Monad m => m a -> RandomC g m a #

Monad m => Monad (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

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

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

return :: a -> RandomC g m a #

fail :: String -> RandomC g m a #

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

Defined in Control.Effect.Random

Methods

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

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

MonadFix m => MonadFix (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

mfix :: (a -> RandomC g m a) -> RandomC g m a #

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

Defined in Control.Effect.Random

Methods

fail :: String -> RandomC g m a #

Monad m => Applicative (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

pure :: a -> RandomC g m a #

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

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

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

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

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

Defined in Control.Effect.Random

Methods

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

(Alternative m, Monad m) => Alternative (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

empty :: RandomC g m a #

(<|>) :: RandomC g m a -> RandomC g m a -> RandomC g m a #

some :: RandomC g m a -> RandomC g m [a] #

many :: RandomC g m a -> RandomC g m [a] #

(Alternative m, Monad m) => MonadPlus (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

mzero :: RandomC g m a #

mplus :: RandomC g m a -> RandomC g m a -> RandomC g m a #

(Carrier sig m, Effect sig, RandomGen g) => MonadInterleave (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

interleave :: RandomC g m a -> RandomC g m a #

(Carrier sig m, Effect sig, RandomGen g) => MonadRandom (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

getRandomR :: Random a => (a, a) -> RandomC g m a #

getRandom :: Random a => RandomC g m a #

getRandomRs :: Random a => (a, a) -> RandomC g m [a] #

getRandoms :: Random a => RandomC g m [a] #

(Carrier sig m, Effect sig, RandomGen g) => Carrier (Random :+: sig) (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

eff :: (Random :+: sig) (RandomC g m) a -> RandomC g m a Source #

Re-exports

class (HFunctor sig, Monad m) => Carrier sig m | m -> sig Source #

The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the eff method.

Minimal complete definition

eff

Instances
Carrier Pure PureC Source # 
Instance details

Defined in Control.Effect.Carrier

Methods

eff :: Pure PureC a -> PureC a Source #

(HFunctor eff, Carrier sig m, Member eff sig) => Carrier sig (InterposeC eff m) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

eff :: sig (InterposeC eff m) a -> InterposeC eff m a Source #

Monad m => Carrier (Lift m) (LiftC m) Source # 
Instance details

Defined in Control.Effect.Lift

Methods

eff :: Lift m (LiftC m) a -> LiftC m a Source #

(Carrier sig m, MonadIO m) => Carrier (Resource :+: sig) (ResourceC m) Source # 
Instance details

Defined in Control.Effect.Resource

Methods

eff :: (Resource :+: sig) (ResourceC m) a -> ResourceC m a Source #

(Carrier sig m, Effect sig) => Carrier (NonDet :+: sig) (NonDetC m) Source # 
Instance details

Defined in Control.Effect.NonDet

Methods

eff :: (NonDet :+: sig) (NonDetC m) a -> NonDetC m a Source #

(Carrier sig m, Effect sig) => Carrier (NonDet :+: sig) (OnceC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

eff :: (NonDet :+: sig) (OnceC m) a -> OnceC m a Source #

(Carrier sig m, Effect sig) => Carrier (Fresh :+: sig) (FreshC m) Source # 
Instance details

Defined in Control.Effect.Fresh

Methods

eff :: (Fresh :+: sig) (FreshC m) a -> FreshC m a Source #

(Carrier sig m, Effect sig) => Carrier (Fail :+: sig) (FailC m) Source # 
Instance details

Defined in Control.Effect.Fail

Methods

eff :: (Fail :+: sig) (FailC m) a -> FailC m a Source #

(Carrier sig m, Effect sig) => Carrier (Cut :+: (NonDet :+: sig)) (CutC m) Source # 
Instance details

Defined in Control.Effect.Cut

Methods

eff :: (Cut :+: (NonDet :+: sig)) (CutC m) a -> CutC m a Source #

(Carrier sig m, Effect sig) => Carrier (Cull :+: (NonDet :+: sig)) (CullC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

eff :: (Cull :+: (NonDet :+: sig)) (CullC m) a -> CullC m a Source #

(Carrier sig m, Effect sig) => Carrier (Trace :+: sig) (TraceByReturningC m) Source # 
Instance details

Defined in Control.Effect.Trace

Methods

eff :: (Trace :+: sig) (TraceByReturningC m) a -> TraceByReturningC m a Source #

Carrier sig m => Carrier (Trace :+: sig) (TraceByIgnoringC m) Source # 
Instance details

Defined in Control.Effect.Trace

Methods

eff :: (Trace :+: sig) (TraceByIgnoringC m) a -> TraceByIgnoringC m a Source #

(MonadIO m, Carrier sig m) => Carrier (Trace :+: sig) (TraceByPrintingC m) Source # 
Instance details

Defined in Control.Effect.Trace

Methods

eff :: (Trace :+: sig) (TraceByPrintingC m) a -> TraceByPrintingC m a Source #

(HFunctor eff, Carrier sig m) => Carrier (eff :+: sig) (InterpretC eff m) Source # 
Instance details

Defined in Control.Effect.Interpret

Methods

eff :: (eff :+: sig) (InterpretC eff m) a -> InterpretC eff m a Source #

(Carrier sig m, Effect sig) => Carrier (State s :+: sig) (StateC s m) Source # 
Instance details

Defined in Control.Effect.State.Strict

Methods

eff :: (State s :+: sig) (StateC s m) a -> StateC s m a Source #

(Carrier sig m, Effect sig) => Carrier (State s :+: sig) (StateC s m) Source # 
Instance details

Defined in Control.Effect.State.Lazy

Methods

eff :: (State s :+: sig) (StateC s m) a -> StateC s m a Source #

Carrier sig m => Carrier (Reader r :+: sig) (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

eff :: (Reader r :+: sig) (ReaderC r m) a -> ReaderC r m a Source #

(Carrier sig m, Effect sig, RandomGen g) => Carrier (Random :+: sig) (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

eff :: (Random :+: sig) (RandomC g m) a -> RandomC g m a Source #

(Carrier sig m, Effect sig) => Carrier (Error e :+: sig) (ErrorC e m) Source # 
Instance details

Defined in Control.Effect.Error

Methods

eff :: (Error e :+: sig) (ErrorC e m) a -> ErrorC e m a Source #

Carrier sig m => Carrier (Resumable err :+: sig) (ResumableWithC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

eff :: (Resumable err :+: sig) (ResumableWithC err m) a -> ResumableWithC err m a Source #

(Carrier sig m, Effect sig) => Carrier (Resumable err :+: sig) (ResumableC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

eff :: (Resumable err :+: sig) (ResumableC err m) a -> ResumableC err m a Source #

(Monoid w, Carrier sig m, Effect sig) => Carrier (Writer w :+: sig) (WriterC w m) Source # 
Instance details

Defined in Control.Effect.Writer

Methods

eff :: (Writer w :+: sig) (WriterC w m) a -> WriterC w m a Source #

(HFunctor eff, Carrier sig m, Effect sig) => Carrier (eff :+: sig) (InterpretStateC eff s m) Source # 
Instance details

Defined in Control.Effect.Interpret

Methods

eff :: (eff :+: sig) (InterpretStateC eff s m) a -> InterpretStateC eff s m a Source #

class Member (sub :: (* -> *) -> * -> *) sup Source #

Minimal complete definition

inj, prj

Instances
Member sub sub Source # 
Instance details

Defined in Control.Effect.Sum

Methods

inj :: sub m a -> sub m a Source #

prj :: sub m a -> Maybe (sub m a) Source #

Member sub sup => Member sub (sub' :+: sup) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

inj :: sub m a -> (sub' :+: sup) m a Source #

prj :: (sub' :+: sup) m a -> Maybe (sub m a) Source #

Member sub (sub :+: sup) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

inj :: sub m a -> (sub :+: sup) m a Source #

prj :: (sub :+: sup) m a -> Maybe (sub m a) Source #

class Monad m => MonadRandom (m :: Type -> Type) where #

Methods

getRandomR :: Random a => (a, a) -> m a #

getRandom :: Random a => m a #

getRandomRs :: Random a => (a, a) -> m [a] #

getRandoms :: Random a => m [a] #

Instances
MonadRandom IO 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> IO a #

getRandom :: Random a => IO a #

getRandomRs :: Random a => (a, a) -> IO [a] #

getRandoms :: Random a => IO [a] #

MonadRandom m => MonadRandom (ListT m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> ListT m a #

getRandom :: Random a => ListT m a #

getRandomRs :: Random a => (a, a) -> ListT m [a] #

getRandoms :: Random a => ListT m [a] #

MonadRandom m => MonadRandom (MaybeT m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> MaybeT m a #

getRandom :: Random a => MaybeT m a #

getRandomRs :: Random a => (a, a) -> MaybeT m [a] #

getRandoms :: Random a => MaybeT m [a] #

MonadRandom m => MonadRandom (IdentityT m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> IdentityT m a #

getRandom :: Random a => IdentityT m a #

getRandomRs :: Random a => (a, a) -> IdentityT m [a] #

getRandoms :: Random a => IdentityT m [a] #

(Error e, MonadRandom m) => MonadRandom (ErrorT e m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> ErrorT e m a #

getRandom :: Random a => ErrorT e m a #

getRandomRs :: Random a => (a, a) -> ErrorT e m [a] #

getRandoms :: Random a => ErrorT e m [a] #

MonadRandom m => MonadRandom (ExceptT e m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> ExceptT e m a #

getRandom :: Random a => ExceptT e m a #

getRandomRs :: Random a => (a, a) -> ExceptT e m [a] #

getRandoms :: Random a => ExceptT e m [a] #

MonadRandom m => MonadRandom (ReaderT r m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> ReaderT r m a #

getRandom :: Random a => ReaderT r m a #

getRandomRs :: Random a => (a, a) -> ReaderT r m [a] #

getRandoms :: Random a => ReaderT r m [a] #

MonadRandom m => MonadRandom (StateT s m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> StateT s m a #

getRandom :: Random a => StateT s m a #

getRandomRs :: Random a => (a, a) -> StateT s m [a] #

getRandoms :: Random a => StateT s m [a] #

MonadRandom m => MonadRandom (StateT s m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> StateT s m a #

getRandom :: Random a => StateT s m a #

getRandomRs :: Random a => (a, a) -> StateT s m [a] #

getRandoms :: Random a => StateT s m [a] #

(MonadRandom m, Monoid w) => MonadRandom (WriterT w m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> WriterT w m a #

getRandom :: Random a => WriterT w m a #

getRandomRs :: Random a => (a, a) -> WriterT w m [a] #

getRandoms :: Random a => WriterT w m [a] #

(MonadRandom m, Monoid w) => MonadRandom (WriterT w m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> WriterT w m a #

getRandom :: Random a => WriterT w m a #

getRandomRs :: Random a => (a, a) -> WriterT w m [a] #

getRandoms :: Random a => WriterT w m [a] #

(Carrier sig m, Effect sig, RandomGen g) => MonadRandom (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

getRandomR :: Random a => (a, a) -> RandomC g m a #

getRandom :: Random a => RandomC g m a #

getRandomRs :: Random a => (a, a) -> RandomC g m [a] #

getRandoms :: Random a => RandomC g m [a] #

MonadRandom m => MonadRandom (ContT r m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> ContT r m a #

getRandom :: Random a => ContT r m a #

getRandomRs :: Random a => (a, a) -> ContT r m [a] #

getRandoms :: Random a => ContT r m [a] #

(Monoid w, MonadRandom m) => MonadRandom (RWST r w s m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> RWST r w s m a #

getRandom :: Random a => RWST r w s m a #

getRandomRs :: Random a => (a, a) -> RWST r w s m [a] #

getRandoms :: Random a => RWST r w s m [a] #

(Monoid w, MonadRandom m) => MonadRandom (RWST r w s m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

getRandomR :: Random a => (a, a) -> RWST r w s m a #

getRandom :: Random a => RWST r w s m a #

getRandomRs :: Random a => (a, a) -> RWST r w s m [a] #

getRandoms :: Random a => RWST r w s m [a] #

class MonadRandom m => MonadInterleave (m :: Type -> Type) where #

Methods

interleave :: m a -> m a #

Instances
MonadInterleave m => MonadInterleave (ListT m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: ListT m a -> ListT m a #

MonadInterleave m => MonadInterleave (MaybeT m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: MaybeT m a -> MaybeT m a #

MonadInterleave m => MonadInterleave (IdentityT m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: IdentityT m a -> IdentityT m a #

(Error e, MonadInterleave m) => MonadInterleave (ErrorT e m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: ErrorT e m a -> ErrorT e m a #

MonadInterleave m => MonadInterleave (ExceptT e m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: ExceptT e m a -> ExceptT e m a #

MonadInterleave m => MonadInterleave (ReaderT r m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: ReaderT r m a -> ReaderT r m a #

MonadInterleave m => MonadInterleave (StateT s m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: StateT s m a -> StateT s m a #

MonadInterleave m => MonadInterleave (StateT s m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: StateT s m a -> StateT s m a #

(Monoid w, MonadInterleave m) => MonadInterleave (WriterT w m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: WriterT w m a -> WriterT w m a #

(Monoid w, MonadInterleave m) => MonadInterleave (WriterT w m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: WriterT w m a -> WriterT w m a #

(Carrier sig m, Effect sig, RandomGen g) => MonadInterleave (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

interleave :: RandomC g m a -> RandomC g m a #

MonadInterleave m => MonadInterleave (ContT r m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: ContT r m a -> ContT r m a #

(Monoid w, MonadInterleave m) => MonadInterleave (RWST r w s m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: RWST r w s m a -> RWST r w s m a #

(Monoid w, MonadInterleave m) => MonadInterleave (RWST r w s m) 
Instance details

Defined in Control.Monad.Random.Class

Methods

interleave :: RWST r w s m a -> RWST r w s m a #

run :: PureC a -> a Source #

Run an action exhausted of effects to produce its final result value.