(i      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Trustworthy*The empty type, used to close output ends When  Data.Void is merged into base, this will change to:  type X = Void A D 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  is like , but faster. LThis is labeled as unsafe because you will break the monad transformer laws Q 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. ?The monad transformer laws are correct when viewed through the   function:    ( ( r)) =  ( r)   ( (m  f)) =  ( m    f) LThis 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  if you stick to the safe API. Use  to "handle" impossible outputs    Trustworthy! Like , but with a polymorphic type Like , but with a polymorphic type Like , but with a polymorphic type Like , but with a polymorphic type Like , but with a polymorphic type Server b' b receives requests of type b' and sends responses of type  b. s only  and never . Client a' a sends requests of type a' and receives responses of  type a. s only  and never .  s can only   s can both  and   s can only  An effect in the base monad  s neither  nor  Run a self-contained ', converting it back to the base monad Send a value of type a2 downstream and block waiting for a reply of type  a' * is the identity of the respond category. +Compose two unfolds, creating a new unfold   (f  g) x = f x  g (7) is the composition operator of the respond category. (p //> f) replaces each  in p with f. Point-ful version of () Send a value of type a'0 upstream and block waiting for a reply of type a * is the identity of the request category. 'Compose two folds, creating a new fold   (f  g) x = f  g x (7) is the composition operator of the request category. (f >\\ p) replaces each  in p with f. Point-ful version of () 'Forward responses followed by requests    =        ' is the identity of the push category. "Compose two proxies blocked while ing data, creating a new proxy  blocked while  ing data   (f  g) x = f x  g (4) is the composition operator of the push category.  (p >>~ f) pairs each  in p with an  in f. Point-ful version of () (Forward requests followed by responses:    =        ' is the identity of the pull category. -Compose two proxies blocked in the middle of ing, creating a new # proxy blocked in the middle of ing   (f  g) x = f   g x (4) is the composition operator of the pull category.  (f +>> p) pairs each  in p with a  in f. Point-ful version of () !(Switch the upstream and downstream ends "Equivalent to () with the arguments flipped #Equivalent to () with the arguments flipped $Equivalent to () with the arguments flipped %Equivalent to () with the arguments flipped &Equivalent to () with the arguments flipped 'Equivalent to () with the arguments flipped (Equivalent to () with the arguments flipped )Equivalent to ( ) with the arguments flipped !  !"#$%&'()$  !"#$%&'()$ ! "#$(%&')!  !"#$%&'() Safe-Inferred* Distribute  over a monad transformer +Wrap the base monad in  ,Run  in the base monad -!Catch an error in the base monad .9Catch an error using a catch function for the base monad /Wrap the base monad in  0Run  in the base monad 1Wrap the base monad in  2Run  in the base monad 3Wrap the base monad in  4Run  in the base monad 5 Evaluate  in the base monad 6Execute  in the base monad 7Wrap the base monad in  8Run  in the base monad 9Execute  in the base monad :Wrap the base monad in  ;Run  in the base monad < Evaluate  in the base monad =Execute  in the base monad *+,-./0123456789:;<=*+,-./0123456789:;<=*+,-./0123456789:;<=*+,-./0123456789:;<= Trustworthy>> generalizes , converting effectful  containers to @s.  Instances of > must satisfy these two laws:   toListT (return r) = return r  + toListT $ do x <- m = do x <- toListT m * f x toListT (f x) In other words, ? is monad morphism. @GThe list monad transformer, which extends a monad with non-determinism  corresponds to C, yielding a single value () corresponds to D/, calling the second computation once for each  time the first computation Cs. CProduce a value  C ::  m => a ->  x a m () D (for p body) loops over p replacing each C with body.   D ::  m =>  b m r -> (b ->  m ()) ->  m r D ::  m =>  b m r -> (b ->  c m ()) ->  c m r D ::  m =>  x b m r -> (b ->  x m ()) ->  x m r D ::  m =>  x b m r -> (b ->  x c m ()) ->  x c m r 5The following diagrams show the flow of information:   ( .---> b  / |  +-----------+ /3 +-----|-----+ +---------------+  | | /4 | v | | |  | | /5 | | | | x ==> p ==> b ---'' x ==> body ==> c = x ==> D p body ==> c P | | | | | | P | | | | | | | | | P +-----|-----+ +-----|-----+ +-------|-------+ H v v v H r () r >For a more complete diagram including bidirectional flow, see Pipes.Core#respond-diagram. ECompose loop bodies   (E) ::  m => (a ->  b m r) -> (b ->  m ()) -> (a ->  m r) (E) ::  m => (a ->  b m r) -> (b ->  c m ()) -> (a ->  c m r) (E) ::  m => (a ->  x b m r) -> (b ->  x m ()) -> (a ->  x m r) (E) ::  m => (a ->  x b m r) -> (b ->  x c m ()) -> (a ->  x c m r) 5The following diagrams show the flow of information:   G a .---> b a  | /) | |  +-----|-----+ /1 +-----|-----+ +------|------+  | v | /2 | v | | v |  | | /3 | | | | x ==> f ==> b ---'+ x ==> g ==> c = x ==> f E g ==> c N | | | | | | N | | | | | | | | | N +-----|-----+ +-----|-----+ +------|------+ G v v v G r () r >For a more complete diagram including bidirectional flow, see Pipes.Core#respond-diagram. F(E) with the arguments flipped GConsume a value  G ::  m =>  a y m a H (draw >~ p) loops over p replacing each G with draw   (H) ::  m =>  m b ->  b m c ->  m c (H) ::  m =>  a m b ->  b m c ->  a m c (H) ::  m =>  y m b ->  b y m c ->  y m c (H) ::  m =>  a y m b ->  b y m c ->  a y m c 5The following diagrams show the flow of information:    L+-----------+ +-----------+ +-------------+ O | | | | | | O | | | | | | Fa ==> f ==> y .---> b ==> g ==> y = a ==> f H g ==> y  | | /9 | | | |  | | | /: | | | | | |  +-----|-----+ /; +-----|-----+ +------|------+  v /5 v v  b ----'6 c c >For a more complete diagram including bidirectional flow, see Pipes.Core#request-diagram. I(H) with the arguments flipped J The identity , analogous to the Unix cat program K2 composition, analogous to the Unix pipe operator   (K) ::  m =>  b m r ->  b m r ->  m r (K) ::  m =>  b m r ->  b c m r ->  c m r (K) ::  m =>  a b m r ->  b m r ->  a m r (K) ::  m =>  a b m r ->  b c m r ->  a c m r 5The following diagrams show the flow of information:    @+-----------+ +-----------+ +-------------+ C | | | | | | C | | | | | | 9a ==> f ==> b ==> g ==> c = a ==> f K g ==> c C | | | | | | C | | | | | | | | | C +-----|-----+ +-----|-----+ +------|------+ < v v v < r r r >For a more complete diagram including bidirectional flow, see Pipes.Core#pull-diagram. LRun a self-contained @ computation MConsume the first value from a  M either fails with a  if the  terminates or succeeds  with a 3 providing the next value and the remainder of the . N Convert a  to a  O Convert an > to a  PDiscards a value Q(K) with the arguments flipped %>?@ABCDEFGHIJKLMNOPQ) >?@ABCDEFGHIJKLMNOPQ  CDEF GHIJKQ@ABL>?MNOP">?@ABCDEFGHIJKLMNOPQ Trustworthy=RRead s from  using  Terminates on end of input Sn values from , ignoring failed parses TRead  s from a  using  Terminates on end of input U&Repeat a monadic action indefinitely, Cing each result V1Repeat a monadic action a fixed number of times, Cing each result " replicateM 0 x = return ()  H replicateM (m + n) x = replicateM m x >> replicateM n x -- 0 <= {m,n} WWrite s to  using  Unlike [, W/ gracefully terminates on a broken output pipe XWrite s to  using  HThis does not handle a broken output pipe, but has a polymorphic return  value Y,Consume all values using a monadic function ZZ values to  [Write s to a  using  \P all incoming values ]2Apply a function to all values flowing downstream  map id = cat   map (g . f) = map f >-> map g ^:Apply a monadic function to all values flowing downstream  mapM return = cat  $ mapM (f >=> g) = mapM f >-> mapM g _2Convert a stream of actions to a stream of values `7Apply a function to all values flowing downstream, and ) forward each element of the result. a(filter predicate)2 only forwards values that satisfy the predicate.  filter (pure True) = cat  6 filter (liftA2 (&&) p1 p2) = filter p1 >-> filter p2 b(filterM predicate)/ only forwards values that satisfy the monadic  predicate " filterM (pure (pure True)) = cat  B filterM (liftA2 (liftA2 (&&)) p1 p2) = filterM p1 >-> filterM p2 c(take n) only allows n values to pass through   take 0 = return ()  ! take (m + n) = take m >> take n  take <infinity> = cat  $ take (min m n) = take m >-> take n d (takeWhile p): allows values to pass downstream so long as they satisfy  the predicate p.  takeWhile (pure True) = cat  ? takeWhile (liftA2 (&&) p1 p2) = takeWhile p1 >-> takeWhile p2 e (takeWhile' p): is a version of takeWhile that returns the value failing  the predicate.  takeWhile' (pure True) = cat  B takeWhile' (liftA2 (&&) p1 p2) = takeWhile' p1 >-> takeWhile' p2 f(drop n) discards n values going downstream  drop 0 = cat  " drop (m + n) = drop m >-> drop n g (dropWhile p)9 discards values going downstream until one violates the  predicate p.  dropWhile (pure False) = cat  ? dropWhile (liftA2 (||) p1 p2) = dropWhile p1 >-> dropWhile p2 h Flatten all  elements flowing downstream iAOutputs the indices of all elements that match the given element jAOutputs the indices of all elements that satisfied the predicate kStrict left scan B Control.Foldl.purely scan :: Monad m => Fold a b -> Pipe a b m r lStrict, monadic left scan G Control.Foldl.impurely scan :: Monad m => FoldM a m b -> Pipe a b m r m1Apply an action to all values flowing downstream  chain (pure (return ())) = cat  3 chain (liftA2 (>>) m1 m2) = chain m1 >-> chain m2 nParse =able values, only forwarding the value if the parse succeeds oConvert able values to s p/Evaluate all values flowing downstream to WHNF q Create a  from a @ transformation ( loop (k1 >=> k2) = loop k1 >-> loop k2   loop return = cat r!Strict fold of the elements of a  L Control.Foldl.purely fold :: Monad m => Fold a b -> Producer a m () -> m b s!Strict fold of the elements of a ! that preserves the return value Q Control.Foldl.purely fold' :: Monad m => Fold a b -> Producer a m r -> m (b, r) t*Strict, monadic fold of the elements of a  P Control.Foldl.impurely foldM :: Monad m => FoldM a b -> Producer a m () -> m b u*Strict, monadic fold of the elements of a  U Control.Foldl.impurely foldM' :: Monad m => FoldM a b -> Producer a m r -> m (b, r) v(all predicate p)( determines whether all the elements of p satisfy the  predicate. w(any predicate p)# determines whether any element of p satisfies the  predicate. x$Determines whether all elements are  y"Determines whether any element is  z (elem a p) returns  if p has an element equal to a,   otherwise { (notElem a) returns  if p has an element equal to a,   otherwise |Find the first element of a  that satisfies the predicate })Find the index of the first element of a  that satisfies the  predicate ~"Retrieve the first element from a   Index into a  !Retrieve the last element from a  "Count the number of elements in a  Find the maximum element of a  Find the minimum element of a  Determine if a  is empty %Compute the sum of the elements of a  )Compute the product of the elements of a  Convert a pure  into a list Convert an effectful  into a list Note:  is not an idiomatic use of pipes, but I provide it for ( simple testing purposes. Idiomatic pipes style consumes the elements K immediately as they are generated instead of loading all elements into  memory. Convert an effectful ( into a list alongside the return value Note:  is not an idiomatic use of pipes, but I provide it for ( simple testing purposes. Idiomatic pipes style consumes the elements K immediately as they are generated instead of loading all elements into  memory. Zip two s Zip two (s using the provided combining function  Transform a  to a $ that reforwards all values further  downstream Transform a unidirectional  to a bidirectional  6 generalize (f >-> g) = generalize f >+> generalize g   generalize cat = pull The natural unfold into a " with a step function and a seed  unfoldr next = id =RSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~=RSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~=RSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~=RSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  Safe-Inferred    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  pipes-4.1.6Pipes.Internal Pipes.Core Pipes.LiftPipes Pipes.Preludeawaityield Control.Monad>=>Pipes.TutorialXProxyPureMRespondRequest unsafeHoistobserveclosedClient'Server' Consumer' Producer'Effect'ServerClientConsumerPipeProducerEffect runEffectrespond/>///>request\>\>\\push>~>>>~pull>+>+>>reflect\<\/<~>~~<cat>->runListTnexteacheverydiscard<-<stdinLnreadLn fromHandlerepeatM replicateMstdoutLn stdoutLn'mapM_printtoHandledrainmapmapMsequence mapFoldablefilterfilterMtake takeWhile takeWhile'drop dropWhileconcat elemIndices findIndicesscanscanMchainreadshowseqloopfoldfold'foldMfoldM'allanyandorelemnotElemfind findIndexheadindexlastlengthmaximumminimumnullsumproducttoListtoListMtoListM'zipzipWithtee generalizeunfoldr mmorph-1.0.4Control.Monad.Morphhoisttransformers-0.3.0.0Control.Monad.Trans.ClassliftbaseGHC.Basereturn>>=._bind$fMonadPlusProxy$fAlternativeProxy$fMonadErroreProxy$fMonadWriterwProxy$fMonadStatesProxy$fMonadReaderrProxy$fMonadIOProxy $fMMonadProxy$fMFunctorProxy$fMonadTransProxy $fMonoidProxy $fMonadProxy$fApplicativeProxy$fFunctorProxyControl.Monad.Trans.ErrorErrorTControl.Monad.Trans.MaybeMaybeTControl.Monad.Trans.ReaderReaderT Control.Monad.Trans.State.StrictStateT!Control.Monad.Trans.Writer.StrictWriterTControl.Monad.Trans.RWS.StrictRWST Data.FoldableFoldableMonad Data.EitherLeftRight$fEnumerableErrorT$fEnumerableMaybeT$fEnumerableIdentityT$fEnumerableListT$fMonadErroreListT$fMonadReaderiListT$fMonadWriterwListT$fMonadStatesListT $fMonoidListT$fMFunctorListT$fMonadPlusListT$fAlternativeListT$fMonadIOListT$fMonadTransListT $fMonadListT$fApplicativeListT$fFunctorListT MonadPlusvoidmplusmzeroMFunctor MonadTransControl.Monad.IO.ClassMonadIOliftIOStringGHC.IO.Handle.FDstdin System.IOgetLineGHC.IO.Handle.TypesHandleGHC.IO.Handle.TexthGetLinestdoutputStrLn hPutStrLnGHC.ReadReadGHC.ShowShowghc-prim GHC.TypesTrueFalse