module Control.Monad.Trans.MSF.Random
( runRandS
, evalRandS
, getRandomS
, getRandomsS
, getRandomRS
, getRandomRS_
, getRandomsRS
, getRandomsRS_
)
where
import Control.Arrow (arr, (>>>))
import Control.Monad.Random (MonadRandom, RandT, Random, RandomGen, getRandom,
getRandomR, getRandomRs, getRandoms, runRandT)
import Control.Monad.Trans.MSF.State (StateT (..), runStateS_)
import Data.MonadicStreamFunction (MSF, arrM, constM, morphS)
runRandS :: (RandomGen g, Functor m, Monad m)
=> MSF (RandT g m) a b
-> g
-> MSF m a (g, b)
runRandS :: forall g (m :: * -> *) a b.
(RandomGen g, Functor m, Monad m) =>
MSF (RandT g m) a b -> g -> MSF m a (g, b)
runRandS = MSF (StateT g m) a b -> g -> MSF m a (g, b)
forall (m :: * -> *) s a b.
(Functor m, Monad m) =>
MSF (StateT s m) a b -> s -> MSF m a (s, b)
runStateS_ (MSF (StateT g m) a b -> g -> MSF m a (g, b))
-> (MSF (RandT g m) a b -> MSF (StateT g m) a b)
-> MSF (RandT g m) a b
-> g
-> MSF m a (g, b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall c. RandT g m c -> StateT g m c)
-> MSF (RandT g m) a b -> MSF (StateT g m) a b
forall (m2 :: * -> *) (m1 :: * -> *) a b.
(Monad m2, Monad m1) =>
(forall c. m1 c -> m2 c) -> MSF m1 a b -> MSF m2 a b
morphS ((g -> m (c, g)) -> StateT g m c
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT ((g -> m (c, g)) -> StateT g m c)
-> (RandT g m c -> g -> m (c, g)) -> RandT g m c -> StateT g m c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RandT g m c -> g -> m (c, g)
forall g (m :: * -> *) a. RandT g m a -> g -> m (a, g)
runRandT)
evalRandS :: (RandomGen g, Functor m, Monad m)
=> MSF (RandT g m) a b -> g -> MSF m a b
evalRandS :: forall g (m :: * -> *) a b.
(RandomGen g, Functor m, Monad m) =>
MSF (RandT g m) a b -> g -> MSF m a b
evalRandS MSF (RandT g m) a b
msf g
g = MSF (RandT g m) a b -> g -> MSF m a (g, b)
forall g (m :: * -> *) a b.
(RandomGen g, Functor m, Monad m) =>
MSF (RandT g m) a b -> g -> MSF m a (g, b)
runRandS MSF (RandT g m) a b
msf g
g MSF m a (g, b) -> MSF m (g, b) b -> MSF m a b
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ((g, b) -> b) -> MSF m (g, b) b
forall b c. (b -> c) -> MSF m b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (g, b) -> b
forall a b. (a, b) -> b
snd
getRandomS :: (MonadRandom m, Random b) => MSF m a b
getRandomS :: forall (m :: * -> *) b a. (MonadRandom m, Random b) => MSF m a b
getRandomS = m b -> MSF m a b
forall (m :: * -> *) b a. Monad m => m b -> MSF m a b
constM m b
forall a. Random a => m a
forall (m :: * -> *) a. (MonadRandom m, Random a) => m a
getRandom
getRandomsS :: (MonadRandom m, Random b) => MSF m a [b]
getRandomsS :: forall (m :: * -> *) b a. (MonadRandom m, Random b) => MSF m a [b]
getRandomsS = m [b] -> MSF m a [b]
forall (m :: * -> *) b a. Monad m => m b -> MSF m a b
constM m [b]
forall a. Random a => m [a]
forall (m :: * -> *) a. (MonadRandom m, Random a) => m [a]
getRandoms
getRandomRS :: (MonadRandom m, Random b) => (b, b) -> MSF m a b
getRandomRS :: forall (m :: * -> *) b a.
(MonadRandom m, Random b) =>
(b, b) -> MSF m a b
getRandomRS (b, b)
range = m b -> MSF m a b
forall (m :: * -> *) b a. Monad m => m b -> MSF m a b
constM (m b -> MSF m a b) -> m b -> MSF m a b
forall a b. (a -> b) -> a -> b
$ (b, b) -> m b
forall a. Random a => (a, a) -> m a
forall (m :: * -> *) a. (MonadRandom m, Random a) => (a, a) -> m a
getRandomR (b, b)
range
getRandomRS_ :: (MonadRandom m, Random b) => MSF m (b, b) b
getRandomRS_ :: forall (m :: * -> *) b. (MonadRandom m, Random b) => MSF m (b, b) b
getRandomRS_ = ((b, b) -> m b) -> MSF m (b, b) b
forall (m :: * -> *) a b. Monad m => (a -> m b) -> MSF m a b
arrM (b, b) -> m b
forall a. Random a => (a, a) -> m a
forall (m :: * -> *) a. (MonadRandom m, Random a) => (a, a) -> m a
getRandomR
getRandomsRS :: (MonadRandom m, Random b) => (b, b) -> MSF m a [b]
getRandomsRS :: forall (m :: * -> *) b a.
(MonadRandom m, Random b) =>
(b, b) -> MSF m a [b]
getRandomsRS (b, b)
range = m [b] -> MSF m a [b]
forall (m :: * -> *) b a. Monad m => m b -> MSF m a b
constM (m [b] -> MSF m a [b]) -> m [b] -> MSF m a [b]
forall a b. (a -> b) -> a -> b
$ (b, b) -> m [b]
forall a. Random a => (a, a) -> m [a]
forall (m :: * -> *) a.
(MonadRandom m, Random a) =>
(a, a) -> m [a]
getRandomRs (b, b)
range
getRandomsRS_ :: (MonadRandom m, Random b) => MSF m (b, b) [b]
getRandomsRS_ :: forall (m :: * -> *) b.
(MonadRandom m, Random b) =>
MSF m (b, b) [b]
getRandomsRS_ = ((b, b) -> m [b]) -> MSF m (b, b) [b]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> MSF m a b
arrM (b, b) -> m [b]
forall a. Random a => (a, a) -> m [a]
forall (m :: * -> *) a.
(MonadRandom m, Random a) =>
(a, a) -> m [a]
getRandomRs