-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Compositional pipelines
--   
--   pipes is a clean and powerful stream processing library that
--   lets you build and connect reusable streaming components
--   
--   Advantages over traditional streaming libraries:
--   
--   
--   
- Concise API: Use simple commands like for,
--   (>->), await, and yield
--   
- Blazing fast: Implementation tuned for speed, including
--   shortcut fusion
--   
- Lightweight Dependency: pipes is small and
--   compiles very rapidly, including dependencies
--   
- Elegant semantics: Use practical category theory
--   
- ListT: Correct implementation of ListT that
--   interconverts with pipes
--   
- Bidirectionality: Implement duplex channels
--   
- Extensive Documentation: Second to none!
--   
--   
--   Import Pipes to use the library.
--   
--   Read Pipes.Tutorial for an extensive tutorial.
@package pipes
@version 4.1.0

-- | This is an internal module, meaning that it is unsafe to import unless
--   you understand the risks.
--   
--   This module provides a fast implementation by weakening the monad
--   transformer laws. These laws do not hold if you can pattern match on
--   the constructors, as the following counter-example illustrates:
--   
--   
--   lift . return = M . return . Pure
--   
--   return = Pure
--   
--   lift . return /= return
--   
--   
--   You do not need to worry about this if you do not import this module,
--   since the other modules in this library do not export the constructors
--   or export any functions which can violate the monad transformer laws.
module Pipes.Internal

-- | A Proxy is a monad transformer that receives and sends
--   information on both an upstream and downstream interface.
--   
--   The type variables signify:
--   
--   
--   
- a' and a - The upstream interface, where
--   (a')s go out and (a)s come in
--   
- b' and b - The downstream interface, where
--   (b)s go out and (b')s come in
--   
- m  - The base monad
--   
- r  - The return value
--   
data Proxy a' a b' b m r
Request :: a' -> (a -> Proxy a' a b' b m r) -> Proxy a' a b' b m r
Respond :: b -> (b' -> Proxy a' a b' b m r) -> Proxy a' a b' b m r
M :: (m (Proxy a' a b' b m r)) -> Proxy a' a b' b m r
Pure :: r -> Proxy a' a b' b m r

-- | unsafeHoist is like hoist, but faster.
--   
--   This is labeled as unsafe because you will break the monad transformer
--   laws if you do not pass a monad morphism as the first argument. This
--   function is safe if you pass a monad morphism as the first argument.
unsafeHoist :: Monad m => (forall x. m x -> n x) -> Proxy a' a b' b m r -> Proxy a' a b' b n r

-- | The monad transformer laws are correct when viewed through the
--   observe function:
--   
--   
--   observe (lift (return r)) = observe (return r)
--   
--   observe (lift (m >>= f)) = observe (lift m >>= lift . f)
--   
--   
--   This correctness comes at a small cost to performance, so use this
--   function sparingly.
--   
--   This function is a convenience for low-level pipes
--   implementers. You do not need to use observe if you stick to
--   the safe API.
observe :: Monad m => Proxy a' a b' b m r -> Proxy a' a b' b m r

-- | The empty type, used to close output ends
--   
--   When Data.Void is merged into base, this will change
--   to:
--   
--   
--   type X = Void
--   
data X

-- | Use closed to "handle" impossible outputs
closed :: X -> a
instance MonadPlus m => MonadPlus (Proxy a' a b' b m)
instance MonadPlus m => Alternative (Proxy a' a b' b m)
instance MonadError e m => MonadError e (Proxy a' a b' b m)
instance MonadWriter w m => MonadWriter w (Proxy a' a b' b m)
instance MonadState s m => MonadState s (Proxy a' a b' b m)
instance MonadReader r m => MonadReader r (Proxy a' a b' b m)
instance MonadIO m => MonadIO (Proxy a' a b' b m)
instance MFunctor (Proxy a' a b' b)
instance MonadTrans (Proxy a' a b' b)
instance Monad m => Monad (Proxy a' a b' b m)
instance Monad m => Applicative (Proxy a' a b' b m)
instance Monad m => Functor (Proxy a' a b' b m)

-- | The core functionality for the Proxy monad transformer
--   
--   Read Pipes.Tutorial if you want a beginners tutorial explaining
--   how to use this library. The documentation in this module targets more
--   advanced users who want to understand the theory behind this library.
--   
--   This module is not exported by default, and I recommend you use the
--   unidirectional operations exported by the Pipes module if you
--   can. You should only use this module if you require advanced features
--   like:
--   
--   
--   
- bidirectional communication, or:
--   
- push-based Pipes.
--   
module Pipes.Core

-- | A Proxy is a monad transformer that receives and sends
--   information on both an upstream and downstream interface.
--   
--   The type variables signify:
--   
--   
--   
- a' and a - The upstream interface, where
--   (a')s go out and (a)s come in
--   
- b' and b - The downstream interface, where
--   (b)s go out and (b')s come in
--   
- m  - The base monad
--   
- r  - The return value
--   
data Proxy a' a b' b m r

-- | Run a self-contained Effect, converting it back to the base
--   monad
runEffect :: Monad m => Effect m r -> m r

-- | Send a value of type a downstream and block waiting for a
--   reply of type a'
--   
--   respond is the identity of the respond category.
respond :: Monad m => a -> Proxy x' x a' a m a'

-- | Compose two unfolds, creating a new unfold
--   
--   
--   (f />/ g) x = f x //> g
--   
--   
--   (/>/) is the composition operator of the respond category.
(/>/) :: Monad m => (a -> Proxy x' x b' b m a') -> (b -> Proxy x' x c' c m b') -> (a -> Proxy x' x c' c m a')

-- | (p //> f) replaces each respond in p with
--   f.
--   
--   Point-ful version of (/>/)
(//>) :: Monad m => Proxy x' x b' b m a' -> (b -> Proxy x' x c' c m b') -> Proxy x' x c' c m a'

-- | Send a value of type a' upstream and block waiting for a
--   reply of type a
--   
--   request is the identity of the request category.
request :: Monad m => a' -> Proxy a' a y' y m a

-- | Compose two folds, creating a new fold
--   
--   
--   (f \>\ g) x = f >\\ g x
--   
--   
--   (\>\) is the composition operator of the request category.
(\>\) :: Monad m => (b' -> Proxy a' a y' y m b) -> (c' -> Proxy b' b y' y m c) -> (c' -> Proxy a' a y' y m c)

-- | (f >\\ p) replaces each request in p with
--   f.
--   
--   Point-ful version of (\>\)
(>\\) :: Monad m => (b' -> Proxy a' a y' y m b) -> Proxy b' b y' y m c -> Proxy a' a y' y m c

-- | Forward responses followed by requests
--   
--   
--   push = respond >=> request >=> push
--   
--   
--   push is the identity of the push category.
push :: Monad m => a -> Proxy a' a a' a m r

-- | Compose two proxies blocked while requesting data, creating a
--   new proxy blocked while requesting data
--   
--   
--   (f >~> g) x = f x >>~ g
--   
--   
--   (>~>) is the composition operator of the push category.
(>~>) :: Monad m => (_a -> Proxy a' a b' b m r) -> (b -> Proxy b' b c' c m r) -> (_a -> Proxy a' a c' c m r)

-- | (p >>~ f) pairs each respond in p with
--   an request in f.
--   
--   Point-ful version of (>~>)
(>>~) :: Monad m => Proxy a' a b' b m r -> (b -> Proxy b' b c' c m r) -> Proxy a' a c' c m r

-- | Forward requests followed by responses:
--   
--   
--   pull = request >=> respond >=> pull
--   
--   
--   pull is the identity of the pull category.
pull :: Monad m => a' -> Proxy a' a a' a m r

-- | Compose two proxies blocked in the middle of responding,
--   creating a new proxy blocked in the middle of responding
--   
--   
--   (f >+> g) x = f +>> g x
--   
--   
--   (>+>) is the composition operator of the pull category.
(>+>) :: Monad m => (b' -> Proxy a' a b' b m r) -> (_c' -> Proxy b' b c' c m r) -> (_c' -> Proxy a' a c' c m r)

-- | (f +>> p) pairs each request in p with
--   a respond in f.
--   
--   Point-ful version of (>+>)
(+>>) :: Monad m => (b' -> Proxy a' a b' b m r) -> Proxy b' b c' c m r -> Proxy a' a c' c m r

-- | Switch the upstream and downstream ends
reflect :: Monad m => Proxy a' a b' b m r -> Proxy b b' a a' m r

-- | The empty type, used to close output ends
--   
--   When Data.Void is merged into base, this will change
--   to:
--   
--   
--   type X = Void
--   
data X

-- | An effect in the base monad
--   
--   Effects neither await nor yield
type Effect = Proxy X () () X

-- | Producers can only yield
type Producer b = Proxy X () () b

-- | Pipes can both await and yield
type Pipe a b = Proxy () a () b

-- | Consumers can only await
type Consumer a = Proxy () a () X

-- | Client a' a sends requests of type a' and receives
--   responses of type a.
--   
--   Clients only request and never respond.
type Client a' a = Proxy a' a () X

-- | Server b' b receives requests of type b' and sends
--   responses of type b.
--   
--   Servers only respond and never request.
type Server b' b = Proxy X () b' b

-- | Like Effect, but with a polymorphic type
type Effect' m r = forall x' x y' y. Proxy x' x y' y m r

-- | Like Producer, but with a polymorphic type
type Producer' b m r = forall x' x. Proxy x' x () b m r

-- | Like Consumer, but with a polymorphic type
type Consumer' a m r = forall y' y. Proxy () a y' y m r

-- | Like Client, but with a polymorphic type
type Client' a' a m r = forall y' y. Proxy a' a y' y m r

-- | Like Server, but with a polymorphic type
type Server' b' b m r = forall x' x. Proxy x' x b' b m r

-- | Equivalent to (/>/) with the arguments flipped
(\<\) :: Monad m => (b -> Proxy x' x c' c m b') -> (a -> Proxy x' x b' b m a') -> (a -> Proxy x' x c' c m a')

-- | Equivalent to (\>\) with the arguments flipped
(/</) :: Monad m => (c' -> Proxy b' b x' x m c) -> (b' -> Proxy a' a x' x m b) -> (c' -> Proxy a' a x' x m c)

-- | Equivalent to (>~>) with the arguments flipped
(<~<) :: Monad m => (b -> Proxy b' b c' c m r) -> (a -> Proxy a' a b' b m r) -> (a -> Proxy a' a c' c m r)

-- | Equivalent to (>>~) with the arguments flipped
(~<<) :: Monad m => (b -> Proxy b' b c' c m r) -> Proxy a' a b' b m r -> Proxy a' a c' c m r

-- | Equivalent to (>+>) with the arguments flipped
(<+<) :: Monad m => (c' -> Proxy b' b c' c m r) -> (b' -> Proxy a' a b' b m r) -> (c' -> Proxy a' a c' c m r)

-- | Equivalent to (//>) with the arguments flipped
(<\\) :: Monad m => (b -> Proxy x' x c' c m b') -> Proxy x' x b' b m a' -> Proxy x' x c' c m a'

-- | Equivalent to (>\\) with the arguments flipped
(//<) :: Monad m => Proxy b' b y' y m c -> (b' -> Proxy a' a y' y m b) -> Proxy a' a y' y m c

-- | Equivalent to (+>>) with the arguments flipped
(<<+) :: Monad m => Proxy b' b c' c m r -> (b' -> Proxy a' a b' b m r) -> Proxy a' a c' c m r

-- | Use closed to "handle" impossible outputs
closed :: X -> a

-- | Many actions in base monad transformers cannot be automatically
--   lifted. These functions lift these remaining actions so that
--   they work in the Proxy monad transformer.
--   
--   See the mini-tutorial at the bottom of this module for example code
--   and typical use cases where this module will come in handy.
module Pipes.Lift

-- | Distribute Proxy over a monad transformer
distribute :: (Monad m, MonadTrans t, MFunctor t, Monad (t m), Monad (t (Proxy a' a b' b m))) => Proxy a' a b' b (t m) r -> t (Proxy a' a b' b m) r

-- | Wrap the base monad in ErrorT
errorP :: (Monad m, Error e) => Proxy a' a b' b m (Either e r) -> Proxy a' a b' b (ErrorT e m) r

-- | Run ErrorT in the base monad
runErrorP :: (Monad m, Error e) => Proxy a' a b' b (ErrorT e m) r -> Proxy a' a b' b m (Either e r)

-- | Catch an error in the base monad
catchError :: (Monad m, Error e) => Proxy a' a b' b (ErrorT e m) r -> (e -> Proxy a' a b' b (ErrorT e m) r) -> Proxy a' a b' b (ErrorT e m) r

-- | Catch an error using a catch function for the base monad
liftCatchError :: Monad m => (m (Proxy a' a b' b m r) -> (e -> m (Proxy a' a b' b m r)) -> m (Proxy a' a b' b m r)) -> (Proxy a' a b' b m r -> (e -> Proxy a' a b' b m r) -> Proxy a' a b' b m r)

-- | Wrap the base monad in MaybeT
maybeP :: Monad m => Proxy a' a b' b m (Maybe r) -> Proxy a' a b' b (MaybeT m) r

-- | Run MaybeT in the base monad
runMaybeP :: Monad m => Proxy a' a b' b (MaybeT m) r -> Proxy a' a b' b m (Maybe r)

-- | Wrap the base monad in ReaderT
readerP :: Monad m => (i -> Proxy a' a b' b m r) -> Proxy a' a b' b (ReaderT i m) r

-- | Run ReaderT in the base monad
runReaderP :: Monad m => i -> Proxy a' a b' b (ReaderT i m) r -> Proxy a' a b' b m r

-- | Wrap the base monad in StateT
stateP :: Monad m => (s -> Proxy a' a b' b m (r, s)) -> Proxy a' a b' b (StateT s m) r

-- | Run StateT in the base monad
runStateP :: Monad m => s -> Proxy a' a b' b (StateT s m) r -> Proxy a' a b' b m (r, s)

-- | Evaluate StateT in the base monad
evalStateP :: Monad m => s -> Proxy a' a b' b (StateT s m) r -> Proxy a' a b' b m r

-- | Execute StateT in the base monad
execStateP :: Monad m => s -> Proxy a' a b' b (StateT s m) r -> Proxy a' a b' b m s

-- | Wrap the base monad in WriterT
writerP :: (Monad m, Monoid w) => Proxy a' a b' b m (r, w) -> Proxy a' a b' b (WriterT w m) r

-- | Run WriterT in the base monad
runWriterP :: (Monad m, Monoid w) => Proxy a' a b' b (WriterT w m) r -> Proxy a' a b' b m (r, w)

-- | Execute WriterT in the base monad
execWriterP :: (Monad m, Monoid w) => Proxy a' a b' b (WriterT w m) r -> Proxy a' a b' b m w

-- | Wrap the base monad in RWST
rwsP :: (Monad m, Monoid w) => (i -> s -> Proxy a' a b' b m (r, s, w)) -> Proxy a' a b' b (RWST i w s m) r

-- | Run RWST in the base monad
runRWSP :: (Monad m, Monoid w) => r -> s -> Proxy a' a b' b (RWST r w s m) d -> Proxy a' a b' b m (d, s, w)

-- | Evaluate RWST in the base monad
evalRWSP :: (Monad m, Monoid w) => r -> s -> Proxy a' a b' b (RWST r w s m) d -> Proxy a' a b' b m (d, w)

-- | Execute RWST in the base monad
execRWSP :: (Monad m, Monoid w) => r -> s -> Proxy a' a b' b (RWST r w s m) d -> Proxy a' a b' b m (s, w)

-- | This module is the recommended entry point to the pipes
--   library.
--   
--   Read Pipes.Tutorial if you want a tutorial explaining how to
--   use this library.
module Pipes

-- | A Proxy is a monad transformer that receives and sends
--   information on both an upstream and downstream interface.
--   
--   The type variables signify:
--   
--   
--   
- a' and a - The upstream interface, where
--   (a')s go out and (a)s come in
--   
- b' and b - The downstream interface, where
--   (b)s go out and (b')s come in
--   
- m  - The base monad
--   
- r  - The return value
--   
data Proxy a' a b' b m r

-- | The empty type, used to close output ends
--   
--   When Data.Void is merged into base, this will change
--   to:
--   
--   
--   type X = Void
--   
data X

-- | An effect in the base monad
--   
--   Effects neither await nor yield
type Effect = Proxy X () () X

-- | Like Effect, but with a polymorphic type
type Effect' m r = forall x' x y' y. Proxy x' x y' y m r

-- | Run a self-contained Effect, converting it back to the base
--   monad
runEffect :: Monad m => Effect m r -> m r

-- | Producers can only yield
type Producer b = Proxy X () () b

-- | Like Producer, but with a polymorphic type
type Producer' b m r = forall x' x. Proxy x' x () b m r

-- | Produce a value
--   
--   
--   yield :: Monad m => a -> Pipe x a m ()
--   
yield :: Monad m => a -> Producer' a m ()

-- | (for p body) loops over p replacing each
--   yield with body.
--   
--   
--   for :: Monad m => Producer b m r -> (b -> Effect       m ()) -> Effect       m r
--   for :: Monad m => Producer b m r -> (b -> Producer   c m ()) -> Producer   c m r
--   for :: Monad m => Pipe   x b m r -> (b -> Consumer x   m ()) -> Consumer x   m r
--   for :: Monad m => Pipe   x b m r -> (b -> Pipe     x c m ()) -> Pipe     x c m r
--   
for :: Monad m => Proxy x' x b' b m a' -> (b -> Proxy x' x c' c m b') -> Proxy x' x c' c m a'

-- | Compose loop bodies
--   
--   
--   (~>) :: Monad m => (a -> Producer b m r) -> (b -> Effect       m ()) -> (a -> Effect       m r)
--   (~>) :: Monad m => (a -> Producer b m r) -> (b -> Producer   c m ()) -> (a -> Producer   c m r)
--   (~>) :: Monad m => (a -> Pipe   x b m r) -> (b -> Consumer x   m ()) -> (a -> Consumer x   m r)
--   (~>) :: Monad m => (a -> Pipe   x b m r) -> (b -> Pipe     x c m ()) -> (a -> Pipe     x c m r)
--   
(~>) :: Monad m => (a -> Proxy x' x b' b m a') -> (b -> Proxy x' x c' c m b') -> (a -> Proxy x' x c' c m a')

-- | (~>) with the arguments flipped
(<~) :: Monad m => (b -> Proxy x' x c' c m b') -> (a -> Proxy x' x b' b m a') -> (a -> Proxy x' x c' c m a')

-- | Consumers can only await
type Consumer a = Proxy () a () X

-- | Like Consumer, but with a polymorphic type
type Consumer' a m r = forall y' y. Proxy () a y' y m r

-- | Consume a value
--   
--   
--   await :: Monad m => Pipe a y m a
--   
await :: Monad m => Consumer' a m a

-- | (draw >~ p) loops over p replacing each
--   await with draw
--   
--   
--   (>~) :: Monad m => Effect       m b -> Consumer b   m c -> Effect       m c
--   (>~) :: Monad m => Consumer a   m b -> Consumer b   m c -> Consumer a   m c
--   (>~) :: Monad m => Producer   y m b -> Pipe     b y m c -> Producer   y m c
--   (>~) :: Monad m => Pipe     a y m b -> Pipe     b y m c -> Pipe     a y m c
--   
(>~) :: Monad m => Proxy a' a y' y m b -> Proxy () b y' y m c -> Proxy a' a y' y m c

-- | (>~) with the arguments flipped
(~<) :: Monad m => Proxy () b y' y m c -> Proxy a' a y' y m b -> Proxy a' a y' y m c

-- | Pipes can both await and yield
type Pipe a b = Proxy () a () b

-- | The identity Pipe, analogous to the Unix cat program
cat :: Monad m => Pipe a a m r

-- | Pipe composition, analogous to the Unix pipe operator
--   
--   
--   (>->) :: Monad m => Producer b m r -> Consumer b   m r -> Effect       m r
--   (>->) :: Monad m => Producer b m r -> Pipe     b c m r -> Producer   c m r
--   (>->) :: Monad m => Pipe   a b m r -> Consumer b   m r -> Consumer a   m r
--   (>->) :: Monad m => Pipe   a b m r -> Pipe     b c m r -> Pipe     a c m r
--   
(>->) :: Monad m => Proxy a' a () b m r -> Proxy () b c' c m r -> Proxy a' a c' c m r

-- | (>->) with the arguments flipped
(<-<) :: Monad m => Proxy () b c' c m r -> Proxy a' a () b m r -> Proxy a' a c' c m r

-- | The list monad transformer, which extends a monad with non-determinism
--   
--   return corresponds to yield, yielding a single value
--   
--   (>>=) corresponds to for, calling the second
--   computation once for each time the first computation yields.
newtype ListT m a
Select :: Producer a m () -> ListT m a
enumerate :: ListT m a -> Producer a m ()

-- | Enumerable generalizes Foldable, converting effectful
--   containers to ListTs.
class Enumerable t
toListT :: (Enumerable t, Monad m) => t m a -> ListT m a

-- | Consume the first value from a Producer
--   
--   next either fails with a Left if the Producer
--   terminates or succeeds with a Right providing the next value
--   and the remainder of the Producer.
next :: Monad m => Producer a m r -> m (Either r (a, Producer a m r))

-- | Convert a Foldable to a Producer
each :: (Monad m, Foldable f) => f a -> Producer' a m ()

-- | Convert an Enumerable to a Producer
every :: (Monad m, Enumerable t) => t m a -> Producer' a m ()

-- | Discards a value
discard :: Monad m => a -> m ()
instance Enumerable (ErrorT e)
instance Enumerable MaybeT
instance Enumerable IdentityT
instance Enumerable ListT
instance MonadError e m => MonadError e (ListT m)
instance MonadReader i m => MonadReader i (ListT m)
instance MonadWriter w m => MonadWriter w (ListT m)
instance MonadState s m => MonadState s (ListT m)
instance Monad m => Monoid (ListT m a)
instance MFunctor ListT
instance Monad m => MonadPlus (ListT m)
instance Monad m => Alternative (ListT m)
instance MonadIO m => MonadIO (ListT m)
instance MonadTrans ListT
instance Monad m => Monad (ListT m)
instance Monad m => Applicative (ListT m)
instance Monad m => Functor (ListT m)

-- | General purpose utilities
--   
--   The names in this module clash heavily with the Haskell Prelude, so I
--   recommend the following import scheme:
--   
--   
--   import Pipes
--   import qualified Pipes.Prelude as P  -- or use any other qualifier you prefer
--   
--   
--   Note that String-based IO is inefficient. The
--   String-based utilities in this module exist only for simple
--   demonstrations without incurring a dependency on the text
--   package.
--   
--   Also, stdinLn and stdoutLn remove and add newlines,
--   respectively. This behavior is intended to simplify examples. The
--   corresponding stdin and stdout utilities from
--   pipes-bytestring and pipes-text preserve newlines.
module Pipes.Prelude

-- | Read Strings from stdin using getLine
--   
--   Terminates on end of input
stdinLn :: MonadIO m => Producer' String m ()

-- | read values from stdin, ignoring failed parses
readLn :: (MonadIO m, Read a) => Producer' a m ()

-- | Read Strings from a Handle using hGetLine
--   
--   Terminates on end of input
fromHandle :: MonadIO m => Handle -> Producer' String m ()

-- | Repeat a monadic action a fixed number of times, yielding each
--   result
replicateM :: Monad m => Int -> m a -> Producer a m ()

-- | Write Strings to stdout using putStrLn
--   
--   Unlike toHandle, stdoutLn gracefully terminates on a
--   broken output pipe
stdoutLn :: MonadIO m => Consumer' String m ()

-- | print values to stdout
print :: (MonadIO m, Show a) => Consumer' a m r

-- | Write Strings to a Handle using hPutStrLn
toHandle :: MonadIO m => Handle -> Consumer' String m r

-- | discard all incoming values
drain :: Monad m => Consumer' a m r

-- | Apply a function to all values flowing downstream
map :: Monad m => (a -> b) -> Pipe a b m r

-- | Apply a monadic function to all values flowing downstream
mapM :: Monad m => (a -> m b) -> Pipe a b m r

-- | Convert a stream of actions to a stream of values
sequence :: Monad m => Pipe (m a) a m r

-- | Apply a function to all values flowing downstream, and forward each
--   element of the result.
mapFoldable :: (Monad m, Foldable t) => (a -> t b) -> Pipe a b m r

-- | (filter predicate) only forwards values that satisfy the
--   predicate.
filter :: Monad m => (a -> Bool) -> Pipe a a m r

-- | (filterM predicate) only forwards values that satisfy the
--   monadic predicate
filterM :: Monad m => (a -> m Bool) -> Pipe a a m r

-- | (take n) only allows n values to pass through
take :: Monad m => Int -> Pipe a a m ()

-- | (takeWhile p) allows values to pass downstream so long as
--   they satisfy the predicate p.
takeWhile :: Monad m => (a -> Bool) -> Pipe a a m ()

-- | (drop n) discards n values going downstream
drop :: Monad m => Int -> Pipe a a m r

-- | (dropWhile p) discards values going downstream until one
--   violates the predicate p.
dropWhile :: Monad m => (a -> Bool) -> Pipe a a m r

-- | Flatten all Foldable elements flowing downstream
concat :: (Monad m, Foldable f) => Pipe (f a) a m r

-- | Outputs the indices of all elements that match the given element
elemIndices :: (Monad m, Eq a) => a -> Pipe a Int m r

-- | Outputs the indices of all elements that satisfied the predicate
findIndices :: Monad m => (a -> Bool) -> Pipe a Int m r

-- | Strict left scan
scan :: Monad m => (x -> a -> x) -> x -> (x -> b) -> Pipe a b m r

-- | Strict, monadic left scan
scanM :: Monad m => (x -> a -> m x) -> m x -> (x -> m b) -> Pipe a b m r

-- | Apply an action to all values flowing downstream
chain :: Monad m => (a -> m ()) -> Pipe a a m r

-- | Parse Readable values, only forwarding the value if the parse
--   succeeds
read :: (Monad m, Read a) => Pipe String a m r

-- | Convert Showable values to Strings
show :: (Monad m, Show a) => Pipe a String m r

-- | Strict fold of the elements of a Producer
fold :: Monad m => (x -> a -> x) -> x -> (x -> b) -> Producer a m () -> m b

-- | Strict, monadic fold of the elements of a Producer
foldM :: Monad m => (x -> a -> m x) -> m x -> (x -> m b) -> Producer a m () -> m b

-- | (all predicate p) determines whether all the elements of
--   p satisfy the predicate.
all :: Monad m => (a -> Bool) -> Producer a m () -> m Bool

-- | (any predicate p) determines whether any element of
--   p satisfies the predicate.
any :: Monad m => (a -> Bool) -> Producer a m () -> m Bool

-- | Determines whether all elements are True
and :: Monad m => Producer Bool m () -> m Bool

-- | Determines whether any element is True
or :: Monad m => Producer Bool m () -> m Bool

-- | (elem a p) returns True if p has an element
--   equal to a, False otherwise
elem :: (Monad m, Eq a) => a -> Producer a m () -> m Bool

-- | (notElem a) returns False if p has an element
--   equal to a, True otherwise
notElem :: (Monad m, Eq a) => a -> Producer a m () -> m Bool

-- | Find the first element of a Producer that satisfies the
--   predicate
find :: Monad m => (a -> Bool) -> Producer a m () -> m (Maybe a)

-- | Find the index of the first element of a Producer that
--   satisfies the predicate
findIndex :: Monad m => (a -> Bool) -> Producer a m () -> m (Maybe Int)

-- | Retrieve the first element from a Producer
head :: Monad m => Producer a m () -> m (Maybe a)

-- | Index into a Producer
index :: Monad m => Int -> Producer a m () -> m (Maybe a)

-- | Retrieve the last element from a Producer
last :: Monad m => Producer a m () -> m (Maybe a)

-- | Count the number of elements in a Producer
length :: Monad m => Producer a m () -> m Int

-- | Find the maximum element of a Producer
maximum :: (Monad m, Ord a) => Producer a m () -> m (Maybe a)

-- | Find the minimum element of a Producer
minimum :: (Monad m, Ord a) => Producer a m () -> m (Maybe a)

-- | Determine if a Producer is empty
null :: Monad m => Producer a m () -> m Bool

-- | Compute the sum of the elements of a Producer
sum :: (Monad m, Num a) => Producer a m () -> m a

-- | Compute the product of the elements of a Producer
product :: (Monad m, Num a) => Producer a m () -> m a

-- | Convert a pure Producer into a list
toList :: Producer a Identity () -> [a]

-- | Convert an effectful Producer into a list
--   
--   Note: toListM is not an idiomatic use of pipes, but I
--   provide it for simple testing purposes. Idiomatic pipes style
--   consumes the elements immediately as they are generated instead of
--   loading all elements into memory.
toListM :: Monad m => Producer a m () -> m [a]

-- | Zip two Producers
zip :: Monad m => (Producer a m r) -> (Producer b m r) -> (Producer' (a, b) m r)

-- | Zip two Producers using the provided combining function
zipWith :: Monad m => (a -> b -> c) -> (Producer a m r) -> (Producer b m r) -> (Producer' c m r)

-- | Transform a Consumer to a Pipe that reforwards all
--   values further downstream
tee :: Monad m => Consumer a m r -> Pipe a a m r

-- | Transform a unidirectional Pipe to a bidirectional Proxy
--   
--   
--   generalize (f >-> g) = generalize f >+> generalize g
--   
--   generalize cat = pull
--   
generalize :: Monad m => Pipe a b m r -> x -> Proxy x a x b m r

-- | Conventional Haskell stream programming forces you to choose only two
--   of the following three features:
--   
--   
--   
- Effects
--   
- Streaming
--   
- Composability
--   
--   
--   If you sacrifice Effects you get Haskell's pure and lazy lists,
--   which you can transform using composable functions in constant space,
--   but without interleaving effects.
--   
--   If you sacrifice Streaming you get mapM, forM and
--   "ListT done wrong", which are composable and effectful, but do not
--   return a single result until the whole list has first been processed
--   and loaded into memory.
--   
--   If you sacrifice Composability you write a tightly coupled
--   read, transform, and write loop in IO, which is streaming and
--   effectful, but is not modular or separable.
--   
--   pipes gives you all three features: effectful, streaming, and
--   composable programming. pipes also provides a wide variety of
--   stream programming abstractions which are all subsets of a single
--   unified machinery:
--   
--   
--   
- effectful Producers (like generators),
--   
- effectful Consumers (like iteratees),
--   
- effectful Pipes (like Unix pipes), and:
--   
- ListT done right.
--   
--   
--   All of these are connectable and you can combine them together in
--   clever and unexpected ways because they all share the same underlying
--   type.
--   
--   pipes requires a basic understanding of monad transformers,
--   which you can learn about by reading either:
--   
--   
--   
- the paper "Monad Transformers - Step by Step",
--   
- chapter 18 of "Real World Haskell" on monad transformers, or:
--   
- the documentation of the transformers library.
--   
--   
--   If you want a Quick Start guide to pipes, read the
--   documentation in Pipes.Prelude from top to bottom.
--   
--   This tutorial is more extensive and explains the pipes API in
--   greater detail and illustrates several idioms.
module Pipes.Tutorial
