{-# OPTIONS_HADDOCK not-home #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeFamilies #-}
module Data.Conduit.Internal.Conduit
(
ConduitT (..)
, ConduitM
, Source
, Producer
, Sink
, Consumer
, Conduit
, Flush (..)
, ZipSource (..)
, ZipSink (..)
, ZipConduit (..)
, SealedConduitT (..)
, sealConduitT
, unsealConduitT
, await
, awaitForever
, yield
, yieldM
, leftover
, runConduit
, runConduitPure
, runConduitRes
, fuse
, connect
, unconsM
, unconsEitherM
, connectResume
, connectResumeConduit
, fuseLeftovers
, fuseReturnLeftovers
, ($$+)
, ($$++)
, ($$+-)
, ($=+)
, (=$$+)
, (=$$++)
, (=$$+-)
, ($$)
, ($=)
, (=$)
, (=$=)
, (.|)
, sourceToPipe
, sinkToPipe
, conduitToPipe
, toProducer
, toConsumer
, bracketP
, catchC
, handleC
, tryC
, Data.Conduit.Internal.Conduit.transPipe
, Data.Conduit.Internal.Conduit.mapOutput
, Data.Conduit.Internal.Conduit.mapOutputMaybe
, Data.Conduit.Internal.Conduit.mapInput
, Data.Conduit.Internal.Conduit.mapInputM
, zipSinks
, zipSources
, zipSourcesApp
, zipConduitApp
, mergeSource
, passthroughSink
, sourceToList
, fuseBoth
, fuseBothMaybe
, fuseUpstream
, sequenceSources
, sequenceSinks
, sequenceConduits
) where
import Control.Applicative (Applicative (..))
import Control.Exception (Exception)
import qualified Control.Exception as E (catch)
import Control.Monad (liftM, liftM2, ap)
import Control.Monad.Fail(MonadFail(..))
import Control.Monad.Error.Class(MonadError(..))
import Control.Monad.Reader.Class(MonadReader(..))
import Control.Monad.RWS.Class(MonadRWS())
import Control.Monad.Writer.Class(MonadWriter(..), censor)
import Control.Monad.State.Class(MonadState(..))
import Control.Monad.Trans.Class (MonadTrans (lift))
import Control.Monad.IO.Unlift (MonadIO (liftIO), MonadUnliftIO, withRunInIO)
import Control.Monad.Primitive (PrimMonad, PrimState, primitive)
import Data.Functor.Identity (Identity, runIdentity)
import Data.Void (Void, absurd)
import Data.Monoid (Monoid (mappend, mempty))
import Data.Semigroup (Semigroup ((<>)))
import Control.Monad.Trans.Resource
import Data.Conduit.Internal.Pipe hiding (yield, mapOutput, leftover, yieldM, await, awaitForever, bracketP, unconsM, unconsEitherM)
import qualified Data.Conduit.Internal.Pipe as CI
import Control.Monad (forever)
import Data.Traversable (Traversable (..))
newtype ConduitT i o m r = ConduitT
{ 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 :: forall b.
(r -> Pipe i i o () m b) -> Pipe i i o () m b
}
newtype SealedConduitT i o m r = SealedConduitT (Pipe i i o () m r)
type ConduitM = ConduitT
instance Functor (ConduitT i o m) where
fmap :: forall a b. (a -> b) -> ConduitT i o m a -> ConduitT i o m b
fmap a -> b
f (ConduitT forall b. (a -> Pipe i i o () m b) -> Pipe i i o () m b
c) = 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
$ \b -> Pipe i i o () m b
rest -> forall b. (a -> Pipe i i o () m b) -> Pipe i i o () m b
c (b -> Pipe i i o () m b
rest forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
f)
instance Applicative (ConduitT i o m) where
pure :: forall a. a -> ConduitT i o m a
pure a
x = 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
$ a
x)
{-# INLINE pure #-}
<*> :: forall a b.
ConduitT i o m (a -> b) -> ConduitT i o m a -> ConduitT i o m b
(<*>) = forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap
{-# INLINE (<*>) #-}
*> :: forall a b.
ConduitT i o m a -> ConduitT i o m b -> ConduitT i o m b
(*>) = forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
(>>)
{-# INLINE (*>) #-}
instance Monad (ConduitT i o m) where
return :: forall a. a -> ConduitT i o m a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
ConduitT forall b. (a -> Pipe i i o () m b) -> Pipe i i o () m b
f >>= :: forall a b.
ConduitT i o m a -> (a -> ConduitT i o m b) -> ConduitT i o m b
>>= a -> ConduitT i o m b
g = 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
$ \b -> Pipe i i o () m b
h -> forall b. (a -> Pipe i i o () m b) -> Pipe i i o () m b
f forall a b. (a -> b) -> a -> b
$ \a
a -> 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 (a -> ConduitT i o m b
g a
a) b -> Pipe i i o () m b
h
instance MonadFail m => MonadFail (ConduitT i o m) where
fail :: forall a. String -> ConduitT i o m a
fail = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail
instance MonadThrow m => MonadThrow (ConduitT i o m) where
throwM :: forall e a. Exception e => e -> ConduitT i o m a
throwM = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM
instance MonadIO m => MonadIO (ConduitT i o m) where
liftIO :: forall a. IO a -> ConduitT i o m a
liftIO = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
{-# INLINE liftIO #-}
instance MonadReader r m => MonadReader r (ConduitT i o m) where
ask :: ConduitT i o m r
ask = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall r (m :: * -> *). MonadReader r m => m r
ask
{-# INLINE ask #-}
local :: forall a. (r -> r) -> ConduitT i o m a -> ConduitT i o m a
local r -> r
f (ConduitT forall b. (a -> Pipe i i o () m b) -> Pipe i i o () 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
$ \a -> Pipe i i o () m b
rest ->
let go :: Pipe i i o () m a -> Pipe i i o () m b
go (HaveOutput Pipe i i o () m a
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 () m a -> Pipe i i o () m b
go Pipe i i o () m a
p) o
o
go (NeedInput i -> Pipe i i o () m a
p () -> Pipe i i o () m a
c) = 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 (\i
i -> Pipe i i o () m a -> Pipe i i o () m b
go (i -> Pipe i i o () m a
p i
i)) (\()
u -> Pipe i i o () m a -> Pipe i i o () m b
go (() -> Pipe i i o () m a
c ()
u))
go (Done a
x) = a -> Pipe i i o () m b
rest a
x
go (PipeM m (Pipe i i o () m a)
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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe i i o () m a -> Pipe i i o () m b
go forall a b. (a -> b) -> a -> b
$ forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local r -> r
f m (Pipe i i o () m a)
mp)
go (Leftover Pipe i i o () m a
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 () m a -> Pipe i i o () m b
go Pipe i i o () m a
p) i
i
in Pipe i i o () m a -> Pipe i i o () m b
go (forall b. (a -> Pipe i i o () m b) -> Pipe i i o () m b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
#ifndef MIN_VERSION_mtl
#define MIN_VERSION_mtl(x, y, z) 0
#endif
instance MonadWriter w m => MonadWriter w (ConduitT i o m) where
#if MIN_VERSION_mtl(2, 1, 0)
writer :: forall a. (a, w) -> ConduitT i o m a
writer = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall w (m :: * -> *) a. MonadWriter w m => (a, w) -> m a
writer
#endif
tell :: w -> ConduitT i o m ()
tell = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell
listen :: forall a. ConduitT i o m a -> ConduitT i o m (a, w)
listen (ConduitT forall b. (a -> Pipe i i o () m b) -> Pipe i i o () 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
$ \(a, w) -> Pipe i i o () m b
rest ->
let go :: w -> Pipe i i o () m a -> Pipe i i o () m b
go w
front (HaveOutput Pipe i i o () m a
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 (w -> Pipe i i o () m a -> Pipe i i o () m b
go w
front Pipe i i o () m a
p) o
o
go w
front (NeedInput i -> Pipe i i o () m a
p () -> Pipe i i o () m a
c) = 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 (\i
i -> w -> Pipe i i o () m a -> Pipe i i o () m b
go w
front (i -> Pipe i i o () m a
p i
i)) (\()
u -> w -> Pipe i i o () m a -> Pipe i i o () m b
go w
front (() -> Pipe i i o () m a
c ()
u))
go w
front (Done a
x) = (a, w) -> Pipe i i o () m b
rest (a
x, w
front)
go w
front (PipeM m (Pipe i i o () m a)
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 () m a
p,w
w) <- forall w (m :: * -> *) a. MonadWriter w m => m a -> m (a, w)
listen m (Pipe i i o () m a)
mp
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ w -> Pipe i i o () m a -> Pipe i i o () m b
go (w
front forall a. Monoid a => a -> a -> a
`mappend` w
w) Pipe i i o () m a
p
go w
front (Leftover Pipe i i o () m a
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 (w -> Pipe i i o () m a -> Pipe i i o () m b
go w
front Pipe i i o () m a
p) i
i
in w -> Pipe i i o () m a -> Pipe i i o () m b
go forall a. Monoid a => a
mempty (forall b. (a -> Pipe i i o () m b) -> Pipe i i o () m b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
pass :: forall a. ConduitT i o m (a, w -> w) -> ConduitT i o m a
pass (ConduitT forall b. ((a, w -> w) -> Pipe i i o () m b) -> Pipe i i o () 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
$ \a -> Pipe i i o () m b
rest ->
let go :: w -> Pipe i i o () m (a, w -> w) -> Pipe i i o () m b
go w
front (HaveOutput Pipe i i o () m (a, w -> w)
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 (w -> Pipe i i o () m (a, w -> w) -> Pipe i i o () m b
go w
front Pipe i i o () m (a, w -> w)
p) o
o
go w
front (NeedInput i -> Pipe i i o () m (a, w -> w)
p () -> Pipe i i o () m (a, w -> w)
c) = 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 (\i
i -> w -> Pipe i i o () m (a, w -> w) -> Pipe i i o () m b
go w
front (i -> Pipe i i o () m (a, w -> w)
p i
i)) (\()
u -> w -> Pipe i i o () m (a, w -> w) -> Pipe i i o () m b
go w
front (() -> Pipe i i o () m (a, w -> w)
c ()
u))
go w
front (PipeM m (Pipe i i o () m (a, w -> w))
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 () m (a, w -> w)
p,w
w) <- forall w (m :: * -> *) a. MonadWriter w m => (w -> w) -> m a -> m a
censor (forall a b. a -> b -> a
const forall a. Monoid a => a
mempty) (forall w (m :: * -> *) a. MonadWriter w m => m a -> m (a, w)
listen m (Pipe i i o () m (a, w -> w))
mp)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ w -> Pipe i i o () m (a, w -> w) -> Pipe i i o () m b
go (w
front forall a. Monoid a => a -> a -> a
`mappend` w
w) Pipe i i o () m (a, w -> w)
p
go w
front (Done (a
x,w -> w
f)) = 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
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (w -> w
f w
front)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ a -> Pipe i i o () m b
rest a
x
go w
front (Leftover Pipe i i o () m (a, w -> w)
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 (w -> Pipe i i o () m (a, w -> w) -> Pipe i i o () m b
go w
front Pipe i i o () m (a, w -> w)
p) i
i
in w -> Pipe i i o () m (a, w -> w) -> Pipe i i o () m b
go forall a. Monoid a => a
mempty (forall b. ((a, w -> w) -> Pipe i i o () m b) -> Pipe i i o () m b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
instance MonadState s m => MonadState s (ConduitT i o m) where
get :: ConduitT i o m s
get = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall s (m :: * -> *). MonadState s m => m s
get
put :: s -> ConduitT i o m ()
put = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *). MonadState s m => s -> m ()
put
#if MIN_VERSION_mtl(2, 1, 0)
state :: forall a. (s -> (a, s)) -> ConduitT i o m a
state = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
state
#endif
instance MonadRWS r w s m => MonadRWS r w s (ConduitT i o m)
instance MonadError e m => MonadError e (ConduitT i o m) where
throwError :: forall a. e -> ConduitT i o m a
throwError = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError
catchError :: forall a.
ConduitT i o m a -> (e -> ConduitT i o m a) -> ConduitT i o m a
catchError (ConduitT forall b. (a -> Pipe i i o () m b) -> Pipe i i o () m b
c0) e -> ConduitT i o m a
f = 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
$ \a -> Pipe i i o () m b
rest ->
let go :: Pipe i i o () m a -> Pipe i i o () m b
go (HaveOutput Pipe i i o () m a
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 () m a -> Pipe i i o () m b
go Pipe i i o () m a
p) o
o
go (NeedInput i -> Pipe i i o () m a
p () -> Pipe i i o () m a
c) = 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 (\i
i -> Pipe i i o () m a -> Pipe i i o () m b
go (i -> Pipe i i o () m a
p i
i)) (\()
u -> Pipe i i o () m a -> Pipe i i o () m b
go (() -> Pipe i i o () m a
c ()
u))
go (Done a
x) = a -> Pipe i i o () m b
rest a
x
go (PipeM m (Pipe i i o () m a)
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
$ forall e (m :: * -> *) a.
MonadError e m =>
m a -> (e -> m a) -> m a
catchError (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe i i o () m a -> Pipe i i o () m b
go m (Pipe i i o () m a)
mp) forall a b. (a -> b) -> a -> b
$ \e
e -> do
forall (m :: * -> *) a. Monad m => a -> m a
return 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 (e -> ConduitT i o m a
f e
e) a -> Pipe i i o () m b
rest
go (Leftover Pipe i i o () m a
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 () m a -> Pipe i i o () m b
go Pipe i i o () m a
p) i
i
in Pipe i i o () m a -> Pipe i i o () m b
go (forall b. (a -> Pipe i i o () m b) -> Pipe i i o () m b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
instance MonadTrans (ConduitT i o) where
lift :: forall (m :: * -> *) a. Monad m => m a -> ConduitT i o m a
lift m a
mr = 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
$ \a -> Pipe i i o () m b
rest -> forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM a -> Pipe i i o () m b
rest m a
mr)
{-# INLINE [1] lift #-}
instance MonadResource m => MonadResource (ConduitT i o m) where
liftResourceT :: forall a. ResourceT IO a -> ConduitT i o m a
liftResourceT = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. MonadResource m => ResourceT IO a -> m a
liftResourceT
{-# INLINE liftResourceT #-}
instance Monad m => Semigroup (ConduitT i o m ()) where
<> :: ConduitT i o m () -> ConduitT i o m () -> ConduitT i o m ()
(<>) = forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
(>>)
{-# INLINE (<>) #-}
instance Monad m => Monoid (ConduitT i o m ()) where
mempty :: ConduitT i o m ()
mempty = forall (m :: * -> *) a. Monad m => a -> m a
return ()
{-# INLINE mempty #-}
#if !(MIN_VERSION_base(4,11,0))
mappend = (<>)
{-# INLINE mappend #-}
#endif
instance PrimMonad m => PrimMonad (ConduitT i o m) where
type PrimState (ConduitT i o m) = PrimState m
primitive :: forall a.
(State# (PrimState (ConduitT i o m))
-> (# State# (PrimState (ConduitT i o m)), a #))
-> ConduitT i o m a
primitive = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a.
PrimMonad m =>
(State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
primitive
type Source m o = ConduitT () o m ()
{-# DEPRECATED Source "Use ConduitT directly" #-}
type Producer m o = forall i. ConduitT i o m ()
{-# DEPRECATED Producer "Use ConduitT directly" #-}
type Sink i = ConduitT i Void
{-# DEPRECATED Sink "Use ConduitT directly" #-}
type Consumer i m r = forall o. ConduitT i o m r
{-# DEPRECATED Consumer "Use ConduitT directly" #-}
type Conduit i m o = ConduitT i o m ()
{-# DEPRECATED Conduit "Use ConduitT directly" #-}
sealConduitT :: ConduitT i o m r -> SealedConduitT i o m r
sealConduitT :: forall i o (m :: * -> *) r.
ConduitT i o m r -> SealedConduitT i o m r
sealConduitT (ConduitT forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b
f) = forall i o (m :: * -> *) r.
Pipe i i o () m r -> SealedConduitT i o m r
SealedConduitT (forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b
f forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
unsealConduitT :: Monad m => SealedConduitT i o m r -> ConduitT i o m r
unsealConduitT :: forall (m :: * -> *) i o r.
Monad m =>
SealedConduitT i o m r -> ConduitT i o m r
unsealConduitT (SealedConduitT Pipe i i o () m r
f) = 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 (Pipe i i o () m r
f forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=)
connectResume :: Monad m
=> SealedConduitT () a m ()
-> ConduitT a Void m r
-> m (SealedConduitT () a m (), r)
connectResume :: forall (m :: * -> *) a r.
Monad m =>
SealedConduitT () a m ()
-> ConduitT a Void m r -> m (SealedConduitT () a m (), r)
connectResume (SealedConduitT Pipe () () a () m ()
left0) (ConduitT forall b. (r -> Pipe a a Void () m b) -> Pipe a a Void () m b
right0) =
forall {m :: * -> *} {i} {b}.
Monad m =>
Pipe () () i () m ()
-> Pipe i i Void () m b -> m (SealedConduitT () i m (), b)
goRight Pipe () () a () m ()
left0 (forall b. (r -> Pipe a a Void () m b) -> Pipe a a Void () m b
right0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
where
goRight :: Pipe () () i () m ()
-> Pipe i i Void () m b -> m (SealedConduitT () i m (), b)
goRight Pipe () () i () m ()
left Pipe i i Void () m b
right =
case Pipe i i Void () m b
right of
HaveOutput Pipe i i Void () m b
_ Void
o -> forall a. Void -> a
absurd Void
o
NeedInput i -> Pipe i i Void () m b
rp () -> Pipe i i Void () m b
rc -> (i -> Pipe i i Void () m b)
-> (() -> Pipe i i Void () m b)
-> Pipe () () i () m ()
-> m (SealedConduitT () i m (), b)
goLeft i -> Pipe i i Void () m b
rp () -> Pipe i i Void () m b
rc Pipe () () i () m ()
left
Done b
r2 -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall i o (m :: * -> *) r.
Pipe i i o () m r -> SealedConduitT i o m r
SealedConduitT Pipe () () i () m ()
left, b
r2)
PipeM m (Pipe i i Void () m b)
mp -> m (Pipe i i Void () m b)
mp forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Pipe () () i () m ()
-> Pipe i i Void () m b -> m (SealedConduitT () i m (), b)
goRight Pipe () () i () m ()
left
Leftover Pipe i i Void () m b
p i
i -> Pipe () () i () m ()
-> Pipe i i Void () m b -> m (SealedConduitT () i m (), b)
goRight (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 () m ()
left i
i) Pipe i i Void () m b
p
goLeft :: (i -> Pipe i i Void () m b)
-> (() -> Pipe i i Void () m b)
-> Pipe () () i () m ()
-> m (SealedConduitT () i m (), b)
goLeft i -> Pipe i i Void () m b
rp () -> Pipe i i Void () m b
rc Pipe () () i () m ()
left =
case Pipe () () i () m ()
left of
HaveOutput Pipe () () i () m ()
left' i
o -> Pipe () () i () m ()
-> Pipe i i Void () m b -> m (SealedConduitT () i m (), b)
goRight Pipe () () i () m ()
left' (i -> Pipe i i Void () m b
rp i
o)
NeedInput () -> Pipe () () i () m ()
_ () -> Pipe () () i () m ()
lc -> Pipe () () i () m () -> m (SealedConduitT () i m (), b)
recurse (() -> Pipe () () i () m ()
lc ())
Done () -> Pipe () () i () m ()
-> Pipe i i Void () m b -> m (SealedConduitT () i m (), b)
goRight (forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done ()) (() -> Pipe i i Void () m b
rc ())
PipeM m (Pipe () () i () m ())
mp -> m (Pipe () () i () m ())
mp forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Pipe () () i () m () -> m (SealedConduitT () i m (), b)
recurse
Leftover Pipe () () i () m ()
p () -> Pipe () () i () m () -> m (SealedConduitT () i m (), b)
recurse Pipe () () i () m ()
p
where
recurse :: Pipe () () i () m () -> m (SealedConduitT () i m (), b)
recurse = (i -> Pipe i i Void () m b)
-> (() -> Pipe i i Void () m b)
-> Pipe () () i () m ()
-> m (SealedConduitT () i m (), b)
goLeft i -> Pipe i i Void () m b
rp () -> Pipe i i Void () m b
rc
sourceToPipe :: Monad m => ConduitT () o m () -> Pipe l i o u m ()
sourceToPipe :: forall (m :: * -> *) o l i u.
Monad m =>
ConduitT () o m () -> Pipe l i o u m ()
sourceToPipe (ConduitT forall b. (() -> Pipe () () o () m b) -> Pipe () () o () m b
k) =
forall {m :: * -> *} {i} {o} {l} {i} {u}.
Monad m =>
Pipe () i o () m () -> Pipe l i o u m ()
go forall a b. (a -> b) -> a -> b
$ forall b. (() -> Pipe () () o () m b) -> Pipe () () o () m b
k forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done
where
go :: Pipe () i o () m () -> Pipe l i o u m ()
go (HaveOutput Pipe () i o () m ()
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 o () m () -> Pipe l i o u m ()
go Pipe () i o () m ()
p) o
o
go (NeedInput i -> Pipe () i o () m ()
_ () -> Pipe () i o () m ()
c) = Pipe () i o () m () -> Pipe l i o u m ()
go forall a b. (a -> b) -> a -> b
$ () -> Pipe () i o () m ()
c ()
go (Done ()) = forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done ()
go (PipeM m (Pipe () i o () m ())
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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe () i o () m () -> Pipe l i o u m ()
go m (Pipe () i o () m ())
mp)
go (Leftover Pipe () i o () m ()
p ()) = Pipe () i o () m () -> Pipe l i o u m ()
go Pipe () i o () m ()
p
sinkToPipe :: Monad m => ConduitT i Void m r -> Pipe l i o u m r
sinkToPipe :: forall (m :: * -> *) i r l o u.
Monad m =>
ConduitT i Void m r -> Pipe l i o u m r
sinkToPipe (ConduitT forall b. (r -> Pipe i i Void () m b) -> Pipe i i Void () m b
k) =
forall {m :: * -> *} {i} {r} {l} {o} {u}.
Monad m =>
Pipe Void i Void () m r -> Pipe l i o u m r
go forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) i o u r l.
Monad m =>
Pipe i i o u m r -> Pipe l i o u m r
injectLeftovers forall a b. (a -> b) -> a -> b
$ forall b. (r -> Pipe i i Void () m b) -> Pipe i i Void () m b
k forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done
where
go :: Pipe Void i Void () m r -> Pipe l i o u m r
go (HaveOutput Pipe Void i Void () m r
_ Void
o) = forall a. Void -> a
absurd Void
o
go (NeedInput i -> Pipe Void i Void () m r
p () -> Pipe Void i Void () m r
c) = 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 Void i Void () m r -> Pipe l i o u m r
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe Void i Void () m r
p) (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ Pipe Void i Void () m r -> Pipe l i o u m r
go forall a b. (a -> b) -> a -> b
$ () -> Pipe Void i Void () m r
c ())
go (Done r
r) = forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done r
r
go (PipeM m (Pipe Void i Void () 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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe Void i Void () m r -> Pipe l i o u m r
go m (Pipe Void i Void () m r)
mp)
go (Leftover Pipe Void i Void () m r
_ Void
l) = forall a. Void -> a
absurd Void
l
conduitToPipe :: Monad m => ConduitT i o m () -> Pipe l i o u m ()
conduitToPipe :: forall (m :: * -> *) i o l u.
Monad m =>
ConduitT i o m () -> Pipe l i o u m ()
conduitToPipe (ConduitT forall b. (() -> Pipe i i o () m b) -> Pipe i i o () m b
k) =
forall {m :: * -> *} {i} {o} {l} {u}.
Monad m =>
Pipe Void i o () m () -> Pipe l i o u m ()
go forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) i o u r l.
Monad m =>
Pipe i i o u m r -> Pipe l i o u m r
injectLeftovers forall a b. (a -> b) -> a -> b
$ forall b. (() -> Pipe i i o () m b) -> Pipe i i o () m b
k forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done
where
go :: Pipe Void i o () m () -> Pipe l i o u m ()
go (HaveOutput Pipe Void i o () m ()
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 Void i o () m () -> Pipe l i o u m ()
go Pipe Void i o () m ()
p) o
o
go (NeedInput i -> Pipe Void i o () m ()
p () -> Pipe Void i o () m ()
c) = 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 Void i o () m () -> Pipe l i o u m ()
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe Void i o () m ()
p) (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ Pipe Void i o () m () -> Pipe l i o u m ()
go forall a b. (a -> b) -> a -> b
$ () -> Pipe Void i o () m ()
c ())
go (Done ()) = forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done ()
go (PipeM m (Pipe Void i o () m ())
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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe Void i o () m () -> Pipe l i o u m ()
go m (Pipe Void i o () m ())
mp)
go (Leftover Pipe Void i o () m ()
_ Void
l) = forall a. Void -> a
absurd Void
l
toProducer :: Monad m => ConduitT () a m () -> ConduitT i a m ()
toProducer :: forall (m :: * -> *) a i.
Monad m =>
ConduitT () a m () -> ConduitT i a m ()
toProducer (ConduitT forall b. (() -> Pipe () () a () m b) -> Pipe () () a () 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
$ \() -> Pipe i i a () m b
rest -> let
go :: Pipe () () a () m () -> Pipe i i a () m b
go (HaveOutput Pipe () () a () m ()
p a
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 () () a () m () -> Pipe i i a () m b
go Pipe () () a () m ()
p) a
o
go (NeedInput () -> Pipe () () a () m ()
_ () -> Pipe () () a () m ()
c) = Pipe () () a () m () -> Pipe i i a () m b
go (() -> Pipe () () a () m ()
c ())
go (Done ()
r) = () -> Pipe i i a () m b
rest ()
r
go (PipeM m (Pipe () () a () m ())
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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe () () a () m () -> Pipe i i a () m b
go m (Pipe () () a () m ())
mp)
go (Leftover Pipe () () a () m ()
p ()) = Pipe () () a () m () -> Pipe i i a () m b
go Pipe () () a () m ()
p
in Pipe () () a () m () -> Pipe i i a () m b
go (forall b. (() -> Pipe () () a () m b) -> Pipe () () a () m b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
toConsumer :: Monad m => ConduitT a Void m b -> ConduitT a o m b
toConsumer :: forall (m :: * -> *) a b o.
Monad m =>
ConduitT a Void m b -> ConduitT a o m b
toConsumer (ConduitT forall b. (b -> Pipe a a Void () m b) -> Pipe a a Void () 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
$ \b -> Pipe a a o () m b
rest -> let
go :: Pipe a a Void () m b -> Pipe a a o () m b
go (HaveOutput Pipe a a Void () m b
_ Void
o) = forall a. Void -> a
absurd Void
o
go (NeedInput a -> Pipe a a Void () m b
p () -> Pipe a a Void () m b
c) = 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 a a Void () m b -> Pipe a a o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Pipe a a Void () m b
p) (Pipe a a Void () m b -> Pipe a a o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe a a Void () m b
c)
go (Done b
r) = b -> Pipe a a o () m b
rest b
r
go (PipeM m (Pipe a a Void () m b)
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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe a a Void () m b -> Pipe a a o () m b
go m (Pipe a a Void () m b)
mp)
go (Leftover Pipe a a Void () m b
p a
l) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> l -> Pipe l i o u m r
Leftover (Pipe a a Void () m b -> Pipe a a o () m b
go Pipe a a Void () m b
p) a
l
in Pipe a a Void () m b -> Pipe a a o () m b
go (forall b. (b -> Pipe a a Void () m b) -> Pipe a a Void () m b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
catchC :: (MonadUnliftIO m, Exception e)
=> ConduitT i o m r
-> (e -> ConduitT i o m r)
-> ConduitT i o m r
catchC :: forall (m :: * -> *) e i o r.
(MonadUnliftIO m, Exception e) =>
ConduitT i o m r -> (e -> ConduitT i o m r) -> ConduitT i o m r
catchC (ConduitT forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b
p0) e -> ConduitT i o m r
onErr = 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 () m b
rest -> let
go :: Pipe i i o () m r -> Pipe i i o () m b
go (Done r
r) = r -> Pipe i i o () m b
rest r
r
go (PipeM m (Pipe i i o () 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
$ forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO forall a b. (a -> b) -> a -> b
$ \ forall a. m a -> IO a
run ->
forall a. m a -> IO a
run (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe i i o () m r -> Pipe i i o () m b
go m (Pipe i i o () m r)
mp) forall e a. Exception e => IO a -> (e -> IO a) -> IO a
`E.catch` \ e
e ->
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ e -> ConduitT i o m r
onErr 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` r -> Pipe i i o () m b
rest
go (Leftover Pipe i i o () 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 () m r -> Pipe i i o () m b
go Pipe i i o () m r
p) i
i
go (NeedInput i -> Pipe i i o () m r
x () -> Pipe i i o () 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 () m r -> Pipe i i o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe i i o () m r
x) (Pipe i i o () m r -> Pipe i i o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i i o () m r
y)
go (HaveOutput Pipe i i o () 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 () m r -> Pipe i i o () m b
go Pipe i i o () m r
p) o
o
in Pipe i i o () m r -> Pipe i i o () m b
go (forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b
p0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
{-# INLINE catchC #-}
handleC :: (MonadUnliftIO m, Exception e)
=> (e -> ConduitT i o m r)
-> ConduitT i o m r
-> ConduitT i o m r
handleC :: forall (m :: * -> *) e i o r.
(MonadUnliftIO m, Exception e) =>
(e -> ConduitT i o m r) -> ConduitT i o m r -> ConduitT i o m r
handleC = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall (m :: * -> *) e i o r.
(MonadUnliftIO m, Exception e) =>
ConduitT i o m r -> (e -> ConduitT i o m r) -> ConduitT i o m r
catchC
{-# INLINE handleC #-}
tryC :: (MonadUnliftIO m, Exception e)
=> ConduitT i o m r
-> ConduitT i o m (Either e r)
tryC :: forall (m :: * -> *) e i o r.
(MonadUnliftIO m, Exception e) =>
ConduitT i o m r -> ConduitT i o m (Either e r)
tryC ConduitT i o m r
c = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. b -> Either a b
Right ConduitT i o m r
c forall (m :: * -> *) e i o r.
(MonadUnliftIO m, Exception e) =>
ConduitT i o m r -> (e -> ConduitT i o m r) -> ConduitT i o m r
`catchC` (forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Left)
{-# INLINE tryC #-}
zipSinks :: Monad m => ConduitT i Void m r -> ConduitT i Void m r' -> ConduitT i Void m (r, r')
zipSinks :: forall (m :: * -> *) i r r'.
Monad m =>
ConduitT i Void m r
-> ConduitT i Void m r' -> ConduitT i Void m (r, r')
zipSinks (ConduitT forall b. (r -> Pipe i i Void () m b) -> Pipe i i Void () m b
x0) (ConduitT forall b. (r' -> Pipe i i Void () m b) -> Pipe i i Void () m b
y0) = 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, r') -> Pipe i i Void () m b
rest -> let
Leftover Pipe Void i Void () m r
_ Void
i >< :: Pipe Void i Void () m r
-> Pipe Void i Void () m r' -> Pipe i i Void () m b
>< Pipe Void i Void () m r'
_ = forall a. Void -> a
absurd Void
i
Pipe Void i Void () m r
_ >< Leftover Pipe Void i Void () m r'
_ Void
i = forall a. Void -> a
absurd Void
i
HaveOutput Pipe Void i Void () m r
_ Void
o >< Pipe Void i Void () m r'
_ = forall a. Void -> a
absurd Void
o
Pipe Void i Void () m r
_ >< HaveOutput Pipe Void i Void () m r'
_ Void
o = forall a. Void -> a
absurd Void
o
PipeM m (Pipe Void i Void () m r)
mx >< Pipe Void i Void () m r'
y = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Pipe Void i Void () m r
-> Pipe Void i Void () m r' -> Pipe i i Void () m b
>< Pipe Void i Void () m r'
y) m (Pipe Void i Void () m r)
mx)
Pipe Void i Void () m r
x >< PipeM m (Pipe Void i Void () m r')
my = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Pipe Void i Void () m r
x Pipe Void i Void () m r
-> Pipe Void i Void () m r' -> Pipe i i Void () m b
><) m (Pipe Void i Void () m r')
my)
Done r
x >< Done r'
y = (r, r') -> Pipe i i Void () m b
rest (r
x, r'
y)
NeedInput i -> Pipe Void i Void () m r
px () -> Pipe Void i Void () m r
cx >< NeedInput i -> Pipe Void i Void () m r'
py () -> Pipe Void i Void () m r'
cy = 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 (\i
i -> i -> Pipe Void i Void () m r
px i
i Pipe Void i Void () m r
-> Pipe Void i Void () m r' -> Pipe i i Void () m b
>< i -> Pipe Void i Void () m r'
py i
i) (\() -> () -> Pipe Void i Void () m r
cx () Pipe Void i Void () m r
-> Pipe Void i Void () m r' -> Pipe i i Void () m b
>< () -> Pipe Void i Void () m r'
cy ())
NeedInput i -> Pipe Void i Void () m r
px () -> Pipe Void i Void () m r
cx >< y :: Pipe Void i Void () m r'
y@Done{} = 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 (\i
i -> i -> Pipe Void i Void () m r
px i
i Pipe Void i Void () m r
-> Pipe Void i Void () m r' -> Pipe i i Void () m b
>< Pipe Void i Void () m r'
y) (\()
u -> () -> Pipe Void i Void () m r
cx ()
u Pipe Void i Void () m r
-> Pipe Void i Void () m r' -> Pipe i i Void () m b
>< Pipe Void i Void () m r'
y)
x :: Pipe Void i Void () m r
x@Done{} >< NeedInput i -> Pipe Void i Void () m r'
py () -> Pipe Void i Void () m r'
cy = 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 (\i
i -> Pipe Void i Void () m r
x Pipe Void i Void () m r
-> Pipe Void i Void () m r' -> Pipe i i Void () m b
>< i -> Pipe Void i Void () m r'
py i
i) (\()
u -> Pipe Void i Void () m r
x Pipe Void i Void () m r
-> Pipe Void i Void () m r' -> Pipe i i Void () m b
>< () -> Pipe Void i Void () m r'
cy ()
u)
in forall (m :: * -> *) i o u r l.
Monad m =>
Pipe i i o u m r -> Pipe l i o u m r
injectLeftovers (forall b. (r -> Pipe i i Void () m b) -> Pipe i i Void () m b
x0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done) Pipe Void i Void () m r
-> Pipe Void i Void () m r' -> Pipe i i Void () m b
>< forall (m :: * -> *) i o u r l.
Monad m =>
Pipe i i o u m r -> Pipe l i o u m r
injectLeftovers (forall b. (r' -> Pipe i i Void () m b) -> Pipe i i Void () m b
y0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
zipSources :: Monad m => ConduitT () a m () -> ConduitT () b m () -> ConduitT () (a, b) m ()
zipSources :: forall (m :: * -> *) a b.
Monad m =>
ConduitT () a m () -> ConduitT () b m () -> ConduitT () (a, b) m ()
zipSources (ConduitT forall b. (() -> Pipe () () a () m b) -> Pipe () () a () m b
left0) (ConduitT forall b. (() -> Pipe () () b () m b) -> Pipe () () b () m b
right0) = 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
$ \() -> Pipe () () (a, b) () m b
rest -> let
go :: Pipe () () a () m ()
-> Pipe () () b () m () -> Pipe () () (a, b) () m b
go (Leftover Pipe () () a () m ()
left ()) Pipe () () b () m ()
right = Pipe () () a () m ()
-> Pipe () () b () m () -> Pipe () () (a, b) () m b
go Pipe () () a () m ()
left Pipe () () b () m ()
right
go Pipe () () a () m ()
left (Leftover Pipe () () b () m ()
right ()) = Pipe () () a () m ()
-> Pipe () () b () m () -> Pipe () () (a, b) () m b
go Pipe () () a () m ()
left Pipe () () b () m ()
right
go (Done ()) (Done ()) = () -> Pipe () () (a, b) () m b
rest ()
go (Done ()) (HaveOutput Pipe () () b () m ()
_ b
_) = () -> Pipe () () (a, b) () m b
rest ()
go (HaveOutput Pipe () () a () m ()
_ a
_) (Done ()) = () -> Pipe () () (a, b) () m b
rest ()
go (Done ()) (PipeM m (Pipe () () b () m ())
_) = () -> Pipe () () (a, b) () m b
rest ()
go (PipeM m (Pipe () () a () m ())
_) (Done ()) = () -> Pipe () () (a, b) () m b
rest ()
go (PipeM m (Pipe () () a () m ())
mx) (PipeM m (Pipe () () b () m ())
my) = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Pipe () () a () m ()
-> Pipe () () b () m () -> Pipe () () (a, b) () m b
go m (Pipe () () a () m ())
mx m (Pipe () () b () m ())
my)
go (PipeM m (Pipe () () a () m ())
mx) y :: Pipe () () b () m ()
y@HaveOutput{} = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\Pipe () () a () m ()
x -> Pipe () () a () m ()
-> Pipe () () b () m () -> Pipe () () (a, b) () m b
go Pipe () () a () m ()
x Pipe () () b () m ()
y) m (Pipe () () a () m ())
mx)
go x :: Pipe () () a () m ()
x@HaveOutput{} (PipeM m (Pipe () () b () m ())
my) = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Pipe () () a () m ()
-> Pipe () () b () m () -> Pipe () () (a, b) () m b
go Pipe () () a () m ()
x) m (Pipe () () b () m ())
my)
go (HaveOutput Pipe () () a () m ()
srcx a
x) (HaveOutput Pipe () () b () m ()
srcy b
y) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> o -> Pipe l i o u m r
HaveOutput (Pipe () () a () m ()
-> Pipe () () b () m () -> Pipe () () (a, b) () m b
go Pipe () () a () m ()
srcx Pipe () () b () m ()
srcy) (a
x, b
y)
go (NeedInput () -> Pipe () () a () m ()
_ () -> Pipe () () a () m ()
c) Pipe () () b () m ()
right = Pipe () () a () m ()
-> Pipe () () b () m () -> Pipe () () (a, b) () m b
go (() -> Pipe () () a () m ()
c ()) Pipe () () b () m ()
right
go Pipe () () a () m ()
left (NeedInput () -> Pipe () () b () m ()
_ () -> Pipe () () b () m ()
c) = Pipe () () a () m ()
-> Pipe () () b () m () -> Pipe () () (a, b) () m b
go Pipe () () a () m ()
left (() -> Pipe () () b () m ()
c ())
in Pipe () () a () m ()
-> Pipe () () b () m () -> Pipe () () (a, b) () m b
go (forall b. (() -> Pipe () () a () m b) -> Pipe () () a () m b
left0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done) (forall b. (() -> Pipe () () b () m b) -> Pipe () () b () m b
right0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
zipSourcesApp :: Monad m => ConduitT () (a -> b) m () -> ConduitT () a m () -> ConduitT () b m ()
zipSourcesApp :: forall (m :: * -> *) a b.
Monad m =>
ConduitT () (a -> b) m ()
-> ConduitT () a m () -> ConduitT () b m ()
zipSourcesApp (ConduitT forall b.
(() -> Pipe () () (a -> b) () m b) -> Pipe () () (a -> b) () m b
left0) (ConduitT forall b. (() -> Pipe () () a () m b) -> Pipe () () a () m b
right0) = 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
$ \() -> Pipe () () b () m b
rest -> let
go :: Pipe () () (a -> b) () m ()
-> Pipe () () a () m () -> Pipe () () b () m b
go (Leftover Pipe () () (a -> b) () m ()
left ()) Pipe () () a () m ()
right = Pipe () () (a -> b) () m ()
-> Pipe () () a () m () -> Pipe () () b () m b
go Pipe () () (a -> b) () m ()
left Pipe () () a () m ()
right
go Pipe () () (a -> b) () m ()
left (Leftover Pipe () () a () m ()
right ()) = Pipe () () (a -> b) () m ()
-> Pipe () () a () m () -> Pipe () () b () m b
go Pipe () () (a -> b) () m ()
left Pipe () () a () m ()
right
go (Done ()) (Done ()) = () -> Pipe () () b () m b
rest ()
go (Done ()) (HaveOutput Pipe () () a () m ()
_ a
_) = () -> Pipe () () b () m b
rest ()
go (HaveOutput Pipe () () (a -> b) () m ()
_ a -> b
_) (Done ()) = () -> Pipe () () b () m b
rest ()
go (Done ()) (PipeM m (Pipe () () a () m ())
_) = () -> Pipe () () b () m b
rest ()
go (PipeM m (Pipe () () (a -> b) () m ())
_) (Done ()) = () -> Pipe () () b () m b
rest ()
go (PipeM m (Pipe () () (a -> b) () m ())
mx) (PipeM m (Pipe () () a () m ())
my) = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Pipe () () (a -> b) () m ()
-> Pipe () () a () m () -> Pipe () () b () m b
go m (Pipe () () (a -> b) () m ())
mx m (Pipe () () a () m ())
my)
go (PipeM m (Pipe () () (a -> b) () m ())
mx) y :: Pipe () () a () m ()
y@HaveOutput{} = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\Pipe () () (a -> b) () m ()
x -> Pipe () () (a -> b) () m ()
-> Pipe () () a () m () -> Pipe () () b () m b
go Pipe () () (a -> b) () m ()
x Pipe () () a () m ()
y) m (Pipe () () (a -> b) () m ())
mx)
go x :: Pipe () () (a -> b) () m ()
x@HaveOutput{} (PipeM m (Pipe () () a () m ())
my) = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Pipe () () (a -> b) () m ()
-> Pipe () () a () m () -> Pipe () () b () m b
go Pipe () () (a -> b) () m ()
x) m (Pipe () () a () m ())
my)
go (HaveOutput Pipe () () (a -> b) () m ()
srcx a -> b
x) (HaveOutput Pipe () () a () m ()
srcy a
y) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> o -> Pipe l i o u m r
HaveOutput (Pipe () () (a -> b) () m ()
-> Pipe () () a () m () -> Pipe () () b () m b
go Pipe () () (a -> b) () m ()
srcx Pipe () () a () m ()
srcy) (a -> b
x a
y)
go (NeedInput () -> Pipe () () (a -> b) () m ()
_ () -> Pipe () () (a -> b) () m ()
c) Pipe () () a () m ()
right = Pipe () () (a -> b) () m ()
-> Pipe () () a () m () -> Pipe () () b () m b
go (() -> Pipe () () (a -> b) () m ()
c ()) Pipe () () a () m ()
right
go Pipe () () (a -> b) () m ()
left (NeedInput () -> Pipe () () a () m ()
_ () -> Pipe () () a () m ()
c) = Pipe () () (a -> b) () m ()
-> Pipe () () a () m () -> Pipe () () b () m b
go Pipe () () (a -> b) () m ()
left (() -> Pipe () () a () m ()
c ())
in Pipe () () (a -> b) () m ()
-> Pipe () () a () m () -> Pipe () () b () m b
go (forall b.
(() -> Pipe () () (a -> b) () m b) -> Pipe () () (a -> b) () m b
left0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done) (forall b. (() -> Pipe () () a () m b) -> Pipe () () a () m b
right0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
zipConduitApp
:: Monad m
=> ConduitT i o m (x -> y)
-> ConduitT i o m x
-> ConduitT i o m y
zipConduitApp :: forall (m :: * -> *) i o x y.
Monad m =>
ConduitT i o m (x -> y) -> ConduitT i o m x -> ConduitT i o m y
zipConduitApp (ConduitT forall b. ((x -> y) -> Pipe i i o () m b) -> Pipe i i o () m b
left0) (ConduitT forall b. (x -> Pipe i i o () m b) -> Pipe i i o () m b
right0) = 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
$ \y -> Pipe i i o () m b
rest -> let
go :: Pipe Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go (Done x -> y
f) (Done x
x) = y -> Pipe i i o () m b
rest (x -> y
f x
x)
go (PipeM m (Pipe Void i o () m (x -> y))
mx) Pipe Void i o () m x
y = 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 c. (a -> b -> c) -> b -> a -> c
flip Pipe Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go Pipe Void i o () m x
y forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m (Pipe Void i o () m (x -> y))
mx)
go Pipe Void i o () m (x -> y)
x (PipeM m (Pipe Void i o () m x)
my) = forall l i o u (m :: * -> *) r.
m (Pipe l i o u m r) -> Pipe l i o u m r
PipeM (Pipe Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go Pipe Void i o () m (x -> y)
x forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m (Pipe Void i o () m x)
my)
go (HaveOutput Pipe Void i o () m (x -> y)
x o
o) Pipe Void i o () m x
y = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> o -> Pipe l i o u m r
HaveOutput (Pipe Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go Pipe Void i o () m (x -> y)
x Pipe Void i o () m x
y) o
o
go Pipe Void i o () m (x -> y)
x (HaveOutput Pipe Void i o () m x
y 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 Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go Pipe Void i o () m (x -> y)
x Pipe Void i o () m x
y) o
o
go (Leftover Pipe Void i o () m (x -> y)
_ Void
i) Pipe Void i o () m x
_ = forall a. Void -> a
absurd Void
i
go Pipe Void i o () m (x -> y)
_ (Leftover Pipe Void i o () m x
_ Void
i) = forall a. Void -> a
absurd Void
i
go (NeedInput i -> Pipe Void i o () m (x -> y)
px () -> Pipe Void i o () m (x -> y)
cx) (NeedInput i -> Pipe Void i o () m x
py () -> Pipe Void i o () m x
cy) = 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
(\i
i -> Pipe Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go (i -> Pipe Void i o () m (x -> y)
px i
i) (i -> Pipe Void i o () m x
py i
i))
(\()
u -> Pipe Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go (() -> Pipe Void i o () m (x -> y)
cx ()
u) (() -> Pipe Void i o () m x
cy ()
u))
go (NeedInput i -> Pipe Void i o () m (x -> y)
px () -> Pipe Void i o () m (x -> y)
cx) (Done x
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
(\i
i -> Pipe Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go (i -> Pipe Void i o () m (x -> y)
px i
i) (forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done x
y))
(\()
u -> Pipe Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go (() -> Pipe Void i o () m (x -> y)
cx ()
u) (forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done x
y))
go (Done x -> y
x) (NeedInput i -> Pipe Void i o () m x
py () -> Pipe Void i o () m x
cy) = 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
(\i
i -> Pipe Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go (forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done x -> y
x) (i -> Pipe Void i o () m x
py i
i))
(\()
u -> Pipe Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go (forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done x -> y
x) (() -> Pipe Void i o () m x
cy ()
u))
in Pipe Void i o () m (x -> y)
-> Pipe Void i o () m x -> Pipe i i o () m b
go (forall (m :: * -> *) i o u r l.
Monad m =>
Pipe i i o u m r -> Pipe l i o u m r
injectLeftovers forall a b. (a -> b) -> a -> b
$ forall b. ((x -> y) -> Pipe i i o () m b) -> Pipe i i o () m b
left0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done) (forall (m :: * -> *) i o u r l.
Monad m =>
Pipe i i o u m r -> Pipe l i o u m r
injectLeftovers forall a b. (a -> b) -> a -> b
$ forall b. (x -> Pipe i i o () m b) -> Pipe i i o () m b
right0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
fuseReturnLeftovers :: Monad m
=> ConduitT a b m ()
-> ConduitT b c m r
-> ConduitT a c m (r, [b])
fuseReturnLeftovers :: forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m (r, [b])
fuseReturnLeftovers (ConduitT forall b. (() -> Pipe a a b () m b) -> Pipe a a b () m b
left0) (ConduitT forall b. (r -> Pipe b b c () m b) -> Pipe b b c () m b
right0) = 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, [b]) -> Pipe a a c () m b
rest -> let
goRight :: [b] -> Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight [b]
bs Pipe a a b () m ()
left Pipe b b c () m r
right =
case Pipe b b c () m r
right of
HaveOutput Pipe b b c () m r
p c
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 b b c () m r -> Pipe a a c () m b
recurse Pipe b b c () m r
p) c
o
NeedInput b -> Pipe b b c () m r
rp () -> Pipe b b c () m r
rc ->
case [b]
bs of
[] -> (b -> Pipe b b c () m r)
-> (() -> Pipe b b c () m r)
-> Pipe a a b () m ()
-> Pipe a a c () m b
goLeft b -> Pipe b b c () m r
rp () -> Pipe b b c () m r
rc Pipe a a b () m ()
left
b
b:[b]
bs' -> [b] -> Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight [b]
bs' Pipe a a b () m ()
left (b -> Pipe b b c () m r
rp b
b)
Done r
r2 -> (r, [b]) -> Pipe a a c () m b
rest (r
r2, [b]
bs)
PipeM m (Pipe b b c () 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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe b b c () m r -> Pipe a a c () m b
recurse m (Pipe b b c () m r)
mp)
Leftover Pipe b b c () m r
p b
b -> [b] -> Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight (b
bforall a. a -> [a] -> [a]
:[b]
bs) Pipe a a b () m ()
left Pipe b b c () m r
p
where
recurse :: Pipe b b c () m r -> Pipe a a c () m b
recurse = [b] -> Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight [b]
bs Pipe a a b () m ()
left
goLeft :: (b -> Pipe b b c () m r)
-> (() -> Pipe b b c () m r)
-> Pipe a a b () m ()
-> Pipe a a c () m b
goLeft b -> Pipe b b c () m r
rp () -> Pipe b b c () m r
rc Pipe a a b () m ()
left =
case Pipe a a b () m ()
left of
HaveOutput Pipe a a b () m ()
left' b
o -> [b] -> Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight [] Pipe a a b () m ()
left' (b -> Pipe b b c () m r
rp b
o)
NeedInput a -> Pipe a a b () m ()
left' () -> Pipe a a b () m ()
lc -> 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 a a b () m () -> Pipe a a c () m b
recurse forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Pipe a a b () m ()
left') (Pipe a a b () m () -> Pipe a a c () m b
recurse forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe a a b () m ()
lc)
Done ()
r1 -> [b] -> Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight [] (forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done ()
r1) (() -> Pipe b b c () m r
rc ()
r1)
PipeM m (Pipe a a b () m ())
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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe a a b () m () -> Pipe a a c () m b
recurse m (Pipe a a b () m ())
mp)
Leftover Pipe a a b () m ()
left' a
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 a a b () m () -> Pipe a a c () m b
recurse Pipe a a b () m ()
left') a
i
where
recurse :: Pipe a a b () m () -> Pipe a a c () m b
recurse = (b -> Pipe b b c () m r)
-> (() -> Pipe b b c () m r)
-> Pipe a a b () m ()
-> Pipe a a c () m b
goLeft b -> Pipe b b c () m r
rp () -> Pipe b b c () m r
rc
in [b] -> Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight [] (forall b. (() -> Pipe a a b () m b) -> Pipe a a b () m b
left0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done) (forall b. (r -> Pipe b b c () m b) -> Pipe b b c () m b
right0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
fuseLeftovers
:: Monad m
=> ([b] -> [a])
-> ConduitT a b m ()
-> ConduitT b c m r
-> ConduitT a c m r
fuseLeftovers :: forall (m :: * -> *) b a c r.
Monad m =>
([b] -> [a])
-> ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
fuseLeftovers [b] -> [a]
f ConduitT a b m ()
left ConduitT b c m r
right = do
(r
r, [b]
bs) <- forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m (r, [b])
fuseReturnLeftovers ConduitT a b m ()
left ConduitT b c m r
right
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ forall i o (m :: * -> *). i -> ConduitT i o m ()
leftover forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [a]
reverse forall a b. (a -> b) -> a -> b
$ [b] -> [a]
f [b]
bs
forall (m :: * -> *) a. Monad m => a -> m a
return r
r
connectResumeConduit
:: Monad m
=> SealedConduitT i o m ()
-> ConduitT o Void m r
-> ConduitT i Void m (SealedConduitT i o m (), r)
connectResumeConduit :: forall (m :: * -> *) i o r.
Monad m =>
SealedConduitT i o m ()
-> ConduitT o Void m r
-> ConduitT i Void m (SealedConduitT i o m (), r)
connectResumeConduit (SealedConduitT Pipe i i o () m ()
left0) (ConduitT forall b. (r -> Pipe o o Void () m b) -> Pipe o o Void () m b
right0) = 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
$ \(SealedConduitT i o m (), r) -> Pipe i i Void () m b
rest -> let
goRight :: Pipe i i o () m () -> Pipe o o Void () m r -> Pipe i i Void () m b
goRight Pipe i i o () m ()
left Pipe o o Void () m r
right =
case Pipe o o Void () m r
right of
HaveOutput Pipe o o Void () m r
_ Void
o -> forall a. Void -> a
absurd Void
o
NeedInput o -> Pipe o o Void () m r
rp () -> Pipe o o Void () m r
rc -> (o -> Pipe o o Void () m r)
-> (() -> Pipe o o Void () m r)
-> Pipe i i o () m ()
-> Pipe i i Void () m b
goLeft o -> Pipe o o Void () m r
rp () -> Pipe o o Void () m r
rc Pipe i i o () m ()
left
Done r
r2 -> (SealedConduitT i o m (), r) -> Pipe i i Void () m b
rest (forall i o (m :: * -> *) r.
Pipe i i o () m r -> SealedConduitT i o m r
SealedConduitT Pipe i i o () m ()
left, r
r2)
PipeM m (Pipe o o Void () 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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Pipe i i o () m () -> Pipe o o Void () m r -> Pipe i i Void () m b
goRight Pipe i i o () m ()
left) m (Pipe o o Void () m r)
mp)
Leftover Pipe o o Void () m r
p o
i -> Pipe i i o () m () -> Pipe o o Void () m r -> Pipe i i Void () m b
goRight (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 () m ()
left o
i) Pipe o o Void () m r
p
goLeft :: (o -> Pipe o o Void () m r)
-> (() -> Pipe o o Void () m r)
-> Pipe i i o () m ()
-> Pipe i i Void () m b
goLeft o -> Pipe o o Void () m r
rp () -> Pipe o o Void () m r
rc Pipe i i o () m ()
left =
case Pipe i i o () m ()
left of
HaveOutput Pipe i i o () m ()
left' o
o -> Pipe i i o () m () -> Pipe o o Void () m r -> Pipe i i Void () m b
goRight Pipe i i o () m ()
left' (o -> Pipe o o Void () m r
rp o
o)
NeedInput i -> Pipe i i o () m ()
left' () -> Pipe i i o () m ()
lc -> 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 () m () -> Pipe i i Void () m b
recurse forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe i i o () m ()
left') (Pipe i i o () m () -> Pipe i i Void () m b
recurse forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i i o () m ()
lc)
Done () -> Pipe i i o () m () -> Pipe o o Void () m r -> Pipe i i Void () m b
goRight (forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done ()) (() -> Pipe o o Void () m r
rc ())
PipeM m (Pipe i i o () m ())
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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe i i o () m () -> Pipe i i Void () m b
recurse m (Pipe i i o () m ())
mp)
Leftover Pipe i i o () m ()
left' 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 () m () -> Pipe i i Void () m b
recurse Pipe i i o () m ()
left') i
i
where
recurse :: Pipe i i o () m () -> Pipe i i Void () m b
recurse = (o -> Pipe o o Void () m r)
-> (() -> Pipe o o Void () m r)
-> Pipe i i o () m ()
-> Pipe i i Void () m b
goLeft o -> Pipe o o Void () m r
rp () -> Pipe o o Void () m r
rc
in Pipe i i o () m () -> Pipe o o Void () m r -> Pipe i i Void () m b
goRight Pipe i i o () m ()
left0 (forall b. (r -> Pipe o o Void () m b) -> Pipe o o Void () m b
right0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
mergeSource
:: Monad m
=> ConduitT () i m ()
-> ConduitT a (i, a) m ()
mergeSource :: forall (m :: * -> *) i a.
Monad m =>
ConduitT () i m () -> ConduitT a (i, a) m ()
mergeSource = forall (m :: * -> *) i a.
Monad m =>
SealedConduitT () i m () -> ConduitT a (i, a) m ()
loop forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i o (m :: * -> *) r.
ConduitT i o m r -> SealedConduitT i o m r
sealConduitT
where
loop :: Monad m => SealedConduitT () i m () -> ConduitT a (i, a) m ()
loop :: forall (m :: * -> *) i a.
Monad m =>
SealedConduitT () i m () -> ConduitT a (i, a) m ()
loop SealedConduitT () i m ()
src0 = forall (m :: * -> *) i o. Monad m => ConduitT i o m (Maybe i)
await forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall (m :: * -> *) a. Monad m => a -> m a
return ()) a -> ConduitT a (i, a) m ()
go
where
go :: a -> ConduitT a (i, a) m ()
go a
a = do
(SealedConduitT () i m ()
src1, Maybe i
mi) <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ SealedConduitT () i m ()
src0 forall (m :: * -> *) a r.
Monad m =>
SealedConduitT () a m ()
-> ConduitT a Void m r -> m (SealedConduitT () a m (), r)
$$++ forall (m :: * -> *) i o. Monad m => ConduitT i o m (Maybe i)
await
case Maybe i
mi of
Maybe i
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just i
i -> forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
yield (i
i, a
a) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) i a.
Monad m =>
SealedConduitT () i m () -> ConduitT a (i, a) m ()
loop SealedConduitT () i m ()
src1
passthroughSink :: Monad m
=> ConduitT i Void m r
-> (r -> m ())
-> ConduitT i i m ()
passthroughSink :: forall (m :: * -> *) i r.
Monad m =>
ConduitT i Void m r -> (r -> m ()) -> ConduitT i i m ()
passthroughSink (ConduitT forall b. (r -> Pipe i i Void () m b) -> Pipe i i Void () m b
sink0) r -> m ()
final = 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
$ \() -> Pipe i i i () m b
rest -> let
go :: Maybe i -> [i] -> Pipe i i Void () m r -> Pipe i i i () m b
go Maybe i
mbuf [i]
_ (Done r
r) = do
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall (m :: * -> *) a. Monad m => a -> m a
return ()) forall (m :: * -> *) o l i u. Monad m => o -> Pipe l i o u m ()
CI.yield Maybe i
mbuf
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ r -> m ()
final r
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 (forall (m :: * -> *) i o r.
Monad m =>
(i -> ConduitT i o m r) -> ConduitT i o m ()
awaitForever forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
yield) () -> Pipe i i i () m b
rest
go Maybe i
mbuf [i]
is (Leftover Pipe i i Void () m r
sink i
i) = Maybe i -> [i] -> Pipe i i Void () m r -> Pipe i i i () m b
go Maybe i
mbuf (i
iforall a. a -> [a] -> [a]
:[i]
is) Pipe i i Void () m r
sink
go Maybe i
_ [i]
_ (HaveOutput Pipe i i Void () m r
_ Void
o) = forall a. Void -> a
absurd Void
o
go Maybe i
mbuf [i]
is (PipeM m (Pipe i i Void () m r)
mx) = do
Pipe i i Void () m r
x <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Pipe i i Void () m r)
mx
Maybe i -> [i] -> Pipe i i Void () m r -> Pipe i i i () m b
go Maybe i
mbuf [i]
is Pipe i i Void () m r
x
go Maybe i
mbuf (i
i:[i]
is) (NeedInput i -> Pipe i i Void () m r
next () -> Pipe i i Void () m r
_) = Maybe i -> [i] -> Pipe i i Void () m r -> Pipe i i i () m b
go Maybe i
mbuf [i]
is (i -> Pipe i i Void () m r
next i
i)
go Maybe i
mbuf [] (NeedInput i -> Pipe i i Void () m r
next () -> Pipe i i Void () m r
done) = do
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall (m :: * -> *) a. Monad m => a -> m a
return ()) forall (m :: * -> *) o l i u. Monad m => o -> Pipe l i o u m ()
CI.yield Maybe i
mbuf
Maybe i
mx <- forall l i o u (m :: * -> *). Pipe l i o u m (Maybe i)
CI.await
case Maybe i
mx of
Maybe i
Nothing -> Maybe i -> [i] -> Pipe i i Void () m r -> Pipe i i i () m b
go forall a. Maybe a
Nothing [] (() -> Pipe i i Void () m r
done ())
Just i
x -> Maybe i -> [i] -> Pipe i i Void () m r -> Pipe i i i () m b
go (forall a. a -> Maybe a
Just i
x) [] (i -> Pipe i i Void () m r
next i
x)
in Maybe i -> [i] -> Pipe i i Void () m r -> Pipe i i i () m b
go forall a. Maybe a
Nothing [] (forall b. (r -> Pipe i i Void () m b) -> Pipe i i Void () m b
sink0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
sourceToList :: Monad m => ConduitT () a m () -> m [a]
sourceToList :: forall (m :: * -> *) a. Monad m => ConduitT () a m () -> m [a]
sourceToList (ConduitT forall b. (() -> Pipe () () a () m b) -> Pipe () () a () m b
k) =
forall {m :: * -> *} {l} {i} {a} {r}.
Monad m =>
Pipe l i a () m r -> m [a]
go forall a b. (a -> b) -> a -> b
$ forall b. (() -> Pipe () () a () m b) -> Pipe () () a () m b
k forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done
where
go :: Pipe l i a () m r -> m [a]
go (Done r
_) = forall (m :: * -> *) a. Monad m => a -> m a
return []
go (HaveOutput Pipe l i a () m r
src a
x) = forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (a
xforall a. a -> [a] -> [a]
:) (Pipe l i a () m r -> m [a]
go Pipe l i a () m r
src)
go (PipeM m (Pipe l i a () m r)
msrc) = m (Pipe l i a () m r)
msrc forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Pipe l i a () m r -> m [a]
go
go (NeedInput i -> Pipe l i a () m r
_ () -> Pipe l i a () m r
c) = Pipe l i a () m r -> m [a]
go (() -> Pipe l i a () m r
c ())
go (Leftover Pipe l i a () m r
p l
_) = Pipe l i a () m r -> m [a]
go Pipe l i a () m r
p
infixr 0 $$
infixl 1 $=
infixr 2 =$
infixr 2 =$=
infixr 0 $$+
infixr 0 $$++
infixr 0 $$+-
infixl 1 $=+
infixr 2 .|
connect :: Monad m
=> ConduitT () a m ()
-> ConduitT a Void m r
-> m r
connect :: forall (m :: * -> *) a r.
Monad m =>
ConduitT () a m () -> ConduitT a Void m r -> m r
connect = forall (m :: * -> *) a r.
Monad m =>
ConduitT () a m () -> ConduitT a Void m r -> m r
($$)
unconsM :: Monad m
=> SealedConduitT () o m ()
-> m (Maybe (o, SealedConduitT () o m ()))
unconsM :: forall (m :: * -> *) o.
Monad m =>
SealedConduitT () o m () -> m (Maybe (o, SealedConduitT () o m ()))
unconsM (SealedConduitT Pipe () () o () m ()
p) = forall {f :: * -> *} {o}.
Monad f =>
Pipe () () o () f () -> f (Maybe (o, SealedConduitT () o f ()))
go Pipe () () o () m ()
p
where
go :: Pipe () () o () f () -> f (Maybe (o, SealedConduitT () o f ()))
go (HaveOutput Pipe () () o () f ()
p o
o) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (o
o, forall i o (m :: * -> *) r.
Pipe i i o () m r -> SealedConduitT i o m r
SealedConduitT Pipe () () o () f ()
p)
go (NeedInput () -> Pipe () () o () f ()
_ () -> Pipe () () o () f ()
c) = Pipe () () o () f () -> f (Maybe (o, SealedConduitT () o f ()))
go forall a b. (a -> b) -> a -> b
$ () -> Pipe () () o () f ()
c ()
go (Done ()) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing
go (PipeM f (Pipe () () o () f ())
mp) = f (Pipe () () o () f ())
mp forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Pipe () () o () f () -> f (Maybe (o, SealedConduitT () o f ()))
go
go (Leftover Pipe () () o () f ()
p ()) = Pipe () () o () f () -> f (Maybe (o, SealedConduitT () o f ()))
go Pipe () () o () f ()
p
unconsEitherM :: Monad m
=> SealedConduitT () o m r
-> m (Either r (o, SealedConduitT () o m r))
unconsEitherM :: forall (m :: * -> *) o r.
Monad m =>
SealedConduitT () o m r
-> m (Either r (o, SealedConduitT () o m r))
unconsEitherM (SealedConduitT Pipe () () o () m r
p) = forall {f :: * -> *} {o} {a}.
Monad f =>
Pipe () () o () f a -> f (Either a (o, SealedConduitT () o f a))
go Pipe () () o () m r
p
where
go :: Pipe () () o () f a -> f (Either a (o, SealedConduitT () o f a))
go (HaveOutput Pipe () () o () f a
p o
o) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right (o
o, forall i o (m :: * -> *) r.
Pipe i i o () m r -> SealedConduitT i o m r
SealedConduitT Pipe () () o () f a
p)
go (NeedInput () -> Pipe () () o () f a
_ () -> Pipe () () o () f a
c) = Pipe () () o () f a -> f (Either a (o, SealedConduitT () o f a))
go forall a b. (a -> b) -> a -> b
$ () -> Pipe () () o () f a
c ()
go (Done a
r) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left a
r
go (PipeM f (Pipe () () o () f a)
mp) = f (Pipe () () o () f a)
mp forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Pipe () () o () f a -> f (Either a (o, SealedConduitT () o f a))
go
go (Leftover Pipe () () o () f a
p ()) = Pipe () () o () f a -> f (Either a (o, SealedConduitT () o f a))
go Pipe () () o () f a
p
fuse :: Monad m => ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
fuse :: forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
fuse = forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
(=$=)
(.|) :: Monad m
=> ConduitT a b m ()
-> ConduitT b c m r
-> ConduitT a c m r
.| :: forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
(.|) = forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
fuse
{-# INLINE (.|) #-}
($$) :: Monad m => Source m a -> Sink a m b -> m b
Source m a
src $$ :: forall (m :: * -> *) a r.
Monad m =>
ConduitT () a m () -> ConduitT a Void m r -> m r
$$ Sink a m b
sink = do
(SealedConduitT () a m ()
rsrc, b
res) <- Source m a
src forall (m :: * -> *) a b.
Monad m =>
ConduitT () a m ()
-> ConduitT a Void m b -> m (SealedConduitT () a m (), b)
$$+ Sink a m b
sink
SealedConduitT () a m ()
rsrc forall (m :: * -> *) a b.
Monad m =>
SealedConduitT () a m () -> ConduitT a Void m b -> m b
$$+- forall (m :: * -> *) a. Monad m => a -> m a
return ()
forall (m :: * -> *) a. Monad m => a -> m a
return b
res
{-# INLINE [1] ($$) #-}
{-# DEPRECATED ($$) "Use runConduit and .|" #-}
($=) :: Monad m => Conduit a m b -> ConduitT b c m r -> ConduitT a c m r
$= :: forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
($=) = forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
(=$=)
{-# INLINE [0] ($=) #-}
{-# RULES "conduit: $= is =$=" ($=) = (=$=) #-}
{-# DEPRECATED ($=) "Use .|" #-}
(=$) :: Monad m => Conduit a m b -> ConduitT b c m r -> ConduitT a c m r
=$ :: forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
(=$) = forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
(=$=)
{-# INLINE [0] (=$) #-}
{-# RULES "conduit: =$ is =$=" (=$) = (=$=) #-}
{-# DEPRECATED (=$) "Use .|" #-}
(=$=) :: Monad m => Conduit a m b -> ConduitT b c m r -> ConduitT a c m r
ConduitT forall b. (() -> Pipe a a b () m b) -> Pipe a a b () m b
left0 =$= :: forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
=$= ConduitT forall b. (r -> Pipe b b c () m b) -> Pipe b b c () m b
right0 = 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 a a c () m b
rest ->
let goRight :: Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight Pipe a a b () m ()
left Pipe b b c () m r
right =
case Pipe b b c () m r
right of
HaveOutput Pipe b b c () m r
p c
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 b b c () m r -> Pipe a a c () m b
recurse Pipe b b c () m r
p) c
o
NeedInput b -> Pipe b b c () m r
rp () -> Pipe b b c () m r
rc -> (b -> Pipe b b c () m r)
-> (() -> Pipe b b c () m r)
-> Pipe a a b () m ()
-> Pipe a a c () m b
goLeft b -> Pipe b b c () m r
rp () -> Pipe b b c () m r
rc Pipe a a b () m ()
left
Done r
r2 -> r -> Pipe a a c () m b
rest r
r2
PipeM m (Pipe b b c () 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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe b b c () m r -> Pipe a a c () m b
recurse m (Pipe b b c () m r)
mp)
Leftover Pipe b b c () m r
right' b
i -> Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight (forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> o -> Pipe l i o u m r
HaveOutput Pipe a a b () m ()
left b
i) Pipe b b c () m r
right'
where
recurse :: Pipe b b c () m r -> Pipe a a c () m b
recurse = Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight Pipe a a b () m ()
left
goLeft :: (b -> Pipe b b c () m r)
-> (() -> Pipe b b c () m r)
-> Pipe a a b () m ()
-> Pipe a a c () m b
goLeft b -> Pipe b b c () m r
rp () -> Pipe b b c () m r
rc Pipe a a b () m ()
left =
case Pipe a a b () m ()
left of
HaveOutput Pipe a a b () m ()
left' b
o -> Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight Pipe a a b () m ()
left' (b -> Pipe b b c () m r
rp b
o)
NeedInput a -> Pipe a a b () m ()
left' () -> Pipe a a b () m ()
lc -> 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 a a b () m () -> Pipe a a c () m b
recurse forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Pipe a a b () m ()
left') (Pipe a a b () m () -> Pipe a a c () m b
recurse forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe a a b () m ()
lc)
Done ()
r1 -> Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight (forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done ()
r1) (() -> Pipe b b c () m r
rc ()
r1)
PipeM m (Pipe a a b () m ())
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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe a a b () m () -> Pipe a a c () m b
recurse m (Pipe a a b () m ())
mp)
Leftover Pipe a a b () m ()
left' a
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 a a b () m () -> Pipe a a c () m b
recurse Pipe a a b () m ()
left') a
i
where
recurse :: Pipe a a b () m () -> Pipe a a c () m b
recurse = (b -> Pipe b b c () m r)
-> (() -> Pipe b b c () m r)
-> Pipe a a b () m ()
-> Pipe a a c () m b
goLeft b -> Pipe b b c () m r
rp () -> Pipe b b c () m r
rc
in Pipe a a b () m () -> Pipe b b c () m r -> Pipe a a c () m b
goRight (forall b. (() -> Pipe a a b () m b) -> Pipe a a b () m b
left0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done) (forall b. (r -> Pipe b b c () m b) -> Pipe b b c () m b
right0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
{-# INLINE [1] (=$=) #-}
{-# DEPRECATED (=$=) "Use .|" #-}
await :: Monad m => ConduitT i o m (Maybe i)
await :: forall (m :: * -> *) i o. Monad m => ConduitT i o m (Maybe i)
await = 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 i -> Pipe i i o () m b
f -> 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 (Maybe i -> Pipe i i o () m b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just) (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ Maybe i -> Pipe i i o () m b
f forall a. Maybe a
Nothing)
{-# INLINE [0] await #-}
await' :: Monad m
=> ConduitT i o m r
-> (i -> ConduitT i o m r)
-> ConduitT i o m r
await' :: forall (m :: * -> *) i o r.
Monad m =>
ConduitT i o m r -> (i -> ConduitT i o m r) -> ConduitT i o m r
await' ConduitT i o m r
f i -> ConduitT i o m r
g = 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 () m b
rest -> 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
(\i
i -> 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 (i -> ConduitT i o m r
g i
i) r -> Pipe i i o () m b
rest)
(forall a b. a -> b -> a
const 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 m r
f r -> Pipe i i o () m b
rest)
{-# INLINE await' #-}
{-# RULES "conduit: await >>= maybe" forall x y. await >>= maybe x y = await' x y #-}
yield :: Monad m
=> o
-> ConduitT i o m ()
yield :: forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
yield o
o = 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
$ \() -> Pipe i i o () m b
rest -> 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 () m b
rest ()) o
o
{-# INLINE yield #-}
yieldM :: Monad m => m o -> ConduitT i o m ()
yieldM :: forall (m :: * -> *) o i. Monad m => m o -> ConduitT i o m ()
yieldM m o
mo = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m o
mo forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
yield
{-# INLINE yieldM #-}
leftover :: i -> ConduitT i o m ()
leftover :: forall i o (m :: * -> *). i -> ConduitT i o m ()
leftover i
i = 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
$ \() -> Pipe i i o () m b
rest -> 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 () m b
rest ()) i
i
{-# INLINE leftover #-}
runConduit :: Monad m => ConduitT () Void m r -> m r
runConduit :: forall (m :: * -> *) r. Monad m => ConduitT () Void m r -> m r
runConduit (ConduitT forall b. (r -> Pipe () () Void () m b) -> Pipe () () Void () m b
p) = forall (m :: * -> *) r. Monad m => Pipe Void () Void () m r -> m r
runPipe forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) i o u r l.
Monad m =>
Pipe i i o u m r -> Pipe l i o u m r
injectLeftovers forall a b. (a -> b) -> a -> b
$ forall b. (r -> Pipe () () Void () m b) -> Pipe () () Void () m b
p forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done
{-# INLINE [0] runConduit #-}
bracketP :: MonadResource m
=> IO a
-> (a -> IO ())
-> (a -> ConduitT i o m r)
-> ConduitT i o m r
bracketP :: forall (m :: * -> *) a i o r.
MonadResource m =>
IO a -> (a -> IO ()) -> (a -> ConduitT i o m r) -> ConduitT i o m r
bracketP IO a
alloc a -> IO ()
free a -> ConduitT i o m r
inside = 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 () m b
rest -> do
(ReleaseKey
key, a
seed) <- forall (m :: * -> *) a.
MonadResource m =>
IO a -> (a -> IO ()) -> m (ReleaseKey, a)
allocate IO a
alloc a -> IO ()
free
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 (a -> ConduitT i o m r
inside a
seed) forall a b. (a -> b) -> a -> b
$ \r
res -> do
forall (m :: * -> *). MonadIO m => ReleaseKey -> m ()
release ReleaseKey
key
r -> Pipe i i o () m b
rest r
res
awaitForever :: Monad m => (i -> ConduitT i o m r) -> ConduitT i o m ()
awaitForever :: forall (m :: * -> *) i o r.
Monad m =>
(i -> ConduitT i o m r) -> ConduitT i o m ()
awaitForever i -> ConduitT i o m r
f = 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
$ \() -> Pipe i i o () m b
rest ->
let go :: Pipe i i o () m b
go = 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 (\i
i -> 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 (i -> ConduitT i o m r
f i
i) (forall a b. a -> b -> a
const Pipe i i o () m b
go)) () -> Pipe i i o () m b
rest
in Pipe i i o () m b
go
transPipe :: Monad m => (forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe :: 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 -> n a
f (ConduitT forall b. (r -> Pipe i i o () m b) -> Pipe i i o () 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
$ \r -> Pipe i i o () n b
rest -> let
go :: Pipe i i o () m r -> Pipe i i o () n b
go (HaveOutput Pipe i i o () 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 () m r -> Pipe i i o () n b
go Pipe i i o () m r
p) o
o
go (NeedInput i -> Pipe i i o () m r
p () -> Pipe i i o () m r
c) = 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 () m r -> Pipe i i o () n b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe i i o () m r
p) (Pipe i i o () m r -> Pipe i i o () n b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i i o () m r
c)
go (Done r
r) = r -> Pipe i i o () n b
rest r
r
go (PipeM m (Pipe i i o () 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. m a -> n a
f forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe i i o () m r -> Pipe i i o () n b
go forall a b. (a -> b) -> a -> b
$ forall {m :: * -> *} {l} {i} {o} {u} {r}.
Monad m =>
m (Pipe l i o u m r) -> m (Pipe l i o u m r)
collapse m (Pipe i i o () m r)
mp)
where
collapse :: m (Pipe l i o u m r) -> m (Pipe l i o u m r)
collapse m (Pipe l i o u m r)
mpipe = do
Pipe l i o u m r
pipe' <- m (Pipe l i o u m r)
mpipe
case Pipe l i o u m r
pipe' of
PipeM m (Pipe l i o u m r)
mpipe' -> m (Pipe l i o u m r) -> m (Pipe l i o u m r)
collapse m (Pipe l i o u m r)
mpipe'
Pipe l i o u m r
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return Pipe l i o u m r
pipe'
go (Leftover Pipe i i o () 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 () m r -> Pipe i i o () n b
go Pipe i i o () m r
p) i
i
in Pipe i i o () m r -> Pipe i i o () n b
go (forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
mapOutput :: Monad m => (o1 -> o2) -> ConduitT i o1 m r -> ConduitT i o2 m r
mapOutput :: forall (m :: * -> *) o1 o2 i r.
Monad m =>
(o1 -> o2) -> ConduitT i o1 m r -> ConduitT i o2 m r
mapOutput o1 -> o2
f (ConduitT forall b. (r -> Pipe i i o1 () m b) -> Pipe i i o1 () 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
$ \r -> Pipe i i o2 () m b
rest -> let
go :: Pipe i i o1 () m r -> Pipe i i o2 () m b
go (HaveOutput Pipe i i o1 () m r
p o1
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 o1 () m r -> Pipe i i o2 () m b
go Pipe i i o1 () m r
p) (o1 -> o2
f o1
o)
go (NeedInput i -> Pipe i i o1 () m r
p () -> Pipe i i o1 () m r
c) = 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 o1 () m r -> Pipe i i o2 () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe i i o1 () m r
p) (Pipe i i o1 () m r -> Pipe i i o2 () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i i o1 () m r
c)
go (Done r
r) = r -> Pipe i i o2 () m b
rest r
r
go (PipeM m (Pipe i i o1 () 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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Pipe i i o1 () m r -> Pipe i i o2 () m b
go) m (Pipe i i o1 () m r)
mp)
go (Leftover Pipe i i o1 () 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 o1 () m r -> Pipe i i o2 () m b
go Pipe i i o1 () m r
p) i
i
in Pipe i i o1 () m r -> Pipe i i o2 () m b
go (forall b. (r -> Pipe i i o1 () m b) -> Pipe i i o1 () m b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
mapOutputMaybe :: Monad m => (o1 -> Maybe o2) -> ConduitT i o1 m r -> ConduitT i o2 m r
mapOutputMaybe :: forall (m :: * -> *) o1 o2 i r.
Monad m =>
(o1 -> Maybe o2) -> ConduitT i o1 m r -> ConduitT i o2 m r
mapOutputMaybe o1 -> Maybe o2
f (ConduitT forall b. (r -> Pipe i i o1 () m b) -> Pipe i i o1 () 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
$ \r -> Pipe i i o2 () m b
rest -> let
go :: Pipe i i o1 () m r -> Pipe i i o2 () m b
go (HaveOutput Pipe i i o1 () m r
p o1
o) = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. a -> a
id (\o2
o' Pipe i i o2 () m b
p' -> 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 o2 () m b
p' o2
o') (o1 -> Maybe o2
f o1
o) (Pipe i i o1 () m r -> Pipe i i o2 () m b
go Pipe i i o1 () m r
p)
go (NeedInput i -> Pipe i i o1 () m r
p () -> Pipe i i o1 () m r
c) = 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 o1 () m r -> Pipe i i o2 () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Pipe i i o1 () m r
p) (Pipe i i o1 () m r -> Pipe i i o2 () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i i o1 () m r
c)
go (Done r
r) = r -> Pipe i i o2 () m b
rest r
r
go (PipeM m (Pipe i i o1 () 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 (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Pipe i i o1 () m r -> Pipe i i o2 () m b
go) m (Pipe i i o1 () m r)
mp)
go (Leftover Pipe i i o1 () 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 o1 () m r -> Pipe i i o2 () m b
go Pipe i i o1 () m r
p) i
i
in Pipe i i o1 () m r -> Pipe i i o2 () m b
go (forall b. (r -> Pipe i i o1 () m b) -> Pipe i i o1 () m b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
mapInput :: Monad m
=> (i1 -> i2)
-> (i2 -> Maybe i1)
-> ConduitT i2 o m r
-> ConduitT i1 o m r
mapInput :: forall (m :: * -> *) i1 i2 o r.
Monad m =>
(i1 -> i2)
-> (i2 -> Maybe i1) -> ConduitT i2 o m r -> ConduitT i1 o m r
mapInput i1 -> i2
f i2 -> Maybe i1
f' (ConduitT forall b. (r -> Pipe i2 i2 o () m b) -> Pipe i2 i2 o () 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
$ \r -> Pipe i1 i1 o () m b
rest -> let
go :: Pipe i2 i2 o () m r -> Pipe i1 i1 o () m b
go (HaveOutput Pipe i2 i2 o () 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 i2 i2 o () m r -> Pipe i1 i1 o () m b
go Pipe i2 i2 o () m r
p) o
o
go (NeedInput i2 -> Pipe i2 i2 o () m r
p () -> Pipe i2 i2 o () m r
c) = 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 i2 i2 o () m r -> Pipe i1 i1 o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i2 -> Pipe i2 i2 o () m r
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. i1 -> i2
f) (Pipe i2 i2 o () m r -> Pipe i1 i1 o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i2 i2 o () m r
c)
go (Done r
r) = r -> Pipe i1 i1 o () m b
rest r
r
go (PipeM m (Pipe i2 i2 o () 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
$ forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pipe i2 i2 o () m r -> Pipe i1 i1 o () m b
go m (Pipe i2 i2 o () m r)
mp
go (Leftover Pipe i2 i2 o () m r
p i2
i) = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. a -> a
id (forall a b c. (a -> b -> c) -> b -> a -> c
flip forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> l -> Pipe l i o u m r
Leftover) (i2 -> Maybe i1
f' i2
i) (Pipe i2 i2 o () m r -> Pipe i1 i1 o () m b
go Pipe i2 i2 o () m r
p)
in Pipe i2 i2 o () m r -> Pipe i1 i1 o () m b
go (forall b. (r -> Pipe i2 i2 o () m b) -> Pipe i2 i2 o () m b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
mapInputM :: Monad m
=> (i1 -> m i2)
-> (i2 -> m (Maybe i1))
-> ConduitT i2 o m r
-> ConduitT i1 o m r
mapInputM :: forall (m :: * -> *) i1 i2 o r.
Monad m =>
(i1 -> m i2)
-> (i2 -> m (Maybe i1)) -> ConduitT i2 o m r -> ConduitT i1 o m r
mapInputM i1 -> m i2
f i2 -> m (Maybe i1)
f' (ConduitT forall b. (r -> Pipe i2 i2 o () m b) -> Pipe i2 i2 o () 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
$ \r -> Pipe i1 i1 o () m b
rest -> let
go :: Pipe i2 i2 o () m r -> Pipe i1 i1 o () m b
go (HaveOutput Pipe i2 i2 o () 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 i2 i2 o () m r -> Pipe i1 i1 o () m b
go Pipe i2 i2 o () m r
p) o
o
go (NeedInput i2 -> Pipe i2 i2 o () m r
p () -> Pipe i2 i2 o () m r
c) = 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 (\i1
i -> 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
$ Pipe i2 i2 o () m r -> Pipe i1 i1 o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. i2 -> Pipe i2 i2 o () m r
p forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> i1 -> m i2
f i1
i) (Pipe i2 i2 o () m r -> Pipe i1 i1 o () m b
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. () -> Pipe i2 i2 o () m r
c)
go (Done r
r) = r -> Pipe i1 i1 o () m b
rest r
r
go (PipeM m (Pipe i2 i2 o () 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
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Pipe i2 i2 o () m r -> Pipe i1 i1 o () m b
go m (Pipe i2 i2 o () m r)
mp
go (Leftover Pipe i2 i2 o () m r
p i2
i) = 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
$ (\Maybe i1
x -> forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. a -> a
id (forall a b c. (a -> b -> c) -> b -> a -> c
flip forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> l -> Pipe l i o u m r
Leftover) Maybe i1
x (Pipe i2 i2 o () m r -> Pipe i1 i1 o () m b
go Pipe i2 i2 o () m r
p)) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> i2 -> m (Maybe i1)
f' i2
i
in Pipe i2 i2 o () m r -> Pipe i1 i1 o () m b
go (forall b. (r -> Pipe i2 i2 o () m b) -> Pipe i2 i2 o () m b
c0 forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
($$+) :: Monad m => ConduitT () a m () -> ConduitT a Void m b -> m (SealedConduitT () a m (), b)
ConduitT () a m ()
src $$+ :: forall (m :: * -> *) a b.
Monad m =>
ConduitT () a m ()
-> ConduitT a Void m b -> m (SealedConduitT () a m (), b)
$$+ ConduitT a Void m b
sink = forall (m :: * -> *) a r.
Monad m =>
SealedConduitT () a m ()
-> ConduitT a Void m r -> m (SealedConduitT () a m (), r)
connectResume (forall i o (m :: * -> *) r.
ConduitT i o m r -> SealedConduitT i o m r
sealConduitT ConduitT () a m ()
src) ConduitT a Void m b
sink
{-# INLINE ($$+) #-}
($$++) :: Monad m => SealedConduitT () a m () -> ConduitT a Void m b -> m (SealedConduitT () a m (), b)
$$++ :: forall (m :: * -> *) a r.
Monad m =>
SealedConduitT () a m ()
-> ConduitT a Void m r -> m (SealedConduitT () a m (), r)
($$++) = forall (m :: * -> *) a r.
Monad m =>
SealedConduitT () a m ()
-> ConduitT a Void m r -> m (SealedConduitT () a m (), r)
connectResume
{-# INLINE ($$++) #-}
($$+-) :: Monad m => SealedConduitT () a m () -> ConduitT a Void m b -> m b
SealedConduitT () a m ()
rsrc $$+- :: forall (m :: * -> *) a b.
Monad m =>
SealedConduitT () a m () -> ConduitT a Void m b -> m b
$$+- ConduitT a Void m b
sink = do
(SealedConduitT () a m ()
_, b
res) <- forall (m :: * -> *) a r.
Monad m =>
SealedConduitT () a m ()
-> ConduitT a Void m r -> m (SealedConduitT () a m (), r)
connectResume SealedConduitT () a m ()
rsrc ConduitT a Void m b
sink
forall (m :: * -> *) a. Monad m => a -> m a
return b
res
{-# INLINE ($$+-) #-}
($=+) :: Monad m => SealedConduitT () a m () -> ConduitT a b m () -> SealedConduitT () b m ()
SealedConduitT Pipe () () a () m ()
src $=+ :: forall (m :: * -> *) a b.
Monad m =>
SealedConduitT () a m ()
-> ConduitT a b m () -> SealedConduitT () b m ()
$=+ ConduitT forall b. (() -> Pipe a a b () m b) -> Pipe a a b () m b
sink = forall i o (m :: * -> *) r.
Pipe i i o () m r -> SealedConduitT i o m r
SealedConduitT (Pipe () () a () m ()
src forall (m :: * -> *) l a b r0 r1 c r2.
Monad m =>
Pipe l a b r0 m r1 -> Pipe b b c r1 m r2 -> Pipe l a c r0 m r2
`pipeL` forall b. (() -> Pipe a a b () m b) -> Pipe a a b () m b
sink forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done)
data Flush a = Chunk a | Flush
deriving (Int -> Flush a -> ShowS
forall a. Show a => Int -> Flush a -> ShowS
forall a. Show a => [Flush a] -> ShowS
forall a. Show a => Flush a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Flush a] -> ShowS
$cshowList :: forall a. Show a => [Flush a] -> ShowS
show :: Flush a -> String
$cshow :: forall a. Show a => Flush a -> String
showsPrec :: Int -> Flush a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Flush a -> ShowS
Show, Flush a -> Flush a -> Bool
forall a. Eq a => Flush a -> Flush a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Flush a -> Flush a -> Bool
$c/= :: forall a. Eq a => Flush a -> Flush a -> Bool
== :: Flush a -> Flush a -> Bool
$c== :: forall a. Eq a => Flush a -> Flush a -> Bool
Eq, Flush a -> Flush a -> Bool
Flush a -> Flush a -> Ordering
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a}. Ord a => Eq (Flush a)
forall a. Ord a => Flush a -> Flush a -> Bool
forall a. Ord a => Flush a -> Flush a -> Ordering
forall a. Ord a => Flush a -> Flush a -> Flush a
min :: Flush a -> Flush a -> Flush a
$cmin :: forall a. Ord a => Flush a -> Flush a -> Flush a
max :: Flush a -> Flush a -> Flush a
$cmax :: forall a. Ord a => Flush a -> Flush a -> Flush a
>= :: Flush a -> Flush a -> Bool
$c>= :: forall a. Ord a => Flush a -> Flush a -> Bool
> :: Flush a -> Flush a -> Bool
$c> :: forall a. Ord a => Flush a -> Flush a -> Bool
<= :: Flush a -> Flush a -> Bool
$c<= :: forall a. Ord a => Flush a -> Flush a -> Bool
< :: Flush a -> Flush a -> Bool
$c< :: forall a. Ord a => Flush a -> Flush a -> Bool
compare :: Flush a -> Flush a -> Ordering
$ccompare :: forall a. Ord a => Flush a -> Flush a -> Ordering
Ord)
instance Functor Flush where
fmap :: forall a b. (a -> b) -> Flush a -> Flush b
fmap a -> b
_ Flush a
Flush = forall a. Flush a
Flush
fmap a -> b
f (Chunk a
a) = forall a. a -> Flush a
Chunk (a -> b
f a
a)
newtype ZipSource m o = ZipSource { forall (m :: * -> *) o. ZipSource m o -> ConduitT () o m ()
getZipSource :: ConduitT () o m () }
instance Monad m => Functor (ZipSource m) where
fmap :: forall a b. (a -> b) -> ZipSource m a -> ZipSource m b
fmap a -> b
f = forall (m :: * -> *) o. ConduitT () o m () -> ZipSource m o
ZipSource forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) o1 o2 i r.
Monad m =>
(o1 -> o2) -> ConduitT i o1 m r -> ConduitT i o2 m r
mapOutput a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) o. ZipSource m o -> ConduitT () o m ()
getZipSource
instance Monad m => Applicative (ZipSource m) where
pure :: forall a. a -> ZipSource m a
pure = forall (m :: * -> *) o. ConduitT () o m () -> ZipSource m o
ZipSource forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Applicative f => f a -> f b
forever forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
yield
(ZipSource ConduitT () (a -> b) m ()
f) <*> :: forall a b. ZipSource m (a -> b) -> ZipSource m a -> ZipSource m b
<*> (ZipSource ConduitT () a m ()
x) = forall (m :: * -> *) o. ConduitT () o m () -> ZipSource m o
ZipSource forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
ConduitT () (a -> b) m ()
-> ConduitT () a m () -> ConduitT () b m ()
zipSourcesApp ConduitT () (a -> b) m ()
f ConduitT () a m ()
x
sequenceSources :: (Traversable f, Monad m) => f (ConduitT () o m ()) -> ConduitT () (f o) m ()
sequenceSources :: forall (f :: * -> *) (m :: * -> *) o.
(Traversable f, Monad m) =>
f (ConduitT () o m ()) -> ConduitT () (f o) m ()
sequenceSources = forall (m :: * -> *) o. ZipSource m o -> ConduitT () o m ()
getZipSource forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (m :: * -> *) o. ConduitT () o m () -> ZipSource m o
ZipSource
newtype ZipSink i m r = ZipSink { forall i (m :: * -> *) r. ZipSink i m r -> ConduitT i Void m r
getZipSink :: ConduitT i Void m r }
instance Monad m => Functor (ZipSink i m) where
fmap :: forall a b. (a -> b) -> ZipSink i m a -> ZipSink i m b
fmap a -> b
f (ZipSink ConduitT i Void m a
x) = forall i (m :: * -> *) r. ConduitT i Void m r -> ZipSink i m r
ZipSink (forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM a -> b
f ConduitT i Void m a
x)
instance Monad m => Applicative (ZipSink i m) where
pure :: forall a. a -> ZipSink i m a
pure = forall i (m :: * -> *) r. ConduitT i Void m r -> ZipSink i m r
ZipSink forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Monad m => a -> m a
return
(ZipSink ConduitT i Void m (a -> b)
f) <*> :: forall a b. ZipSink i m (a -> b) -> ZipSink i m a -> ZipSink i m b
<*> (ZipSink ConduitT i Void m a
x) =
forall i (m :: * -> *) r. ConduitT i Void m r -> ZipSink i m r
ZipSink forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry forall a b. (a -> b) -> a -> b
($)) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) i r r'.
Monad m =>
ConduitT i Void m r
-> ConduitT i Void m r' -> ConduitT i Void m (r, r')
zipSinks ConduitT i Void m (a -> b)
f ConduitT i Void m a
x
sequenceSinks :: (Traversable f, Monad m) => f (ConduitT i Void m r) -> ConduitT i Void m (f r)
sequenceSinks :: forall (f :: * -> *) (m :: * -> *) i r.
(Traversable f, Monad m) =>
f (ConduitT i Void m r) -> ConduitT i Void m (f r)
sequenceSinks = forall i (m :: * -> *) r. ZipSink i m r -> ConduitT i Void m r
getZipSink forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall i (m :: * -> *) r. ConduitT i Void m r -> ZipSink i m r
ZipSink
(=$$+) :: Monad m
=> ConduitT a b m ()
-> ConduitT b Void m r
-> ConduitT a Void m (SealedConduitT a b m (), r)
=$$+ :: forall (m :: * -> *) a b r.
Monad m =>
ConduitT a b m ()
-> ConduitT b Void m r
-> ConduitT a Void m (SealedConduitT a b m (), r)
(=$$+) ConduitT a b m ()
conduit = forall (m :: * -> *) i o r.
Monad m =>
SealedConduitT i o m ()
-> ConduitT o Void m r
-> ConduitT i Void m (SealedConduitT i o m (), r)
connectResumeConduit (forall i o (m :: * -> *) r.
ConduitT i o m r -> SealedConduitT i o m r
sealConduitT ConduitT a b m ()
conduit)
{-# INLINE (=$$+) #-}
(=$$++) :: Monad m => SealedConduitT i o m () -> ConduitT o Void m r -> ConduitT i Void m (SealedConduitT i o m (), r)
=$$++ :: forall (m :: * -> *) i o r.
Monad m =>
SealedConduitT i o m ()
-> ConduitT o Void m r
-> ConduitT i Void m (SealedConduitT i o m (), r)
(=$$++) = forall (m :: * -> *) i o r.
Monad m =>
SealedConduitT i o m ()
-> ConduitT o Void m r
-> ConduitT i Void m (SealedConduitT i o m (), r)
connectResumeConduit
{-# INLINE (=$$++) #-}
(=$$+-) :: Monad m => SealedConduitT i o m () -> ConduitT o Void m r -> ConduitT i Void m r
SealedConduitT i o m ()
rsrc =$$+- :: forall (m :: * -> *) i o r.
Monad m =>
SealedConduitT i o m ()
-> ConduitT o Void m r -> ConduitT i Void m r
=$$+- ConduitT o Void m r
sink = do
(SealedConduitT i o m ()
_, r
res) <- forall (m :: * -> *) i o r.
Monad m =>
SealedConduitT i o m ()
-> ConduitT o Void m r
-> ConduitT i Void m (SealedConduitT i o m (), r)
connectResumeConduit SealedConduitT i o m ()
rsrc ConduitT o Void m r
sink
forall (m :: * -> *) a. Monad m => a -> m a
return r
res
{-# INLINE (=$$+-) #-}
infixr 0 =$$+
infixr 0 =$$++
infixr 0 =$$+-
newtype ZipConduit i o m r = ZipConduit { forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit :: ConduitT i o m r }
deriving forall a b. a -> ZipConduit i o m b -> ZipConduit i o m a
forall a b. (a -> b) -> ZipConduit i o m a -> ZipConduit i o m b
forall i o (m :: * -> *) a b.
a -> ZipConduit i o m b -> ZipConduit i o m a
forall i o (m :: * -> *) a b.
(a -> b) -> ZipConduit i o m a -> ZipConduit i o m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> ZipConduit i o m b -> ZipConduit i o m a
$c<$ :: forall i o (m :: * -> *) a b.
a -> ZipConduit i o m b -> ZipConduit i o m a
fmap :: forall a b. (a -> b) -> ZipConduit i o m a -> ZipConduit i o m b
$cfmap :: forall i o (m :: * -> *) a b.
(a -> b) -> ZipConduit i o m a -> ZipConduit i o m b
Functor
instance Monad m => Applicative (ZipConduit i o m) where
pure :: forall a. a -> ZipConduit i o m a
pure = forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure
ZipConduit ConduitT i o m (a -> b)
left <*> :: forall a b.
ZipConduit i o m (a -> b)
-> ZipConduit i o m a -> ZipConduit i o m b
<*> ZipConduit ConduitT i o m a
right = forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (forall (m :: * -> *) i o x y.
Monad m =>
ConduitT i o m (x -> y) -> ConduitT i o m x -> ConduitT i o m y
zipConduitApp ConduitT i o m (a -> b)
left ConduitT i o m a
right)
sequenceConduits :: (Traversable f, Monad m) => f (ConduitT i o m r) -> ConduitT i o m (f r)
sequenceConduits :: forall (f :: * -> *) (m :: * -> *) i o r.
(Traversable f, Monad m) =>
f (ConduitT i o m r) -> ConduitT i o m (f r)
sequenceConduits = forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit
fuseBoth :: Monad m => ConduitT a b m r1 -> ConduitT b c m r2 -> ConduitT a c m (r1, r2)
fuseBoth :: forall (m :: * -> *) a b r1 c r2.
Monad m =>
ConduitT a b m r1 -> ConduitT b c m r2 -> ConduitT a c m (r1, r2)
fuseBoth (ConduitT forall b. (r1 -> Pipe a a b () m b) -> Pipe a a b () m b
up) (ConduitT forall b. (r2 -> Pipe b b c () m b) -> Pipe b b c () m b
down) =
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 (m :: * -> *) l a b r0 r1 c r2.
Monad m =>
Pipe l a b r0 m r1 -> Pipe b b c r1 m r2 -> Pipe l a c r0 m r2
pipeL (forall b. (r1 -> Pipe a a b () m b) -> Pipe a a b () m b
up forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done) (forall (m :: * -> *) l i o u r.
Monad m =>
Pipe l i o u m r -> Pipe l i o u m (u, r)
withUpstream forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) l i o r u.
Monad m =>
Pipe l i o () m r -> Pipe l i o u m r
generalizeUpstream forall a b. (a -> b) -> a -> b
$ forall b. (r2 -> Pipe b b c () m b) -> Pipe b b c () m b
down forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=)
{-# INLINE fuseBoth #-}
fuseBothMaybe
:: Monad m
=> ConduitT a b m r1
-> ConduitT b c m r2
-> ConduitT a c m (Maybe r1, r2)
fuseBothMaybe :: forall (m :: * -> *) a b r1 c r2.
Monad m =>
ConduitT a b m r1
-> ConduitT b c m r2 -> ConduitT a c m (Maybe r1, r2)
fuseBothMaybe (ConduitT forall b. (r1 -> Pipe a a b () m b) -> Pipe a a b () m b
up) (ConduitT forall b. (r2 -> Pipe b b c () m b) -> Pipe b b c () m b
down) =
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 (m :: * -> *) l a b r0 r1 c r2.
Monad m =>
Pipe l a b r0 m r1 -> Pipe b b c r1 m r2 -> Pipe l a c r0 m r2
pipeL (forall b. (r1 -> Pipe a a b () m b) -> Pipe a a b () m b
up forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done) (forall {m :: * -> *} {a} {l} {i} {o} {b}.
Monad m =>
Maybe a -> Pipe l i o () m b -> Pipe l i o a m (Maybe a, b)
go forall a. Maybe a
Nothing forall a b. (a -> b) -> a -> b
$ forall b. (r2 -> Pipe b b c () m b) -> Pipe b b c () m b
down forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=)
where
go :: Maybe a -> Pipe l i o () m b -> Pipe l i o a m (Maybe a, b)
go Maybe a
mup (Done b
r) = forall l i o u (m :: * -> *) r. r -> Pipe l i o u m r
Done (Maybe a
mup, b
r)
go Maybe a
mup (PipeM m (Pipe l i o () m b)
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
$ forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Maybe a -> Pipe l i o () m b -> Pipe l i o a m (Maybe a, b)
go Maybe a
mup) m (Pipe l i o () m b)
mp
go Maybe a
mup (HaveOutput Pipe l i o () m b
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 (Maybe a -> Pipe l i o () m b -> Pipe l i o a m (Maybe a, b)
go Maybe a
mup Pipe l i o () m b
p) o
o
go Maybe a
_ (NeedInput i -> Pipe l i o () m b
p () -> Pipe l i o () m b
c) = 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
(\i
i -> Maybe a -> Pipe l i o () m b -> Pipe l i o a m (Maybe a, b)
go forall a. Maybe a
Nothing (i -> Pipe l i o () m b
p i
i))
(\a
u -> Maybe a -> Pipe l i o () m b -> Pipe l i o a m (Maybe a, b)
go (forall a. a -> Maybe a
Just a
u) (() -> Pipe l i o () m b
c ()))
go Maybe a
mup (Leftover Pipe l i o () m b
p l
i) = forall l i o u (m :: * -> *) r.
Pipe l i o u m r -> l -> Pipe l i o u m r
Leftover (Maybe a -> Pipe l i o () m b -> Pipe l i o a m (Maybe a, b)
go Maybe a
mup Pipe l i o () m b
p) l
i
{-# INLINABLE fuseBothMaybe #-}
fuseUpstream :: Monad m => ConduitT a b m r -> ConduitT b c m () -> ConduitT a c m r
fuseUpstream :: forall (m :: * -> *) a b r c.
Monad m =>
ConduitT a b m r -> ConduitT b c m () -> ConduitT a c m r
fuseUpstream ConduitT a b m r
up ConduitT b c m ()
down = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> a
fst (forall (m :: * -> *) a b r1 c r2.
Monad m =>
ConduitT a b m r1 -> ConduitT b c m r2 -> ConduitT a c m (r1, r2)
fuseBoth ConduitT a b m r
up ConduitT b c m ()
down)
{-# INLINE fuseUpstream #-}
runConduitPure :: ConduitT () Void Identity r -> r
runConduitPure :: forall r. ConduitT () Void Identity r -> r
runConduitPure = forall a. Identity a -> a
runIdentity forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ConduitT () Void m r -> m r
runConduit
{-# INLINE runConduitPure #-}
runConduitRes :: MonadUnliftIO m
=> ConduitT () Void (ResourceT m) r
-> m r
runConduitRes :: forall (m :: * -> *) r.
MonadUnliftIO m =>
ConduitT () Void (ResourceT m) r -> m r
runConduitRes = forall (m :: * -> *) a. MonadUnliftIO m => ResourceT m a -> m a
runResourceT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ConduitT () Void m r -> m r
runConduit
{-# INLINE runConduitRes #-}