{-# LANGUAGE RankNTypes #-}
-- | Allow monad transformers to be run\/eval\/exec in a section of conduit
-- rather then needing to run across the whole conduit.  The circumvents many
-- of the problems with breaking the monad transformer laws.  For more
-- information, see the announcement blog post:
-- <http://www.yesodweb.com/blog/2014/01/conduit-transformer-exception>
--
-- This module was added in conduit 1.0.11.
module Data.Conduit.Lift (
    -- * ExceptT
    exceptC,
    runExceptC,
    catchExceptC,

    -- * CatchC
    runCatchC,
    catchCatchC,

    -- * MaybeT
    maybeC,
    runMaybeC,

    -- * ReaderT
    readerC,
    runReaderC,

    -- * StateT, lazy
    stateLC,
    runStateLC,
    evalStateLC,
    execStateLC,

    -- ** Strict
    stateC,
    runStateC,
    evalStateC,
    execStateC,

    -- * WriterT, lazy
    writerLC,
    runWriterLC,
    execWriterLC,

    -- ** Strict
    writerC,
    runWriterC,
    execWriterC,

    -- * RWST, lazy
    rwsLC,
    runRWSLC,
    evalRWSLC,
    execRWSLC,

    -- ** Strict
    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)

-- | Wrap the base monad in 'Ex.ExceptT'
--
-- Since 1.2.12
exceptC
  :: Monad m =>
     ConduitT i o m (Either e a) -> ConduitT i o (Ex.ExceptT e m) a
exceptC :: 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 a. m a -> ExceptT e m a)
-> ConduitT i o m (Either e a)
-> ConduitT i o (ExceptT e m) (Either e a)
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 a. m a -> ExceptT e m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ConduitT i o m (Either e a)
p
    ExceptT e m a -> ConduitT i o (ExceptT e m) a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ExceptT e m a -> ConduitT i o (ExceptT e m) a)
-> ExceptT e m a -> ConduitT i o (ExceptT e m) a
forall a b. (a -> b) -> a -> b
$ m (Either e a) -> ExceptT e m a
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
Ex.ExceptT (Either e a -> m (Either e a)
forall (m :: * -> *) a. Monad m => a -> m a
return Either e a
x)

-- | Run 'Ex.ExceptT' in the base monad
--
-- Since 1.2.12
runExceptC
  :: Monad m =>
     ConduitT i o (Ex.ExceptT e m) r -> ConduitT i o m (Either e r)
runExceptC :: 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 b. (Either e r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m (Either e r)
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 b. (Either e r -> Pipe i i o () m b) -> Pipe i i o () m b)
 -> ConduitT i o m (Either e r))
-> (forall b.
    (Either e r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m (Either e r)
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 (r -> Either e r
forall a b. b -> Either a b
Right r
r)
            go (PipeM ExceptT e m (Pipe i i o () (ExceptT e m) r)
mp) = m (Pipe i i o () m b) -> Pipe i i o () m b
forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (m (Pipe i i o () m b) -> Pipe i i o () m b)
-> m (Pipe i i o () m b) -> Pipe i i o () m b
forall a b. (a -> b) -> a -> b
$ do
                Either e (Pipe i i o () (ExceptT e m) r)
eres <- ExceptT e m (Pipe i i o () (ExceptT e m) r)
-> m (Either e (Pipe i i o () (ExceptT e m) r))
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
                Pipe i i o () m b -> m (Pipe i i o () m b)
forall (m :: * -> *) a. Monad m => a -> m a
return (Pipe i i o () m b -> m (Pipe i i o () m b))
-> Pipe i i o () m b -> m (Pipe i i o () m b)
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 (Either e r -> Pipe i i o () m b)
-> Either e r -> Pipe i i o () m b
forall a b. (a -> b) -> a -> b
$ e -> Either e r
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) = Pipe i i o () m b -> i -> Pipe i i o () m b
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) = Pipe i i o () m b -> o -> Pipe i i o () m b
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) = (i -> Pipe i i o () m b)
-> (() -> Pipe i i o () m b) -> Pipe i i o () m b
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 (Pipe i i o () (ExceptT e m) r -> Pipe i i o () m b)
-> (i -> Pipe i i o () (ExceptT e m) r) -> i -> Pipe i i o () m b
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 (Pipe i i o () (ExceptT e m) r -> Pipe i i o () m b)
-> (() -> Pipe i i o () (ExceptT e m) r) -> () -> Pipe i i o () m b
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 ((r -> Pipe i i o () (ExceptT e m) r)
-> Pipe i i o () (ExceptT e m) r
forall b.
(r -> Pipe i i o () (ExceptT e m) b)
-> Pipe i i o () (ExceptT e m) b
c0 r -> Pipe i i o () (ExceptT e m) r
forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
{-# INLINABLE runExceptC #-}

-- | Catch an error in the base monad
--
-- Since 1.2.12
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 :: 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 b.
 (r -> Pipe i i o () (ExceptT e m) b)
 -> Pipe i i o () (ExceptT e m) b)
-> ConduitT i o (ExceptT e m) r
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 b.
  (r -> Pipe i i o () (ExceptT e m) b)
  -> Pipe i i o () (ExceptT e m) b)
 -> ConduitT i o (ExceptT e m) r)
-> (forall b.
    (r -> Pipe i i o () (ExceptT e m) b)
    -> Pipe i i o () (ExceptT e m) b)
-> ConduitT i o (ExceptT e m) r
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) = ExceptT e m (Pipe i i o () (ExceptT e m) b)
-> Pipe i i o () (ExceptT e m) b
forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (ExceptT e m (Pipe i i o () (ExceptT e m) b)
 -> Pipe i i o () (ExceptT e m) b)
-> ExceptT e m (Pipe i i o () (ExceptT e m) b)
-> Pipe i i o () (ExceptT e m) b
forall a b. (a -> b) -> a -> b
$ do
                Either e (Pipe i i o () (ExceptT e m) r)
eres <- m (Either e (Pipe i i o () (ExceptT e m) r))
-> ExceptT e m (Either e (Pipe i i o () (ExceptT e m) r))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either e (Pipe i i o () (ExceptT e m) r))
 -> ExceptT e m (Either e (Pipe i i o () (ExceptT e m) r)))
-> m (Either e (Pipe i i o () (ExceptT e m) r))
-> ExceptT e m (Either e (Pipe i i o () (ExceptT e m) r))
forall a b. (a -> b) -> a -> b
$ ExceptT e m (Pipe i i o () (ExceptT e m) r)
-> m (Either e (Pipe i i o () (ExceptT e m) r))
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
                Pipe i i o () (ExceptT e m) b
-> ExceptT e m (Pipe i i o () (ExceptT e m) b)
forall (m :: * -> *) a. Monad m => a -> m a
return (Pipe i i o () (ExceptT e m) b
 -> ExceptT e m (Pipe i i o () (ExceptT e m) b))
-> Pipe i i o () (ExceptT e m) b
-> ExceptT e m (Pipe i i o () (ExceptT e m) b)
forall a b. (a -> b) -> a -> b
$ case Either e (Pipe i i o () (ExceptT e m) r)
eres of
                    Left e
e -> ConduitT i o (ExceptT e m) r
-> (r -> Pipe i i o () (ExceptT e m) b)
-> Pipe i i o () (ExceptT e m) 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 (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) = Pipe i i o () (ExceptT e m) b -> i -> Pipe i i o () (ExceptT e m) b
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) = Pipe i i o () (ExceptT e m) b -> o -> Pipe i i o () (ExceptT e m) b
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) = (i -> Pipe i i o () (ExceptT e m) b)
-> (() -> Pipe i i o () (ExceptT e m) b)
-> Pipe i i o () (ExceptT e m) b
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 (Pipe i i o () (ExceptT e m) r -> Pipe i i o () (ExceptT e m) b)
-> (i -> Pipe i i o () (ExceptT e m) r)
-> i
-> Pipe i i o () (ExceptT e m) b
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 (Pipe i i o () (ExceptT e m) r -> Pipe i i o () (ExceptT e m) b)
-> (() -> Pipe i i o () (ExceptT e m) r)
-> ()
-> Pipe i i o () (ExceptT e m) b
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 (Pipe i i o () (ExceptT e m) r -> Pipe i i o () (ExceptT e m) b)
-> Pipe i i o () (ExceptT e m) r -> Pipe i i o () (ExceptT e m) b
forall a b. (a -> b) -> a -> b
$ ConduitT i o (ExceptT e m) r
-> (r -> Pipe i i o () (ExceptT e m) r)
-> Pipe i i o () (ExceptT e m) r
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 r -> Pipe i i o () (ExceptT e m) r
forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done
  where
{-# INLINABLE catchExceptC #-}

-- | Run 'CatchT' in the base monad
--
-- Since 1.1.0
runCatchC
  :: Monad m =>
     ConduitT i o (CatchT m) r -> ConduitT i o m (Either SomeException r)
runCatchC :: ConduitT i o (CatchT m) r
-> ConduitT i o m (Either SomeException r)
runCatchC ConduitT i o (CatchT m) r
c0 =
    (forall b.
 (Either SomeException r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m (Either SomeException r)
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 b.
  (Either SomeException r -> Pipe i i o () m b) -> Pipe i i o () m b)
 -> ConduitT i o m (Either SomeException r))
-> (forall b.
    (Either SomeException r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m (Either SomeException r)
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 (r -> Either SomeException r
forall a b. b -> Either a b
Right r
r)
            go (PipeM CatchT m (Pipe i i o () (CatchT m) r)
mp) = m (Pipe i i o () m b) -> Pipe i i o () m b
forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (m (Pipe i i o () m b) -> Pipe i i o () m b)
-> m (Pipe i i o () m b) -> Pipe i i o () m b
forall a b. (a -> b) -> a -> b
$ do
                Either SomeException (Pipe i i o () (CatchT m) r)
eres <- CatchT m (Pipe i i o () (CatchT m) r)
-> m (Either SomeException (Pipe i i o () (CatchT m) r))
forall (m :: * -> *) a. CatchT m a -> m (Either SomeException a)
runCatchT CatchT m (Pipe i i o () (CatchT m) r)
mp
                Pipe i i o () m b -> m (Pipe i i o () m b)
forall (m :: * -> *) a. Monad m => a -> m a
return (Pipe i i o () m b -> m (Pipe i i o () m b))
-> Pipe i i o () m b -> m (Pipe i i o () m b)
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 (Either SomeException r -> Pipe i i o () m b)
-> Either SomeException r -> Pipe i i o () m b
forall a b. (a -> b) -> a -> b
$ SomeException -> Either SomeException r
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) = Pipe i i o () m b -> i -> Pipe i i o () m b
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) = Pipe i i o () m b -> o -> Pipe i i o () m b
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) = (i -> Pipe i i o () m b)
-> (() -> Pipe i i o () m b) -> Pipe i i o () m b
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 (Pipe i i o () (CatchT m) r -> Pipe i i o () m b)
-> (i -> Pipe i i o () (CatchT m) r) -> i -> Pipe i i o () m b
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 (Pipe i i o () (CatchT m) r -> Pipe i i o () m b)
-> (() -> Pipe i i o () (CatchT m) r) -> () -> Pipe i i o () m b
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 (Pipe i i o () (CatchT m) r -> Pipe i i o () m b)
-> Pipe i i o () (CatchT m) r -> Pipe i i o () m b
forall a b. (a -> b) -> a -> b
$ ConduitT i o (CatchT m) r
-> (r -> Pipe i i o () (CatchT m) r) -> Pipe i i o () (CatchT m) r
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 r -> Pipe i i o () (CatchT m) r
forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done
{-# INLINABLE runCatchC #-}

-- | Catch an exception in the base monad
--
-- Since 1.1.0
catchCatchC
  :: Monad m
  => ConduitT i o (CatchT m) r
  -> (SomeException -> ConduitT i o (CatchT m) r)
  -> ConduitT i o (CatchT m) r
catchCatchC :: 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 b.
 (r -> Pipe i i o () (CatchT m) b) -> Pipe i i o () (CatchT m) b)
-> ConduitT i o (CatchT m) r
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 b.
  (r -> Pipe i i o () (CatchT m) b) -> Pipe i i o () (CatchT m) b)
 -> ConduitT i o (CatchT m) r)
-> (forall b.
    (r -> Pipe i i o () (CatchT m) b) -> Pipe i i o () (CatchT m) b)
-> ConduitT i o (CatchT m) r
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) = CatchT m (Pipe i i o () (CatchT m) b) -> Pipe i i o () (CatchT m) b
forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (CatchT m (Pipe i i o () (CatchT m) b)
 -> Pipe i i o () (CatchT m) b)
-> CatchT m (Pipe i i o () (CatchT m) b)
-> Pipe i i o () (CatchT m) b
forall a b. (a -> b) -> a -> b
$ do
                Either SomeException (Pipe i i o () (CatchT m) r)
eres <- m (Either SomeException (Pipe i i o () (CatchT m) r))
-> CatchT m (Either SomeException (Pipe i i o () (CatchT m) r))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either SomeException (Pipe i i o () (CatchT m) r))
 -> CatchT m (Either SomeException (Pipe i i o () (CatchT m) r)))
-> m (Either SomeException (Pipe i i o () (CatchT m) r))
-> CatchT m (Either SomeException (Pipe i i o () (CatchT m) r))
forall a b. (a -> b) -> a -> b
$ CatchT m (Pipe i i o () (CatchT m) r)
-> m (Either SomeException (Pipe i i o () (CatchT m) r))
forall (m :: * -> *) a. CatchT m a -> m (Either SomeException a)
runCatchT CatchT m (Pipe i i o () (CatchT m) r)
mp
                Pipe i i o () (CatchT m) b -> CatchT m (Pipe i i o () (CatchT m) b)
forall (m :: * -> *) a. Monad m => a -> m a
return (Pipe i i o () (CatchT m) b
 -> CatchT m (Pipe i i o () (CatchT m) b))
-> Pipe i i o () (CatchT m) b
-> CatchT m (Pipe i i o () (CatchT m) b)
forall a b. (a -> b) -> a -> b
$ case Either SomeException (Pipe i i o () (CatchT m) r)
eres of
                    Left SomeException
e -> ConduitT i o (CatchT m) r
-> (r -> Pipe i i o () (CatchT m) b) -> Pipe i i o () (CatchT m) 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 (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) = Pipe i i o () (CatchT m) b -> i -> Pipe i i o () (CatchT m) b
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) = Pipe i i o () (CatchT m) b -> o -> Pipe i i o () (CatchT m) b
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) = (i -> Pipe i i o () (CatchT m) b)
-> (() -> Pipe i i o () (CatchT m) b) -> Pipe i i o () (CatchT m) b
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 (Pipe i i o () (CatchT m) r -> Pipe i i o () (CatchT m) b)
-> (i -> Pipe i i o () (CatchT m) r)
-> i
-> Pipe i i o () (CatchT m) b
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 (Pipe i i o () (CatchT m) r -> Pipe i i o () (CatchT m) b)
-> (() -> Pipe i i o () (CatchT m) r)
-> ()
-> Pipe i i o () (CatchT m) b
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 ((r -> Pipe i i o () (CatchT m) r) -> Pipe i i o () (CatchT m) r
forall b.
(r -> Pipe i i o () (CatchT m) b) -> Pipe i i o () (CatchT m) b
c0 r -> Pipe i i o () (CatchT m) r
forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
{-# INLINABLE catchCatchC #-}

-- | Wrap the base monad in 'M.MaybeT'
--
-- Since 1.0.11
maybeC
  :: Monad m =>
     ConduitT i o m (Maybe a) -> ConduitT i o (M.MaybeT m) a
maybeC :: 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 a. m a -> MaybeT m a)
-> ConduitT i o m (Maybe a) -> ConduitT i o (MaybeT m) (Maybe a)
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 a. m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ConduitT i o m (Maybe a)
p
    MaybeT m a -> ConduitT i o (MaybeT m) a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MaybeT m a -> ConduitT i o (MaybeT m) a)
-> MaybeT m a -> ConduitT i o (MaybeT m) a
forall a b. (a -> b) -> a -> b
$ m (Maybe a) -> MaybeT m a
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
M.MaybeT (Maybe a -> m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
x)
{-# INLINABLE maybeC #-}

-- | Run 'M.MaybeT' in the base monad
--
-- Since 1.0.11
runMaybeC
  :: Monad m =>
     ConduitT i o (M.MaybeT m) r -> ConduitT i o m (Maybe r)
runMaybeC :: 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 b. (Maybe r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m (Maybe r)
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 b. (Maybe r -> Pipe i i o () m b) -> Pipe i i o () m b)
 -> ConduitT i o m (Maybe r))
-> (forall b. (Maybe r -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m (Maybe r)
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 (r -> Maybe r
forall a. a -> Maybe a
Just r
r)
            go (PipeM MaybeT m (Pipe i i o () (MaybeT m) r)
mp) = m (Pipe i i o () m b) -> Pipe i i o () m b
forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (m (Pipe i i o () m b) -> Pipe i i o () m b)
-> m (Pipe i i o () m b) -> Pipe i i o () m b
forall a b. (a -> b) -> a -> b
$ do
                Maybe (Pipe i i o () (MaybeT m) r)
mres <- MaybeT m (Pipe i i o () (MaybeT m) r)
-> m (Maybe (Pipe i i o () (MaybeT m) r))
forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
M.runMaybeT MaybeT m (Pipe i i o () (MaybeT m) r)
mp
                Pipe i i o () m b -> m (Pipe i i o () m b)
forall (m :: * -> *) a. Monad m => a -> m a
return (Pipe i i o () m b -> m (Pipe i i o () m b))
-> Pipe i i o () m b -> m (Pipe i i o () m b)
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 Maybe r
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) = Pipe i i o () m b -> i -> Pipe i i o () m b
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) = Pipe i i o () m b -> o -> Pipe i i o () m b
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) = (i -> Pipe i i o () m b)
-> (() -> Pipe i i o () m b) -> Pipe i i o () m b
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 (Pipe i i o () (MaybeT m) r -> Pipe i i o () m b)
-> (i -> Pipe i i o () (MaybeT m) r) -> i -> Pipe i i o () m b
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 (Pipe i i o () (MaybeT m) r -> Pipe i i o () m b)
-> (() -> Pipe i i o () (MaybeT m) r) -> () -> Pipe i i o () m b
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 ((r -> Pipe i i o () (MaybeT m) r) -> Pipe i i o () (MaybeT m) r
forall b.
(r -> Pipe i i o () (MaybeT m) b) -> Pipe i i o () (MaybeT m) b
c0 r -> Pipe i i o () (MaybeT m) r
forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
{-# INLINABLE runMaybeC #-}

-- | Wrap the base monad in 'R.ReaderT'
--
-- Since 1.0.11
readerC
  :: Monad m =>
     (r -> ConduitT i o m a) -> ConduitT i o (R.ReaderT r m) a
readerC :: (r -> ConduitT i o m a) -> ConduitT i o (ReaderT r m) a
readerC r -> ConduitT i o m a
k = do
    r
i <- ReaderT r m r -> ConduitT i o (ReaderT r m) r
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ReaderT r m r
forall (m :: * -> *) r. Monad m => ReaderT r m r
R.ask
    (forall a. m a -> ReaderT r m a)
-> ConduitT i o m a -> ConduitT i o (ReaderT r m) a
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 a. m a -> ReaderT r m a
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 #-}

-- | Run 'R.ReaderT' in the base monad
--
-- Since 1.0.11
runReaderC
  :: Monad m =>
     r -> ConduitT i o (R.ReaderT r m) res -> ConduitT i o m res
runReaderC :: r -> ConduitT i o (ReaderT r m) res -> ConduitT i o m res
runReaderC r
r = (forall a. ReaderT r m a -> m a)
-> ConduitT i o (ReaderT r m) res -> ConduitT i o m res
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 (ReaderT r m a -> r -> m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
`R.runReaderT` r
r)
{-# INLINABLE runReaderC #-}


-- | Wrap the base monad in 'SL.StateT'
--
-- Since 1.0.11
stateLC
  :: Monad m =>
     (s -> ConduitT i o m (a, s)) -> ConduitT i o (SL.StateT s m) a
stateLC :: (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 <- StateT s m s -> ConduitT i o (StateT s m) s
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift StateT s m s
forall (m :: * -> *) s. Monad m => StateT s m s
SL.get
    (a
r, s
s') <- (forall a. m a -> StateT s m a)
-> ConduitT i o m (a, s) -> ConduitT i o (StateT s m) (a, 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 a. m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (s -> ConduitT i o m (a, s)
k s
s)
    StateT s m () -> ConduitT i o (StateT s m) ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (s -> StateT s m ()
forall (m :: * -> *) s. Monad m => s -> StateT s m ()
SL.put s
s')
    a -> ConduitT i o (StateT s m) a
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 :: (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 b. (res -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m res
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 b. (res -> Pipe i i o () m b) -> Pipe i i o () m b)
 -> ConduitT i o m res)
-> (forall b. (res -> Pipe i i o () m b) -> Pipe i i o () m b)
-> ConduitT i o m res
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) = m (Pipe i i o () m b) -> Pipe i i o () m b
forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (m (Pipe i i o () m b) -> Pipe i i o () m b)
-> m (Pipe i i o () m b) -> Pipe i i o () m b
forall a b. (a -> b) -> a -> b
$ do
                (Pipe i i o () (t m) r
p, s
s') <- t m (Pipe i i o () (t m) r) -> s -> m (Pipe i i o () (t m) r, s)
forall a. t m a -> s -> m (a, s)
runM t m (Pipe i i o () (t m) r)
mp s
s
                Pipe i i o () m b -> m (Pipe i i o () m b)
forall (m :: * -> *) a. Monad m => a -> m a
return (Pipe i i o () m b -> m (Pipe i i o () m b))
-> Pipe i i o () m b -> m (Pipe i i o () m b)
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) = Pipe i i o () m b -> i -> Pipe i i o () m b
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) = (i -> Pipe i i o () m b)
-> (() -> Pipe i i o () m b) -> Pipe i i o () m b
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 (Pipe i i o () (t m) r -> Pipe i i o () m b)
-> (i -> Pipe i i o () (t m) r) -> i -> Pipe i i o () m b
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 (Pipe i i o () (t m) r -> Pipe i i o () m b)
-> (() -> Pipe i i o () (t m) r) -> () -> Pipe i i o () m b
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) = Pipe i i o () m b -> o -> Pipe i i o () m b
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 ((r -> Pipe i i o () (t m) r) -> Pipe i i o () (t m) r
forall b. (r -> Pipe i i o () (t m) b) -> Pipe i i o () (t m) b
c0 r -> Pipe i i o () (t m) r
forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
{-# INLINABLE thread #-}

-- | Run 'SL.StateT' in the base monad
--
-- Since 1.0.11
runStateLC
  :: Monad m =>
     s -> ConduitT i o (SL.StateT s m) r -> ConduitT i o m (r, s)
runStateLC :: s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
runStateLC = (r -> s -> (r, s))
-> (forall a. StateT s m a -> s -> m (a, s))
-> s
-> ConduitT i o (StateT s m) r
-> ConduitT i o m (r, s)
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. StateT s m a -> s -> m (a, s)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
SL.runStateT
{-# INLINABLE runStateLC #-}

-- | Evaluate 'SL.StateT' in the base monad
--
-- Since 1.0.11
evalStateLC
  :: Monad m =>
     s -> ConduitT i o (SL.StateT s m) r -> ConduitT i o m r
evalStateLC :: s -> ConduitT i o (StateT s m) r -> ConduitT i o m r
evalStateLC s
s ConduitT i o (StateT s m) r
p = ((r, s) -> r) -> ConduitT i o m (r, s) -> ConduitT i o m r
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (r, s) -> r
forall a b. (a, b) -> a
fst (ConduitT i o m (r, s) -> ConduitT i o m r)
-> ConduitT i o m (r, s) -> ConduitT i o m r
forall a b. (a -> b) -> a -> b
$ s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
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 #-}

-- | Execute 'SL.StateT' in the base monad
--
-- Since 1.0.11
execStateLC
  :: Monad m =>
     s -> ConduitT i o (SL.StateT s m) r -> ConduitT i o m s
execStateLC :: s -> ConduitT i o (StateT s m) r -> ConduitT i o m s
execStateLC s
s ConduitT i o (StateT s m) r
p = ((r, s) -> s) -> ConduitT i o m (r, s) -> ConduitT i o m s
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (r, s) -> s
forall a b. (a, b) -> b
snd (ConduitT i o m (r, s) -> ConduitT i o m s)
-> ConduitT i o m (r, s) -> ConduitT i o m s
forall a b. (a -> b) -> a -> b
$ s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
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 #-}


-- | Wrap the base monad in 'SS.StateT'
--
-- Since 1.0.11
stateC
  :: Monad m =>
     (s -> ConduitT i o m (a, s)) -> ConduitT i o (SS.StateT s m) a
stateC :: (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 <- StateT s m s -> ConduitT i o (StateT s m) s
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift StateT s m s
forall (m :: * -> *) s. Monad m => StateT s m s
SS.get
    (a
r, s
s') <- (forall a. m a -> StateT s m a)
-> ConduitT i o m (a, s) -> ConduitT i o (StateT s m) (a, 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 a. m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (s -> ConduitT i o m (a, s)
k s
s)
    StateT s m () -> ConduitT i o (StateT s m) ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (s -> StateT s m ()
forall (m :: * -> *) s. Monad m => s -> StateT s m ()
SS.put s
s')
    a -> ConduitT i o (StateT s m) a
forall (m :: * -> *) a. Monad m => a -> m a
return a
r
{-# INLINABLE stateC #-}

-- | Run 'SS.StateT' in the base monad
--
-- Since 1.0.11
runStateC
  :: Monad m =>
     s -> ConduitT i o (SS.StateT s m) r -> ConduitT i o m (r, s)
runStateC :: s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
runStateC = (r -> s -> (r, s))
-> (forall a. StateT s m a -> s -> m (a, s))
-> s
-> ConduitT i o (StateT s m) r
-> ConduitT i o m (r, s)
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. StateT s m a -> s -> m (a, s)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
SS.runStateT
{-# INLINABLE runStateC #-}

-- | Evaluate 'SS.StateT' in the base monad
--
-- Since 1.0.11
evalStateC
  :: Monad m =>
     s -> ConduitT i o (SS.StateT s m) r -> ConduitT i o m r
evalStateC :: s -> ConduitT i o (StateT s m) r -> ConduitT i o m r
evalStateC s
s ConduitT i o (StateT s m) r
p = ((r, s) -> r) -> ConduitT i o m (r, s) -> ConduitT i o m r
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (r, s) -> r
forall a b. (a, b) -> a
fst (ConduitT i o m (r, s) -> ConduitT i o m r)
-> ConduitT i o m (r, s) -> ConduitT i o m r
forall a b. (a -> b) -> a -> b
$ s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
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 #-}

-- | Execute 'SS.StateT' in the base monad
--
-- Since 1.0.11
execStateC
  :: Monad m =>
     s -> ConduitT i o (SS.StateT s m) r -> ConduitT i o m s
execStateC :: s -> ConduitT i o (StateT s m) r -> ConduitT i o m s
execStateC s
s ConduitT i o (StateT s m) r
p = ((r, s) -> s) -> ConduitT i o m (r, s) -> ConduitT i o m s
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (r, s) -> s
forall a b. (a, b) -> b
snd (ConduitT i o m (r, s) -> ConduitT i o m s)
-> ConduitT i o m (r, s) -> ConduitT i o m s
forall a b. (a -> b) -> a -> b
$ s -> ConduitT i o (StateT s m) r -> ConduitT i o m (r, s)
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 #-}


-- | Wrap the base monad in 'WL.WriterT'
--
-- Since 1.0.11
writerLC
  :: (Monad m, Monoid w) =>
     ConduitT i o m (b, w) -> ConduitT i o (WL.WriterT w m) b
writerLC :: 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 a. m a -> WriterT w m a)
-> ConduitT i o m (b, w) -> ConduitT i o (WriterT w m) (b, 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 a. m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ConduitT i o m (b, w)
p
    WriterT w m () -> ConduitT i o (WriterT w m) ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (WriterT w m () -> ConduitT i o (WriterT w m) ())
-> WriterT w m () -> ConduitT i o (WriterT w m) ()
forall a b. (a -> b) -> a -> b
$ w -> WriterT w m ()
forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
WL.tell w
w
    b -> ConduitT i o (WriterT w m) b
forall (m :: * -> *) a. Monad m => a -> m a
return b
r
{-# INLINABLE writerLC #-}

-- | Run 'WL.WriterT' in the base monad
--
-- Since 1.0.11
runWriterLC
  :: (Monad m, Monoid w) =>
     ConduitT i o (WL.WriterT w m) r -> ConduitT i o m (r, w)
runWriterLC :: ConduitT i o (WriterT w m) r -> ConduitT i o m (r, w)
runWriterLC = (r -> w -> (r, w))
-> (forall a. WriterT w m a -> w -> m (a, w))
-> w
-> ConduitT i o (WriterT w m) r
-> ConduitT i o m (r, w)
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. WriterT w m a -> w -> m (a, w)
forall (m :: * -> *) b a.
(Monad m, Monoid b) =>
WriterT b m a -> b -> m (a, b)
run w
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') <- WriterT b m a -> m (a, b)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
WL.runWriterT WriterT b m a
m
        (a, b) -> m (a, b)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, b
w b -> b -> b
forall a. Monoid a => a -> a -> a
`mappend` b
w')
{-# INLINABLE runWriterLC #-}

-- | Execute 'WL.WriterT' in the base monad
--
-- Since 1.0.11
execWriterLC
  :: (Monad m, Monoid w) =>
     ConduitT i o (WL.WriterT w m) r -> ConduitT i o m w
execWriterLC :: ConduitT i o (WriterT w m) r -> ConduitT i o m w
execWriterLC ConduitT i o (WriterT w m) r
p = ((r, w) -> w) -> ConduitT i o m (r, w) -> ConduitT i o m w
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (r, w) -> w
forall a b. (a, b) -> b
snd (ConduitT i o m (r, w) -> ConduitT i o m w)
-> ConduitT i o m (r, w) -> ConduitT i o m w
forall a b. (a -> b) -> a -> b
$ ConduitT i o (WriterT w m) r -> ConduitT i o m (r, w)
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 #-}


-- | Wrap the base monad in 'WS.WriterT'
--
-- Since 1.0.11
writerC
  :: (Monad m, Monoid w) =>
     ConduitT i o m (b, w) -> ConduitT i o (WS.WriterT w m) b
writerC :: 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 a. m a -> WriterT w m a)
-> ConduitT i o m (b, w) -> ConduitT i o (WriterT w m) (b, 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 a. m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ConduitT i o m (b, w)
p
    WriterT w m () -> ConduitT i o (WriterT w m) ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (WriterT w m () -> ConduitT i o (WriterT w m) ())
-> WriterT w m () -> ConduitT i o (WriterT w m) ()
forall a b. (a -> b) -> a -> b
$ w -> WriterT w m ()
forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
WS.tell w
w
    b -> ConduitT i o (WriterT w m) b
forall (m :: * -> *) a. Monad m => a -> m a
return b
r
{-# INLINABLE writerC #-}

-- | Run 'WS.WriterT' in the base monad
--
-- Since 1.0.11
runWriterC
  :: (Monad m, Monoid w) =>
     ConduitT i o (WS.WriterT w m) r -> ConduitT i o m (r, w)
runWriterC :: ConduitT i o (WriterT w m) r -> ConduitT i o m (r, w)
runWriterC = (r -> w -> (r, w))
-> (forall a. WriterT w m a -> w -> m (a, w))
-> w
-> ConduitT i o (WriterT w m) r
-> ConduitT i o m (r, w)
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. WriterT w m a -> w -> m (a, w)
forall (m :: * -> *) b a.
(Monad m, Monoid b) =>
WriterT b m a -> b -> m (a, b)
run w
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') <- WriterT b m a -> m (a, b)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
WS.runWriterT WriterT b m a
m
        (a, b) -> m (a, b)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, b
w b -> b -> b
forall a. Monoid a => a -> a -> a
`mappend` b
w')
{-# INLINABLE runWriterC #-}

-- | Execute 'WS.WriterT' in the base monad
--
-- Since 1.0.11
execWriterC
  :: (Monad m, Monoid w) =>
     ConduitT i o (WS.WriterT w m) r -> ConduitT i o m w
execWriterC :: ConduitT i o (WriterT w m) r -> ConduitT i o m w
execWriterC ConduitT i o (WriterT w m) r
p = ((r, w) -> w) -> ConduitT i o m (r, w) -> ConduitT i o m w
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (r, w) -> w
forall a b. (a, b) -> b
snd (ConduitT i o m (r, w) -> ConduitT i o m w)
-> ConduitT i o m (r, w) -> ConduitT i o m w
forall a b. (a -> b) -> a -> b
$ ConduitT i o (WriterT w m) r -> ConduitT i o m (r, w)
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 #-}


-- | Wrap the base monad in 'RWSL.RWST'
--
-- Since 1.0.11
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 :: (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 <- RWST r w s m r -> ConduitT i o (RWST r w s m) r
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift RWST r w s m r
forall w (m :: * -> *) r s. (Monoid w, Monad m) => RWST r w s m r
RWSL.ask
    s
s <- RWST r w s m s -> ConduitT i o (RWST r w s m) s
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift RWST r w s m s
forall w (m :: * -> *) r s. (Monoid w, Monad m) => RWST r w s m s
RWSL.get
    (a
r, s
s', w
w) <- (forall a. m a -> RWST r w s m a)
-> ConduitT i o m (a, s, w)
-> ConduitT i o (RWST r w s m) (a, s, 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 a. m a -> RWST r w s m a
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)
    RWST r w s m () -> ConduitT i o (RWST r w s m) ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (RWST r w s m () -> ConduitT i o (RWST r w s m) ())
-> RWST r w s m () -> ConduitT i o (RWST r w s m) ()
forall a b. (a -> b) -> a -> b
$ do
        s -> RWST r w s m ()
forall w (m :: * -> *) s r.
(Monoid w, Monad m) =>
s -> RWST r w s m ()
RWSL.put s
s'
        w -> RWST r w s m ()
forall (m :: * -> *) w r s. Monad m => w -> RWST r w s m ()
RWSL.tell w
w
    a -> ConduitT i o (RWST r w s m) a
forall (m :: * -> *) a. Monad m => a -> m a
return a
r
{-# INLINABLE rwsLC #-}

-- | Run 'RWSL.RWST' in the base monad
--
-- Since 1.0.11
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 :: r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
runRWSLC r
r s
s0 = (res -> (s, w) -> (res, s, w))
-> (forall a. RWST r w s m a -> (s, w) -> m (a, (s, w)))
-> (s, w)
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
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 res -> (s, w) -> (res, s, w)
forall a b c. a -> (b, c) -> (a, b, c)
toRes forall a. RWST r w s m a -> (s, w) -> m (a, (s, w))
forall (m :: * -> *) b a a.
(Monad m, Monoid b) =>
RWST r b a m a -> (a, b) -> m (a, (a, b))
run (s
s0, w
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') <- RWST r b a m a -> r -> a -> m (a, a, b)
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
        (a, (a, b)) -> m (a, (a, b))
forall (m :: * -> *) a. Monad m => a -> m a
return (a
res, (a
s', b
w b -> b -> b
forall a. Monoid a => a -> a -> a
`mappend` b
w'))
{-# INLINABLE runRWSLC #-}

-- | Evaluate 'RWSL.RWST' in the base monad
--
-- Since 1.0.11
evalRWSLC
  :: (Monad m, Monoid w) =>
     r
     -> s
     -> ConduitT i o (RWSL.RWST r w s m) res
     -> ConduitT i o m (res, w)
evalRWSLC :: 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 = ((res, s, w) -> (res, w))
-> ConduitT i o m (res, s, w) -> ConduitT i o m (res, w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (res, s, w) -> (res, w)
forall a b b. (a, b, b) -> (a, b)
f (ConduitT i o m (res, s, w) -> ConduitT i o m (res, w))
-> ConduitT i o m (res, s, w) -> ConduitT i o m (res, w)
forall a b. (a -> b) -> a -> b
$ r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
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 #-}

-- | Execute 'RWSL.RWST' in the base monad
--
-- Since 1.0.11
execRWSLC
  :: (Monad m, Monoid w) =>
     r
     -> s
     -> ConduitT i o (RWSL.RWST r w s m) res
     -> ConduitT i o m (s, w)
execRWSLC :: 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 = ((res, s, w) -> (s, w))
-> ConduitT i o m (res, s, w) -> ConduitT i o m (s, w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (res, s, w) -> (s, w)
forall a a b. (a, a, b) -> (a, b)
f (ConduitT i o m (res, s, w) -> ConduitT i o m (s, w))
-> ConduitT i o m (res, s, w) -> ConduitT i o m (s, w)
forall a b. (a -> b) -> a -> b
$ r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
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 #-}

-- | Wrap the base monad in 'RWSS.RWST'
--
-- Since 1.0.11
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 :: (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 <- RWST r w s m r -> ConduitT i o (RWST r w s m) r
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift RWST r w s m r
forall w (m :: * -> *) r s. (Monoid w, Monad m) => RWST r w s m r
RWSS.ask
    s
s <- RWST r w s m s -> ConduitT i o (RWST r w s m) s
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift RWST r w s m s
forall w (m :: * -> *) r s. (Monoid w, Monad m) => RWST r w s m s
RWSS.get
    (a
r, s
s', w
w) <- (forall a. m a -> RWST r w s m a)
-> ConduitT i o m (a, s, w)
-> ConduitT i o (RWST r w s m) (a, s, 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 a. m a -> RWST r w s m a
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)
    RWST r w s m () -> ConduitT i o (RWST r w s m) ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (RWST r w s m () -> ConduitT i o (RWST r w s m) ())
-> RWST r w s m () -> ConduitT i o (RWST r w s m) ()
forall a b. (a -> b) -> a -> b
$ do
        s -> RWST r w s m ()
forall w (m :: * -> *) s r.
(Monoid w, Monad m) =>
s -> RWST r w s m ()
RWSS.put s
s'
        w -> RWST r w s m ()
forall (m :: * -> *) w r s. Monad m => w -> RWST r w s m ()
RWSS.tell w
w
    a -> ConduitT i o (RWST r w s m) a
forall (m :: * -> *) a. Monad m => a -> m a
return a
r
{-# INLINABLE rwsC #-}

-- | Run 'RWSS.RWST' in the base monad
--
-- Since 1.0.11
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 :: r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
runRWSC r
r s
s0 = (res -> (s, w) -> (res, s, w))
-> (forall a. RWST r w s m a -> (s, w) -> m (a, (s, w)))
-> (s, w)
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
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 res -> (s, w) -> (res, s, w)
forall a b c. a -> (b, c) -> (a, b, c)
toRes forall a. RWST r w s m a -> (s, w) -> m (a, (s, w))
forall (m :: * -> *) b a a.
(Monad m, Monoid b) =>
RWST r b a m a -> (a, b) -> m (a, (a, b))
run (s
s0, w
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') <- RWST r b a m a -> r -> a -> m (a, a, b)
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
        (a, (a, b)) -> m (a, (a, b))
forall (m :: * -> *) a. Monad m => a -> m a
return (a
res, (a
s', b
w b -> b -> b
forall a. Monoid a => a -> a -> a
`mappend` b
w'))
{-# INLINABLE runRWSC #-}

-- | Evaluate 'RWSS.RWST' in the base monad
--
-- Since 1.0.11
evalRWSC
  :: (Monad m, Monoid w) =>
     r
     -> s
     -> ConduitT i o (RWSS.RWST r w s m) res
     -> ConduitT i o m (res, w)
evalRWSC :: 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 = ((res, s, w) -> (res, w))
-> ConduitT i o m (res, s, w) -> ConduitT i o m (res, w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (res, s, w) -> (res, w)
forall a b b. (a, b, b) -> (a, b)
f (ConduitT i o m (res, s, w) -> ConduitT i o m (res, w))
-> ConduitT i o m (res, s, w) -> ConduitT i o m (res, w)
forall a b. (a -> b) -> a -> b
$ r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
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 #-}

-- | Execute 'RWSS.RWST' in the base monad
--
-- Since 1.0.11
execRWSC
  :: (Monad m, Monoid w) =>
     r
     -> s
     -> ConduitT i o (RWSS.RWST r w s m) res
     -> ConduitT i o m (s, w)
execRWSC :: 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 = ((res, s, w) -> (s, w))
-> ConduitT i o m (res, s, w) -> ConduitT i o m (s, w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (res, s, w) -> (s, w)
forall a a b. (a, a, b) -> (a, b)
f (ConduitT i o m (res, s, w) -> ConduitT i o m (s, w))
-> ConduitT i o m (res, s, w) -> ConduitT i o m (s, w)
forall a b. (a -> b) -> a -> b
$ r
-> s
-> ConduitT i o (RWST r w s m) res
-> ConduitT i o m (res, s, w)
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 #-}