{-# LANGUAGE RankNTypes #-}
module Data.Conduit.Lift (
exceptC,
runExceptC,
catchExceptC,
runCatchC,
catchCatchC,
maybeC,
runMaybeC,
readerC,
runReaderC,
stateLC,
runStateLC,
evalStateLC,
execStateLC,
stateC,
runStateC,
evalStateC,
execStateC,
writerLC,
runWriterLC,
execWriterLC,
writerC,
runWriterC,
execWriterC,
rwsLC,
runRWSLC,
evalRWSLC,
execRWSLC,
rwsC,
runRWSC,
evalRWSC,
execRWSC
) where
import Data.Conduit
import Data.Conduit.Internal (ConduitT (..), Pipe (..))
import Control.Monad.Trans.Class (MonadTrans(..))
import Data.Monoid (Monoid(..))
import qualified Control.Monad.Trans.Except as Ex
import qualified Control.Monad.Trans.Maybe as M
import qualified Control.Monad.Trans.Reader as R
import qualified Control.Monad.Trans.State.Strict as SS
import qualified Control.Monad.Trans.Writer.Strict as WS
import qualified Control.Monad.Trans.RWS.Strict as RWSS
import qualified Control.Monad.Trans.State.Lazy as SL
import qualified Control.Monad.Trans.Writer.Lazy as WL
import qualified Control.Monad.Trans.RWS.Lazy as RWSL
import Control.Monad.Catch.Pure (CatchT (runCatchT))
import Control.Exception (SomeException)
exceptC
:: Monad m =>
ConduitT i o m (Either e a) -> ConduitT i o (Ex.ExceptT e m) a
exceptC :: forall (m :: * -> *) i o e a.
Monad m =>
ConduitT i o m (Either e a) -> ConduitT i o (ExceptT e m) a
exceptC ConduitT i o m (Either e a)
p = do
Either e a
x <- forall (m :: * -> *) (n :: * -> *) i o r.
Monad m =>
(forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ConduitT i o m (Either e a)
p
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
Ex.ExceptT (forall (m :: * -> *) a. Monad m => a -> m a
return Either e a
x)
runExceptC
:: Monad m =>
ConduitT i o (Ex.ExceptT e m) r -> ConduitT i o m (Either e r)
runExceptC :: forall (m :: * -> *) i o e r.
Monad m =>
ConduitT i o (ExceptT e m) r -> ConduitT i o m (Either e r)
runExceptC (ConduitT forall b.
(r -> Pipe i i o () (ExceptT e m) b)
-> Pipe i i o () (ExceptT e m) b
c0) =
forall i o (m :: * -> *) r.
(forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m r
ConduitT forall a b. (a -> b) -> a -> b
$ \Either e r -> Pipe i i o () m b
rest ->
let go :: Pipe i i o () (ExceptT e m) r -> Pipe i i o () m b
go (Done r
r) = Either e r -> Pipe i i o () m b
rest (forall a b. b -> Either a b
Right r
r)
go (PipeM ExceptT e m (Pipe i i o () (ExceptT e m) r)
mp) = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM forall a b. (a -> b) -> a -> b
$ do
Either e (Pipe i i o () (ExceptT e m) r)
eres <- forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
Ex.runExceptT ExceptT e m (Pipe i i o () (ExceptT e m) r)
mp
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case Either e (Pipe i i o () (ExceptT e m) r)
eres of
Left e
e -> Either e r -> Pipe i i o () m b
rest forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left e
e
Right Pipe i i o () (ExceptT e m) r
p -> Pipe i i o () (ExceptT e m) r -> Pipe i i o () m b
go Pipe i i o () (ExceptT e m) r
p
go (Leftover Pipe i i o () (ExceptT e m) r
p i
i) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> l -> Pipe l i o u m r
Leftover (Pipe i i o () (ExceptT e m) r -> Pipe i i o () m b
go Pipe i i o () (ExceptT e m) r
p) i
i
go (HaveOutput Pipe i i o () (ExceptT e m) r
p o
o) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> o -> Pipe l i o u m r
HaveOutput (Pipe i i o () (ExceptT e m) r -> Pipe i i o () m b
go Pipe i i o () (ExceptT e m) r
p) o
o
go (NeedInput i -> Pipe i i o () (ExceptT e m) r
x () -> Pipe i i o () (ExceptT e m) r
y) = forall l i o u (m :: * -> *) r.
(i -> Pipe l i o u m r)
-> (u -> Pipe l i o u m r) -> Pipe l i o u m r
NeedInput (Pipe i i o () (ExceptT e m) r -> Pipe i i o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe i i o () (ExceptT e m) r
x) (Pipe i i o () (ExceptT e m) r -> Pipe i i o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i i o () (ExceptT e m) r
y)
in Pipe i i o () (ExceptT e m) r -> Pipe i i o () m b
go (forall b.
(r -> Pipe i i o () (ExceptT e m) b)
-> Pipe i i o () (ExceptT e m) b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
{-# INLINABLE runExceptC #-}
catchExceptC
:: Monad m =>
ConduitT i o (Ex.ExceptT e m) r
-> (e -> ConduitT i o (Ex.ExceptT e m) r)
-> ConduitT i o (Ex.ExceptT e m) r
catchExceptC :: forall (m :: * -> *) i o e r.
Monad m =>
ConduitT i o (ExceptT e m) r
-> (e -> ConduitT i o (ExceptT e m) r)
-> ConduitT i o (ExceptT e m) r
catchExceptC ConduitT i o (ExceptT e m) r
c0 e -> ConduitT i o (ExceptT e m) r
h =
forall i o (m :: * -> *) r.
(forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m r
ConduitT forall a b. (a -> b) -> a -> b
$ \r -> Pipe i i o () (ExceptT e m) b
rest ->
let go :: Pipe i i o () (ExceptT e m) r -> Pipe i i o () (ExceptT e m) b
go (Done r
r) = r -> Pipe i i o () (ExceptT e m) b
rest r
r
go (PipeM ExceptT e m (Pipe i i o () (ExceptT e m) r)
mp) = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM forall a b. (a -> b) -> a -> b
$ do
Either e (Pipe i i o () (ExceptT e m) r)
eres <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
Ex.runExceptT ExceptT e m (Pipe i i o () (ExceptT e m) r)
mp
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case Either e (Pipe i i o () (ExceptT e m) r)
eres of
Left e
e -> forall i o (m :: * -> *) r.
ConduitT i o m r
-> forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b
unConduitT (e -> ConduitT i o (ExceptT e m) r
h e
e) r -> Pipe i i o () (ExceptT e m) b
rest
Right Pipe i i o () (ExceptT e m) r
p -> Pipe i i o () (ExceptT e m) r -> Pipe i i o () (ExceptT e m) b
go Pipe i i o () (ExceptT e m) r
p
go (Leftover Pipe i i o () (ExceptT e m) r
p i
i) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> l -> Pipe l i o u m r
Leftover (Pipe i i o () (ExceptT e m) r -> Pipe i i o () (ExceptT e m) b
go Pipe i i o () (ExceptT e m) r
p) i
i
go (HaveOutput Pipe i i o () (ExceptT e m) r
p o
o) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> o -> Pipe l i o u m r
HaveOutput (Pipe i i o () (ExceptT e m) r -> Pipe i i o () (ExceptT e m) b
go Pipe i i o () (ExceptT e m) r
p) o
o
go (NeedInput i -> Pipe i i o () (ExceptT e m) r
x () -> Pipe i i o () (ExceptT e m) r
y) = forall l i o u (m :: * -> *) r.
(i -> Pipe l i o u m r)
-> (u -> Pipe l i o u m r) -> Pipe l i o u m r
NeedInput (Pipe i i o () (ExceptT e m) r -> Pipe i i o () (ExceptT e m) b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe i i o () (ExceptT e m) r
x) (Pipe i i o () (ExceptT e m) r -> Pipe i i o () (ExceptT e m) b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i i o () (ExceptT e m) r
y)
in Pipe i i o () (ExceptT e m) r -> Pipe i i o () (ExceptT e m) b
go forall a b. (a -> b) -> a -> b
$ forall i o (m :: * -> *) r.
ConduitT i o m r
-> forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b
unConduitT ConduitT i o (ExceptT e m) r
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done
where
{-# INLINABLE catchExceptC #-}
runCatchC
:: Monad m =>
ConduitT i o (CatchT m) r -> ConduitT i o m (Either SomeException r)
runCatchC :: forall (m :: * -> *) i o r.
Monad m =>
ConduitT i o (CatchT m) r
-> ConduitT i o m (Either SomeException r)
runCatchC ConduitT i o (CatchT m) r
c0 =
forall i o (m :: * -> *) r.
(forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m r
ConduitT forall a b. (a -> b) -> a -> b
$ \Either SomeException r -> Pipe i i o () m b
rest ->
let go :: Pipe i i o () (CatchT m) r -> Pipe i i o () m b
go (Done r
r) = Either SomeException r -> Pipe i i o () m b
rest (forall a b. b -> Either a b
Right r
r)
go (PipeM CatchT m (Pipe i i o () (CatchT m) r)
mp) = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM forall a b. (a -> b) -> a -> b
$ do
Either SomeException (Pipe i i o () (CatchT m) r)
eres <- forall (m :: * -> *) a. CatchT m a -> m (Either SomeException a)
runCatchT CatchT m (Pipe i i o () (CatchT m) r)
mp
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case Either SomeException (Pipe i i o () (CatchT m) r)
eres of
Left SomeException
e -> Either SomeException r -> Pipe i i o () m b
rest forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left SomeException
e
Right Pipe i i o () (CatchT m) r
p -> Pipe i i o () (CatchT m) r -> Pipe i i o () m b
go Pipe i i o () (CatchT m) r
p
go (Leftover Pipe i i o () (CatchT m) r
p i
i) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> l -> Pipe l i o u m r
Leftover (Pipe i i o () (CatchT m) r -> Pipe i i o () m b
go Pipe i i o () (CatchT m) r
p) i
i
go (HaveOutput Pipe i i o () (CatchT m) r
p o
o) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> o -> Pipe l i o u m r
HaveOutput (Pipe i i o () (CatchT m) r -> Pipe i i o () m b
go Pipe i i o () (CatchT m) r
p) o
o
go (NeedInput i -> Pipe i i o () (CatchT m) r
x () -> Pipe i i o () (CatchT m) r
y) = forall l i o u (m :: * -> *) r.
(i -> Pipe l i o u m r)
-> (u -> Pipe l i o u m r) -> Pipe l i o u m r
NeedInput (Pipe i i o () (CatchT m) r -> Pipe i i o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe i i o () (CatchT m) r
x) (Pipe i i o () (CatchT m) r -> Pipe i i o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i i o () (CatchT m) r
y)
in Pipe i i o () (CatchT m) r -> Pipe i i o () m b
go forall a b. (a -> b) -> a -> b
$ forall i o (m :: * -> *) r.
ConduitT i o m r
-> forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b
unConduitT ConduitT i o (CatchT m) r
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done
{-# INLINABLE runCatchC #-}
catchCatchC
:: Monad m
=> ConduitT i o (CatchT m) r
-> (SomeException -> ConduitT i o (CatchT m) r)
-> ConduitT i o (CatchT m) r
catchCatchC :: forall (m :: * -> *) i o r.
Monad m =>
ConduitT i o (CatchT m) r
-> (SomeException -> ConduitT i o (CatchT m) r)
-> ConduitT i o (CatchT m) r
catchCatchC (ConduitT forall b.
(r -> Pipe i i o () (CatchT m) b) -> Pipe i i o () (CatchT m) b
c0) SomeException -> ConduitT i o (CatchT m) r
h =
forall i o (m :: * -> *) r.
(forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m r
ConduitT forall a b. (a -> b) -> a -> b
$ \r -> Pipe i i o () (CatchT m) b
rest ->
let go :: Pipe i i o () (CatchT m) r -> Pipe i i o () (CatchT m) b
go (Done r
r) = r -> Pipe i i o () (CatchT m) b
rest r
r
go (PipeM CatchT m (Pipe i i o () (CatchT m) r)
mp) = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM forall a b. (a -> b) -> a -> b
$ do
Either SomeException (Pipe i i o () (CatchT m) r)
eres <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. CatchT m a -> m (Either SomeException a)
runCatchT CatchT m (Pipe i i o () (CatchT m) r)
mp
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case Either SomeException (Pipe i i o () (CatchT m) r)
eres of
Left SomeException
e -> forall i o (m :: * -> *) r.
ConduitT i o m r
-> forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b
unConduitT (SomeException -> ConduitT i o (CatchT m) r
h SomeException
e) r -> Pipe i i o () (CatchT m) b
rest
Right Pipe i i o () (CatchT m) r
p -> Pipe i i o () (CatchT m) r -> Pipe i i o () (CatchT m) b
go Pipe i i o () (CatchT m) r
p
go (Leftover Pipe i i o () (CatchT m) r
p i
i) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> l -> Pipe l i o u m r
Leftover (Pipe i i o () (CatchT m) r -> Pipe i i o () (CatchT m) b
go Pipe i i o () (CatchT m) r
p) i
i
go (HaveOutput Pipe i i o () (CatchT m) r
p o
o) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> o -> Pipe l i o u m r
HaveOutput (Pipe i i o () (CatchT m) r -> Pipe i i o () (CatchT m) b
go Pipe i i o () (CatchT m) r
p) o
o
go (NeedInput i -> Pipe i i o () (CatchT m) r
x () -> Pipe i i o () (CatchT m) r
y) = forall l i o u (m :: * -> *) r.
(i -> Pipe l i o u m r)
-> (u -> Pipe l i o u m r) -> Pipe l i o u m r
NeedInput (Pipe i i o () (CatchT m) r -> Pipe i i o () (CatchT m) b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe i i o () (CatchT m) r
x) (Pipe i i o () (CatchT m) r -> Pipe i i o () (CatchT m) b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i i o () (CatchT m) r
y)
in Pipe i i o () (CatchT m) r -> Pipe i i o () (CatchT m) b
go (forall b.
(r -> Pipe i i o () (CatchT m) b) -> Pipe i i o () (CatchT m) b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
{-# INLINABLE catchCatchC #-}
maybeC
:: Monad m =>
ConduitT i o m (Maybe a) -> ConduitT i o (M.MaybeT m) a
maybeC :: forall (m :: * -> *) i o a.
Monad m =>
ConduitT i o m (Maybe a) -> ConduitT i o (MaybeT m) a
maybeC ConduitT i o m (Maybe a)
p = do
Maybe a
x <- forall (m :: * -> *) (n :: * -> *) i o r.
Monad m =>
(forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ConduitT i o m (Maybe a)
p
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
M.MaybeT (forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
x)
{-# INLINABLE maybeC #-}
runMaybeC
:: Monad m =>
ConduitT i o (M.MaybeT m) r -> ConduitT i o m (Maybe r)
runMaybeC :: forall (m :: * -> *) i o r.
Monad m =>
ConduitT i o (MaybeT m) r -> ConduitT i o m (Maybe r)
runMaybeC (ConduitT forall b.
(r -> Pipe i i o () (MaybeT m) b) -> Pipe i i o () (MaybeT m) b
c0) =
forall i o (m :: * -> *) r.
(forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m r
ConduitT forall a b. (a -> b) -> a -> b
$ \Maybe r -> Pipe i i o () m b
rest ->
let go :: Pipe i i o () (MaybeT m) r -> Pipe i i o () m b
go (Done r
r) = Maybe r -> Pipe i i o () m b
rest (forall a. a -> Maybe a
Just r
r)
go (PipeM MaybeT m (Pipe i i o () (MaybeT m) r)
mp) = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM forall a b. (a -> b) -> a -> b
$ do
Maybe (Pipe i i o () (MaybeT m) r)
mres <- forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
M.runMaybeT MaybeT m (Pipe i i o () (MaybeT m) r)
mp
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case Maybe (Pipe i i o () (MaybeT m) r)
mres of
Maybe (Pipe i i o () (MaybeT m) r)
Nothing -> Maybe r -> Pipe i i o () m b
rest forall a. Maybe a
Nothing
Just Pipe i i o () (MaybeT m) r
p -> Pipe i i o () (MaybeT m) r -> Pipe i i o () m b
go Pipe i i o () (MaybeT m) r
p
go (Leftover Pipe i i o () (MaybeT m) r
p i
i) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> l -> Pipe l i o u m r
Leftover (Pipe i i o () (MaybeT m) r -> Pipe i i o () m b
go Pipe i i o () (MaybeT m) r
p) i
i
go (HaveOutput Pipe i i o () (MaybeT m) r
p o
o) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> o -> Pipe l i o u m r
HaveOutput (Pipe i i o () (MaybeT m) r -> Pipe i i o () m b
go Pipe i i o () (MaybeT m) r
p) o
o
go (NeedInput i -> Pipe i i o () (MaybeT m) r
x () -> Pipe i i o () (MaybeT m) r
y) = forall l i o u (m :: * -> *) r.
(i -> Pipe l i o u m r)
-> (u -> Pipe l i o u m r) -> Pipe l i o u m r
NeedInput (Pipe i i o () (MaybeT m) r -> Pipe i i o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe i i o () (MaybeT m) r
x) (Pipe i i o () (MaybeT m) r -> Pipe i i o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i i o () (MaybeT m) r
y)
in Pipe i i o () (MaybeT m) r -> Pipe i i o () m b
go (forall b.
(r -> Pipe i i o () (MaybeT m) b) -> Pipe i i o () (MaybeT m) b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
{-# INLINABLE runMaybeC #-}
readerC
:: Monad m =>
(r -> ConduitT i o m a) -> ConduitT i o (R.ReaderT r m) a
readerC :: forall (m :: * -> *) r i o a.
Monad m =>
(r -> ConduitT i o m a) -> ConduitT i o (ReaderT r m) a
readerC r -> ConduitT i o m a
k = do
r
i <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *) r. Monad m => ReaderT r m r
R.ask
forall (m :: * -> *) (n :: * -> *) i o r.
Monad m =>
(forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (r -> ConduitT i o m a
k r
i)
{-# INLINABLE readerC #-}
runReaderC
:: Monad m =>
r -> ConduitT i o (R.ReaderT r m) res -> ConduitT i o m res
runReaderC :: forall (m :: * -> *) r i o res.
Monad m =>
r -> ConduitT i o (ReaderT r m) res -> ConduitT i o m res
runReaderC r
r = forall (m :: * -> *) (n :: * -> *) i o r.
Monad m =>
(forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe (forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
`R.runReaderT` r
r)
{-# INLINABLE runReaderC #-}
stateLC
:: Monad m =>
(s -> ConduitT i o m (a, s)) -> ConduitT i o (SL.StateT s m) a
stateLC :: forall (m :: * -> *) s i o a.
Monad m =>
(s -> ConduitT i o m (a, s)) -> ConduitT i o (StateT s m) a
stateLC s -> ConduitT i o m (a, s)
k = do
s
s <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *) s. Monad m => StateT s m s
SL.get
(a
r, s
s') <- forall (m :: * -> *) (n :: * -> *) i o r.
Monad m =>
(forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (s -> ConduitT i o m (a, s)
k s
s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) s. Monad m => s -> StateT s m ()
SL.put s
s')
forall (m :: * -> *) a. Monad m => a -> m a
return a
r
{-# INLINABLE stateLC #-}
thread :: Monad m
=> (r -> s -> res)
-> (forall a. t m a -> s -> m (a, s))
-> s
-> ConduitT i o (t m) r
-> ConduitT i o m res
thread :: forall (m :: * -> *) r s res (t :: (* -> *) -> * -> *) i o.
Monad m =>
(r -> s -> res)
-> (forall a. t m a -> s -> m (a, s))
-> s
-> ConduitT i o (t m) r
-> ConduitT i o m res
thread r -> s -> res
toRes forall a. t m a -> s -> m (a, s)
runM s
s0 (ConduitT forall b. (r -> Pipe i i o () (t m) b) -> Pipe i i o () (t m) b
c0) =
forall i o (m :: * -> *) r.
(forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m r
ConduitT forall a b. (a -> b) -> a -> b
$ \res -> Pipe i i o () m b
rest ->
let go :: s -> Pipe i i o () (t m) r -> Pipe i i o () m b
go s
s (Done r
r) = res -> Pipe i i o () m b
rest (r -> s -> res
toRes r
r s
s)
go s
s (PipeM t m (Pipe i i o () (t m) r)
mp) = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM forall a b. (a -> b) -> a -> b
$ do
(Pipe i i o () (t m) r
p, s
s') <- forall a. t m a -> s -> m (a, s)
runM t m (Pipe i i o () (t m) r)
mp s
s
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ s -> Pipe i i o () (t m) r -> Pipe i i o () m b
go s
s' Pipe i i o () (t m) r
p
go s
s (Leftover Pipe i i o () (t m) r
p i
i) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> l -> Pipe l i o u m r
Leftover (s -> Pipe i i o () (t m) r -> Pipe i i o () m b
go s
s Pipe i i o () (t m) r
p) i
i
go s
s (NeedInput i -> Pipe i i o () (t m) r
x () -> Pipe i i o () (t m) r
y) = forall l i o u (m :: * -> *) r.
(i -> Pipe l i o u m r)
-> (u -> Pipe l i o u m r) -> Pipe l i o u m r
NeedInput (s -> Pipe i i o () (t m) r -> Pipe i i o () m b
go s
s forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe i i o () (t m) r
x) (s -> Pipe i i o () (t m) r -> Pipe i i o () m b
go s
s forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i i o () (t m) r
y)
go s
s (HaveOutput Pipe i i o () (t m) r
p o
o) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> o -> Pipe l i o u m r
HaveOutput (s -> Pipe i i o () (t m) r -> Pipe i i o () m b
go s
s Pipe i i o () (t m) r
p) o
o
in s -> Pipe i i o () (t m) r -> Pipe i i o () m b
go s
s0 (forall b. (r -> Pipe i i o () (t m) b) -> Pipe i i o () (t m) b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
{-# INLINABLE thread #-}
runStateLC
:: Monad m =>
s -> ConduitT i o (SL.StateT s m) r -> ConduitT i o m (r, s)
runStateLC :: forall (m :: * -> *) s i o r.
Monad m =>
s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
runStateLC = forall (m :: * -> *) r s res (t :: (* -> *) -> * -> *) i o.
Monad m =>
(r -> s -> res)
-> (forall a. t m a -> s -> m (a, s))
-> s
-> ConduitT i o (t m) r
-> ConduitT i o m res
thread (,) forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
SL.runStateT
{-# INLINABLE runStateLC #-}
evalStateLC
:: Monad m =>
s -> ConduitT i o (SL.StateT s m) r -> ConduitT i o m r
evalStateLC :: forall (m :: * -> *) s i o r.
Monad m =>
s -> ConduitT i o (StateT s m) r -> ConduitT i o m r
evalStateLC s
s ConduitT i o (StateT s m) r
p = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> a
fst forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s i o r.
Monad m =>
s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
runStateLC s
s ConduitT i o (StateT s m) r
p
{-# INLINABLE evalStateLC #-}
execStateLC
:: Monad m =>
s -> ConduitT i o (SL.StateT s m) r -> ConduitT i o m s
execStateLC :: forall (m :: * -> *) s i o r.
Monad m =>
s -> ConduitT i o (StateT s m) r -> ConduitT i o m s
execStateLC s
s ConduitT i o (StateT s m) r
p = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s i o r.
Monad m =>
s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
runStateLC s
s ConduitT i o (StateT s m) r
p
{-# INLINABLE execStateLC #-}
stateC
:: Monad m =>
(s -> ConduitT i o m (a, s)) -> ConduitT i o (SS.StateT s m) a
stateC :: forall (m :: * -> *) s i o a.
Monad m =>
(s -> ConduitT i o m (a, s)) -> ConduitT i o (StateT s m) a
stateC s -> ConduitT i o m (a, s)
k = do
s
s <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *) s. Monad m => StateT s m s
SS.get
(a
r, s
s') <- forall (m :: * -> *) (n :: * -> *) i o r.
Monad m =>
(forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (s -> ConduitT i o m (a, s)
k s
s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) s. Monad m => s -> StateT s m ()
SS.put s
s')
forall (m :: * -> *) a. Monad m => a -> m a
return a
r
{-# INLINABLE stateC #-}
runStateC
:: Monad m =>
s -> ConduitT i o (SS.StateT s m) r -> ConduitT i o m (r, s)
runStateC :: forall (m :: * -> *) s i o r.
Monad m =>
s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
runStateC = forall (m :: * -> *) r s res (t :: (* -> *) -> * -> *) i o.
Monad m =>
(r -> s -> res)
-> (forall a. t m a -> s -> m (a, s))
-> s
-> ConduitT i o (t m) r
-> ConduitT i o m res
thread (,) forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
SS.runStateT
{-# INLINABLE runStateC #-}
evalStateC
:: Monad m =>
s -> ConduitT i o (SS.StateT s m) r -> ConduitT i o m r
evalStateC :: forall (m :: * -> *) s i o r.
Monad m =>
s -> ConduitT i o (StateT s m) r -> ConduitT i o m r
evalStateC s
s ConduitT i o (StateT s m) r
p = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> a
fst forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s i o r.
Monad m =>
s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
runStateC s
s ConduitT i o (StateT s m) r
p
{-# INLINABLE evalStateC #-}
execStateC
:: Monad m =>
s -> ConduitT i o (SS.StateT s m) r -> ConduitT i o m s
execStateC :: forall (m :: * -> *) s i o r.
Monad m =>
s -> ConduitT i o (StateT s m) r -> ConduitT i o m s
execStateC s
s ConduitT i o (StateT s m) r
p = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s i o r.
Monad m =>
s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
runStateC s
s ConduitT i o (StateT s m) r
p
{-# INLINABLE execStateC #-}
writerLC
:: (Monad m, Monoid w) =>
ConduitT i o m (b, w) -> ConduitT i o (WL.WriterT w m) b
writerLC :: forall (m :: * -> *) w i o b.
(Monad m, Monoid w) =>
ConduitT i o m (b, w) -> ConduitT i o (WriterT w m) b
writerLC ConduitT i o m (b, w)
p = do
(b
r, w
w) <- forall (m :: * -> *) (n :: * -> *) i o r.
Monad m =>
(forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ConduitT i o m (b, w)
p
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
WL.tell w
w
forall (m :: * -> *) a. Monad m => a -> m a
return b
r
{-# INLINABLE writerLC #-}
runWriterLC
:: (Monad m, Monoid w) =>
ConduitT i o (WL.WriterT w m) r -> ConduitT i o m (r, w)
runWriterLC :: forall (m :: * -> *) w i o r.
(Monad m, Monoid w) =>
ConduitT i o (WriterT w m) r -> ConduitT i o m (r, w)
runWriterLC = forall (m :: * -> *) r s res (t :: (* -> *) -> * -> *) i o.
Monad m =>
(r -> s -> res)
-> (forall a. t m a -> s -> m (a, s))
-> s
-> ConduitT i o (t m) r
-> ConduitT i o m res
thread (,) forall {m :: * -> *} {b} {a}.
(Monad m, Monoid b) =>
WriterT b m a -> b -> m (a, b)
run forall a. Monoid a => a
mempty
where
run :: WriterT b m a -> b -> m (a, b)
run WriterT b m a
m b
w = do
(a
a, b
w') <- forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
WL.runWriterT WriterT b m a
m
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, b
w forall a. Monoid a => a -> a -> a
`mappend` b
w')
{-# INLINABLE runWriterLC #-}
execWriterLC
:: (Monad m, Monoid w) =>
ConduitT i o (WL.WriterT w m) r -> ConduitT i o m w
execWriterLC :: forall (m :: * -> *) w i o r.
(Monad m, Monoid w) =>
ConduitT i o (WriterT w m) r -> ConduitT i o m w
execWriterLC ConduitT i o (WriterT w m) r
p = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) w i o r.
(Monad m, Monoid w) =>
ConduitT i o (WriterT w m) r -> ConduitT i o m (r, w)
runWriterLC ConduitT i o (WriterT w m) r
p
{-# INLINABLE execWriterLC #-}
writerC
:: (Monad m, Monoid w) =>
ConduitT i o m (b, w) -> ConduitT i o (WS.WriterT w m) b
writerC :: forall (m :: * -> *) w i o b.
(Monad m, Monoid w) =>
ConduitT i o m (b, w) -> ConduitT i o (WriterT w m) b
writerC ConduitT i o m (b, w)
p = do
(b
r, w
w) <- forall (m :: * -> *) (n :: * -> *) i o r.
Monad m =>
(forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ConduitT i o m (b, w)
p
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
WS.tell w
w
forall (m :: * -> *) a. Monad m => a -> m a
return b
r
{-# INLINABLE writerC #-}
runWriterC
:: (Monad m, Monoid w) =>
ConduitT i o (WS.WriterT w m) r -> ConduitT i o m (r, w)
runWriterC :: forall (m :: * -> *) w i o r.
(Monad m, Monoid w) =>
ConduitT i o (WriterT w m) r -> ConduitT i o m (r, w)
runWriterC = forall (m :: * -> *) r s res (t :: (* -> *) -> * -> *) i o.
Monad m =>
(r -> s -> res)
-> (forall a. t m a -> s -> m (a, s))
-> s
-> ConduitT i o (t m) r
-> ConduitT i o m res
thread (,) forall {m :: * -> *} {b} {a}.
(Monad m, Monoid b) =>
WriterT b m a -> b -> m (a, b)
run forall a. Monoid a => a
mempty
where
run :: WriterT b m a -> b -> m (a, b)
run WriterT b m a
m b
w = do
(a
a, b
w') <- forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
WS.runWriterT WriterT b m a
m
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, b
w forall a. Monoid a => a -> a -> a
`mappend` b
w')
{-# INLINABLE runWriterC #-}
execWriterC
:: (Monad m, Monoid w) =>
ConduitT i o (WS.WriterT w m) r -> ConduitT i o m w
execWriterC :: forall (m :: * -> *) w i o r.
(Monad m, Monoid w) =>
ConduitT i o (WriterT w m) r -> ConduitT i o m w
execWriterC ConduitT i o (WriterT w m) r
p = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) w i o r.
(Monad m, Monoid w) =>
ConduitT i o (WriterT w m) r -> ConduitT i o m (r, w)
runWriterC ConduitT i o (WriterT w m) r
p
{-# INLINABLE execWriterC #-}
rwsLC
:: (Monad m, Monoid w) =>
(r -> s -> ConduitT i o m (a, s, w)) -> ConduitT i o (RWSL.RWST r w s m) a
rwsLC :: forall (m :: * -> *) w r s i o a.
(Monad m, Monoid w) =>
(r -> s -> ConduitT i o m (a, s, w))
-> ConduitT i o (RWST r w s m) a
rwsLC r -> s -> ConduitT i o m (a, s, w)
k = do
r
i <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall w (m :: * -> *) r s. (Monoid w, Monad m) => RWST r w s m r
RWSL.ask
s
s <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall w (m :: * -> *) r s. (Monoid w, Monad m) => RWST r w s m s
RWSL.get
(a
r, s
s', w
w) <- forall (m :: * -> *) (n :: * -> *) i o r.
Monad m =>
(forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (r -> s -> ConduitT i o m (a, s, w)
k r
i s
s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ do
forall w (m :: * -> *) s r.
(Monoid w, Monad m) =>
s -> RWST r w s m ()
RWSL.put s
s'
forall (m :: * -> *) w r s. Monad m => w -> RWST r w s m ()
RWSL.tell w
w
forall (m :: * -> *) a. Monad m => a -> m a
return a
r
{-# INLINABLE rwsLC #-}
runRWSLC
:: (Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWSL.RWST r w s m) res
-> ConduitT i o m (res, s, w)
runRWSLC :: forall (m :: * -> *) w r s i o res.
(Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
runRWSLC r
r s
s0 = forall (m :: * -> *) r s res (t :: (* -> *) -> * -> *) i o.
Monad m =>
(r -> s -> res)
-> (forall a. t m a -> s -> m (a, s))
-> s
-> ConduitT i o (t m) r
-> ConduitT i o m res
thread forall {a} {b} {c}. a -> (b, c) -> (a, b, c)
toRes forall {m :: * -> *} {b} {a} {a}.
(Monad m, Monoid b) =>
RWST r b a m a -> (a, b) -> m (a, (a, b))
run (s
s0, forall a. Monoid a => a
mempty)
where
toRes :: a -> (b, c) -> (a, b, c)
toRes a
a (b
s, c
w) = (a
a, b
s, c
w)
run :: RWST r b a m a -> (a, b) -> m (a, (a, b))
run RWST r b a m a
m (a
s, b
w) = do
(a
res, a
s', b
w') <- forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
RWSL.runRWST RWST r b a m a
m r
r a
s
forall (m :: * -> *) a. Monad m => a -> m a
return (a
res, (a
s', b
w forall a. Monoid a => a -> a -> a
`mappend` b
w'))
{-# INLINABLE runRWSLC #-}
evalRWSLC
:: (Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWSL.RWST r w s m) res
-> ConduitT i o m (res, w)
evalRWSLC :: forall (m :: * -> *) w r s i o res.
(Monad m, Monoid w) =>
r
-> s -> ConduitT i o (RWST r w s m) res -> ConduitT i o m (res, w)
evalRWSLC r
i s
s ConduitT i o (RWST r w s m) res
p = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {a} {b} {b}. (a, b, b) -> (a, b)
f forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) w r s i o res.
(Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
runRWSLC r
i s
s ConduitT i o (RWST r w s m) res
p
where f :: (a, b, b) -> (a, b)
f (a, b, b)
x = let (a
r, b
_, b
w) = (a, b, b)
x in (a
r, b
w)
{-# INLINABLE evalRWSLC #-}
execRWSLC
:: (Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWSL.RWST r w s m) res
-> ConduitT i o m (s, w)
execRWSLC :: forall (m :: * -> *) w r s i o res.
(Monad m, Monoid w) =>
r -> s -> ConduitT i o (RWST r w s m) res -> ConduitT i o m (s, w)
execRWSLC r
i s
s ConduitT i o (RWST r w s m) res
p = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {a} {a} {b}. (a, a, b) -> (a, b)
f forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) w r s i o res.
(Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
runRWSLC r
i s
s ConduitT i o (RWST r w s m) res
p
where f :: (a, a, b) -> (a, b)
f (a, a, b)
x = let (a
_, a
s2, b
w2) = (a, a, b)
x in (a
s2, b
w2)
{-# INLINABLE execRWSLC #-}
rwsC
:: (Monad m, Monoid w) =>
(r -> s -> ConduitT i o m (a, s, w)) -> ConduitT i o (RWSS.RWST r w s m) a
rwsC :: forall (m :: * -> *) w r s i o a.
(Monad m, Monoid w) =>
(r -> s -> ConduitT i o m (a, s, w))
-> ConduitT i o (RWST r w s m) a
rwsC r -> s -> ConduitT i o m (a, s, w)
k = do
r
i <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall w (m :: * -> *) r s. (Monoid w, Monad m) => RWST r w s m r
RWSS.ask
s
s <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall w (m :: * -> *) r s. (Monoid w, Monad m) => RWST r w s m s
RWSS.get
(a
r, s
s', w
w) <- forall (m :: * -> *) (n :: * -> *) i o r.
Monad m =>
(forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (r -> s -> ConduitT i o m (a, s, w)
k r
i s
s)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ do
forall w (m :: * -> *) s r.
(Monoid w, Monad m) =>
s -> RWST r w s m ()
RWSS.put s
s'
forall (m :: * -> *) w r s. Monad m => w -> RWST r w s m ()
RWSS.tell w
w
forall (m :: * -> *) a. Monad m => a -> m a
return a
r
{-# INLINABLE rwsC #-}
runRWSC
:: (Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWSS.RWST r w s m) res
-> ConduitT i o m (res, s, w)
runRWSC :: forall (m :: * -> *) w r s i o res.
(Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
runRWSC r
r s
s0 = forall (m :: * -> *) r s res (t :: (* -> *) -> * -> *) i o.
Monad m =>
(r -> s -> res)
-> (forall a. t m a -> s -> m (a, s))
-> s
-> ConduitT i o (t m) r
-> ConduitT i o m res
thread forall {a} {b} {c}. a -> (b, c) -> (a, b, c)
toRes forall {m :: * -> *} {b} {a} {a}.
(Monad m, Monoid b) =>
RWST r b a m a -> (a, b) -> m (a, (a, b))
run (s
s0, forall a. Monoid a => a
mempty)
where
toRes :: a -> (b, c) -> (a, b, c)
toRes a
a (b
s, c
w) = (a
a, b
s, c
w)
run :: RWST r b a m a -> (a, b) -> m (a, (a, b))
run RWST r b a m a
m (a
s, b
w) = do
(a
res, a
s', b
w') <- forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
RWSS.runRWST RWST r b a m a
m r
r a
s
forall (m :: * -> *) a. Monad m => a -> m a
return (a
res, (a
s', b
w forall a. Monoid a => a -> a -> a
`mappend` b
w'))
{-# INLINABLE runRWSC #-}
evalRWSC
:: (Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWSS.RWST r w s m) res
-> ConduitT i o m (res, w)
evalRWSC :: forall (m :: * -> *) w r s i o res.
(Monad m, Monoid w) =>
r
-> s -> ConduitT i o (RWST r w s m) res -> ConduitT i o m (res, w)
evalRWSC r
i s
s ConduitT i o (RWST r w s m) res
p = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {a} {b} {b}. (a, b, b) -> (a, b)
f forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) w r s i o res.
(Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
runRWSC r
i s
s ConduitT i o (RWST r w s m) res
p
where f :: (a, b, b) -> (a, b)
f (a, b, b)
x = let (a
r, b
_, b
w) = (a, b, b)
x in (a
r, b
w)
{-# INLINABLE evalRWSC #-}
execRWSC
:: (Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWSS.RWST r w s m) res
-> ConduitT i o m (s, w)
execRWSC :: forall (m :: * -> *) w r s i o res.
(Monad m, Monoid w) =>
r -> s -> ConduitT i o (RWST r w s m) res -> ConduitT i o m (s, w)
execRWSC r
i s
s ConduitT i o (RWST r w s m) res
p = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {a} {a} {b}. (a, a, b) -> (a, b)
f forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) w r s i o res.
(Monad m, Monoid w) =>
r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
runRWSC r
i s
s ConduitT i o (RWST r w s m) res
p
where f :: (a, a, b) -> (a, b)
f (a, a, b)
x = let (a
_, a
s2, b
w2) = (a, a, b)
x in (a
s2, b
w2)
{-# INLINABLE execRWSC #-}