module Control.Monad.Trans.MSF.Reader
( module Control.Monad.Trans.Reader
, readerS
, runReaderS
, runReaderS_
)
where
import Control.Arrow (arr, (>>>))
import Control.Monad.Trans.Reader hiding (liftCallCC, liftCatch)
import Data.MonadicStreamFunction (MSF, morphGS)
readerS :: Monad m => MSF m (r, a) b -> MSF (ReaderT r m) a b
readerS :: MSF m (r, a) b -> MSF (ReaderT r m) a b
readerS = (forall c. ((r, a) -> m (b, c)) -> a -> ReaderT r m (b, c))
-> MSF m (r, a) b -> MSF (ReaderT r m) a b
forall (m2 :: * -> *) a1 (m1 :: * -> *) b1 a2 b2.
Monad m2 =>
(forall c. (a1 -> m1 (b1, c)) -> a2 -> m2 (b2, c))
-> MSF m1 a1 b1 -> MSF m2 a2 b2
morphGS ((forall c. ((r, a) -> m (b, c)) -> a -> ReaderT r m (b, c))
-> MSF m (r, a) b -> MSF (ReaderT r m) a b)
-> (forall c. ((r, a) -> m (b, c)) -> a -> ReaderT r m (b, c))
-> MSF m (r, a) b
-> MSF (ReaderT r m) a b
forall a b. (a -> b) -> a -> b
$ \(r, a) -> m (b, c)
f a
a -> (r -> m (b, c)) -> ReaderT r m (b, c)
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m (b, c)) -> ReaderT r m (b, c))
-> (r -> m (b, c)) -> ReaderT r m (b, c)
forall a b. (a -> b) -> a -> b
$ \r
r -> (r, a) -> m (b, c)
f (r
r, a
a)
runReaderS :: Monad m => MSF (ReaderT r m) a b -> MSF m (r, a) b
runReaderS :: MSF (ReaderT r m) a b -> MSF m (r, a) b
runReaderS = (forall c. (a -> ReaderT r m (b, c)) -> (r, a) -> m (b, c))
-> MSF (ReaderT r m) a b -> MSF m (r, a) b
forall (m2 :: * -> *) a1 (m1 :: * -> *) b1 a2 b2.
Monad m2 =>
(forall c. (a1 -> m1 (b1, c)) -> a2 -> m2 (b2, c))
-> MSF m1 a1 b1 -> MSF m2 a2 b2
morphGS ((forall c. (a -> ReaderT r m (b, c)) -> (r, a) -> m (b, c))
-> MSF (ReaderT r m) a b -> MSF m (r, a) b)
-> (forall c. (a -> ReaderT r m (b, c)) -> (r, a) -> m (b, c))
-> MSF (ReaderT r m) a b
-> MSF m (r, a) b
forall a b. (a -> b) -> a -> b
$ \a -> ReaderT r m (b, c)
f (r, a) -> ReaderT r m (b, c) -> r -> m (b, c)
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (a -> ReaderT r m (b, c)
f a
a) r
r
runReaderS_ :: Monad m => MSF (ReaderT s m) a b -> s -> MSF m a b
runReaderS_ :: MSF (ReaderT s m) a b -> s -> MSF m a b
runReaderS_ MSF (ReaderT s m) a b
msf s
s = (a -> (s, a)) -> MSF m a (s, a)
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (\a
a -> (s
s, a
a)) MSF m a (s, a) -> MSF m (s, a) 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
>>> MSF (ReaderT s m) a b -> MSF m (s, a) b
forall (m :: * -> *) r a b.
Monad m =>
MSF (ReaderT r m) a b -> MSF m (r, a) b
runReaderS MSF (ReaderT s m) a b
msf