Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Random m k
- = Random a => Random (a -> k)
- | Random a => RandomR (a, a) (a -> k)
- | Interleave (m a) (a -> k)
- runRandom :: (Carrier sig m, Effect sig, Monad m, RandomGen g) => g -> Eff (RandomC g m) a -> m (g, a)
- evalRandom :: (Carrier sig m, Effect sig, Monad m, RandomGen g) => g -> Eff (RandomC g m) a -> m a
- execRandom :: (Carrier sig m, Effect sig, Monad m, RandomGen g) => g -> Eff (RandomC g m) a -> m g
- evalRandomIO :: (Carrier sig m, Effect sig, MonadIO m) => Eff (RandomC StdGen m) a -> m a
- newtype RandomC g m a = RandomC {
- runRandomC :: g -> m (g, a)
- class Monad m => MonadRandom (m :: * -> *) where
- class MonadRandom m => MonadInterleave (m :: * -> *) where
Documentation
Random a => Random (a -> k) | |
Random a => RandomR (a, a) (a -> k) | |
Interleave (m a) (a -> k) |
runRandom :: (Carrier sig m, Effect sig, Monad m, RandomGen g) => g -> Eff (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 :: (Carrier sig m, Effect sig, Monad m, RandomGen g) => g -> Eff (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 :: (Carrier sig m, Effect sig, Monad m, RandomGen g) => g -> Eff (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 :: (Carrier sig m, Effect sig, MonadIO m) => Eff (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 | |
|
class Monad m => MonadRandom (m :: * -> *) where #
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 | |
Defined in Control.Monad.Random.Class 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) | |
Defined in Control.Monad.Random.Class 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) | |
Defined in Control.Monad.Random.Class 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] # | |
(Member Random sig, Carrier sig carrier) => MonadRandom (Eff carrier) # | |
Defined in Control.Effect.Internal getRandomR :: Random a => (a, a) -> Eff carrier a # getRandom :: Random a => Eff carrier a # getRandomRs :: Random a => (a, a) -> Eff carrier [a] # getRandoms :: Random a => Eff carrier [a] # | |
MonadRandom m => MonadRandom (IdentityT m) | |
Defined in Control.Monad.Random.Class 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) | |
Defined in Control.Monad.Random.Class 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) | |
Defined in Control.Monad.Random.Class 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 (StateT s m) | |
Defined in Control.Monad.Random.Class 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) | |
Defined in Control.Monad.Random.Class 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) | |
Defined in Control.Monad.Random.Class 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) | |
Defined in Control.Monad.Random.Class 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 => MonadRandom (ContT r m) | |
Defined in Control.Monad.Random.Class 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] # | |
MonadRandom m => MonadRandom (ReaderT r m) | |
Defined in Control.Monad.Random.Class 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] # | |
(Monoid w, MonadRandom m) => MonadRandom (RWST r w s m) | |
Defined in Control.Monad.Random.Class 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) | |
Defined in Control.Monad.Random.Class 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 :: * -> *) where #
interleave :: m a -> m a #