\ GO      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr s t u v w x y z { | } ~        !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNSafeD The empty type, denoting a 'C 'losed endA self-contained , ready to be run by  runSessions never request or respond.  Client a' a sends requests of type a'$ and receives responses of type a.s never respond.  Server b' b receives requests of type b'! and sends responses of type b.s never request. A & that consumes values flowing upstreams never request. A & that produces values flowing upstreams never respond. A   where everything flows upstreamA   that consumes valuess never respond. A   that produces valuess never request. A unidirectional Proxy. O   O Safe  s form a P/ instance when you rearrange the type variables 1A self-contained pipeline that is ready to be runA pipe that consumes valuesA pipe that produces valuesThe base type for pipesa1 - The type of input received from upstream pipesb3 - The type of output delivered to downstream pipesm - The base monadr - The type of the return valueWait for input from upstream./ blocks until input is available from upstream.Deliver output downstream.7 restores control back upstream and binds its value to .#Convert a pure function into a pipe 4pipe f = forever $ do x <- await yield (f x)Corresponds to (Q)/(R) from Control.CategoryCorresponds to (S) from Control.CategoryCorresponds to T from Control.CategoryRun the : monad transformer, converting it back into the base monad        88SafeOT!#A functor in the category of monads 0hoist f . hoist g = hoist (f . g) hoist id = idIf f is a monad morphism, then hoist f' is a monad morphism, meaning that hoistK f = (hoist f .). defines a functor between Kleisli categories: LhoistK f k1 >=> hoistK f k2 = hoistK f (k1 >=> k2) hoistK f return = return"Lift a monad morphism from m to n$ into a monad morphism from (t m) to (t n) ##Convenience function equivalent to  (hoist f .)$Lift the base monad raise = hoist lift%Lift the base monad of a 'K 'leisli arrow raiseK = hoistK lift !"#Monad morphism Kleisli arrow$%&'()*+,-!"#$%!"#$% !"#$%&'()*+,-SafeOT.The  (MonadIOP p)6 constraint is equivalent to the following constraint: D(forall a' a b' b m . (MonadIO m) => MonadIO (p a' a b' b m)) => ...0The (MonadPlusP p)6 constraint is equivalent to the following constraint: D(forall a' a b' b m . (Monad m) => MonadPlus (p a' a b' b m)) => ...32Two extra Proxy categories of theoretical interest4f \>\ g replaces all 7s in g with f.5f />/ g replaces all 8s in f with g.6The core API for the pipes libraryYou should only use 7, 8, and (9)I only provide (:f) for theoretical symmetry, and the remaining methods just implement internal type class plumbing.77: input from upstream, passing an argument with the request request a' passes a'^ as a parameter to upstream that upstream may use to decide what response to return. 7/ binds the upstream's response of type a to its own return value. 88B with an output for downstream and bind downstream's next 7 respond b satisfies a downstream 7 by supplying the value b . 8 blocks until downstream 75s a new value and binds the argument of type b' from the next 7 as its return value. 9!Compose two proxies blocked on a 8., generating a new proxy blocked on a 83Begins from the downstream end and satisfies every 7 with a 8 :!Compose two proxies blocked on a 7., generating a new proxy blocked on a 71Begins from the upstream end and satisfies every 8 with a 7 ;; is identical to U5, except with a more polymorphic constraint. <(<) is identical to (V6), except with a more polymorphic constraint. == is identical to W5, except with a more polymorphic constraint. >> is identical to "5, except with a more polymorphic constraint. ??( forwards requests followed by responses !idT = request >=> respond >=> idT@@( forwards responses followed by requests %coidT = respond >=> request >=> coidTA!Compose two proxies blocked on a 8*, generating a new proxy blocked on a 83Begins from the downstream end and satisfies every 7 with a 8 B!Compose two proxies blocked on a 7*, generating a new proxy blocked on a 71Begins from the upstream end and satisfies every 8 with a 7=You don't need to use this. I include it only for symmetry. Cf /</ g replaces all 7s in f with g.Df \<\ g replaces all 8s in g with f../0123456789:;<=>?@ABCD./0123456789<:;=>?@ABCD6789:;<=>?@AB345CD012./ ./0123456789:;<=>?@ABCD485897<1A7C8D8SafeE$Uniform interface to lifting proxiesGLift a 6 Kleisli arrow mapP = (lift .)EFGEFGEFGEFGSafeDOTH$A functor in the category of proxies 4hoistP f . hoistP g = hoistP (f . g) hoistP id = idIf f is a proxy morphism, then hoistP f' is a proxy morphism, meaning that hoistPK f = (hoistP f .)+ defines a functor between five categories.#Functor between Kleisli categories: PhoistPK f p1 >=> hoistPK f p2 = hoistPK f (p1 >=> p2) hoistPK f return = returnFunctor between  categories: JhoistPK f p1 >-> hoistPK f p2 = hoistPK f (p1 >-> p2) hoistPK f idT = idT NhoistPK f p1 >~> hoistPK f p2 = hoistPK f (p1 >~> p2) hoistPK f coidT = coidT%Functor between "request" categories: RhoistPK f p1 \>\ hoistPK f p2 = hoistPK f (p2 \>\ p2) hoistPK f request = request%Functor between "respond" categories: RhoistPK f p1 />/ hoistPK f p2 = hoistPK f (p2 />/ p2) hoistPK f respond = respondILift a proxy morphism from p1 to p2$ into a proxy morphism from (t p1) to (t p2) J#Convenience function equivalent to  (hoistP f .)KLift the base proxy raiseP = hoistP liftPLLift the base proxy of a 'K 'leisli arrow raisePK = hoistPK liftPHIJProxy morphismProxy Kleisli arrowKProxyLProxy Kleisli arrowHIJKLHIJKLHIJKL TrustworthyMA MH communicates with an upstream interface and a downstream interface.The type variables of )ProxyFast req_a' resp_a req_b' resp_b m r signify:req_a'1 - The request supplied to the upstream interfaceresp_a2 - The response provided by the upstream interfacereq_b'3 - The request supplied by the downstream interfaceresp_b4 - The response provided to the downstream interfacem  - The base monadr  - The final return value RRun a self-sufficient M9 Kleisli arrow, converting it back to the base monad SRun a self-sufficient ML Kleisli arrow, converting it back to a Kleisli arrow in the base monad TRun the Pipe8 monad transformer, converting it back to the base monadU?The monad transformer laws are correct when viewed through the U function: hobserve (lift (return r)) = observe (return r) observe (lift (m >>= f)) = observe (lift m >>= lift . f)This correctness comes at a moderate cost to performance, so use this function sparingly or else you would be better off using Control.Proxy.Core.Correct.OYou do not need to use this function if you use the safe API exported from  Control.Proxyf, which does not export any functions or constructors that can violate the monad transformer laws.[Only satisfies laws modulo UMNOPQXYRSTUVWXYZ[\]^ MQNOPRSTU MNOPQRSTUMNOPQXYRSTUVWXYZ[\]^SafeD_The Identity proxy transformerbWrap a 'K'leisli arrow in _cRun an P 'K 'leisli arrow_`abcdefghijklmnopq_`abc_`abc_`abcdefghijklmnopq SafeDrA self-contained r that is ready to be runrs never 7 nor 8. sWait for input from upstreams0 blocks until input is available from upstream. tDeliver output downstreamt9 restores control back downstream and binds its value to s. u#Convert a pure function into a pipevCorresponds to (<<<)/(Z) from Control.CategorywCorresponds to (>>>) from Control.CategoryxCorresponds to [ from Control.Categoryrstuvwxrstuvwxstuvwxrrstuvwxv9 w9 SafeyThe base functor for the } type}A }H communicates with an upstream interface and a downstream interface.The type variables of ,ProxyCorrect req_a' resp_a req_b' resp_b m r signify:req_a'1 - The request supplied to the upstream interfaceresp_a2 - The response provided by the upstream interfacereq_b'3 - The request supplied by the downstream interfaceresp_b4 - The response provided to the downstream interfacem  - The base monadr  - The final return value Run a self-sufficient }9 Kleisli arrow, converting it back to the base monad Run a self-sufficient }L Kleisli arrow, converting it back to a Kleisli arrow in the base monad Run the Pipe8 monad transformer, converting it back to the base monadyz{|}~ y|z{}~ }~yz{|yz{|}~ SafeDThe \ proxy transformerRun an  'K!'leisi arrow, returning either a ] or ^#Abort the computation and return a ] result Synonym for U Synonym for  Resume from an aborted operation with the arguments flippedOriginal computationHandlerHandled computationHandlerOriginal computationHandled computation  SafeDThe _ proxy transformerRun a  'K''leisli arrow, returning the result or `A synonym for aA synonym for U SafeDThe Reader proxy transformerRun a ' computation, supplying the environmentRun a  'K('leisli arrow, supplying the environmentGet the environment!Get a function of the environment8Modify a computation's environment (a specialization of )>Modify a computation's environment (a more general version of ) SafeD The State proxy transformerRun a 2 computation, producing the final result and stateRun a  'K3'leisli arrow, procuding the final result and state Evaluate a ) computation, but discard the final state Evaluate a  'K*'leisli arrow, but discard the final state Evaluate a * computation, but discard the final result Evaluate a  'K+'leisli arrow, but discard the final resultGet the current stateSet the current state)Modify the current state using a function)Get the state filtered through a function SafeD The strict Writer proxy transformerRun a 3 computation, producing the final result and monoidRun a  'K4'leisli arrow, producing the final result and monoid Evaluate a * computation, but discard the final result Evaluate a  'K+'leisli arrow, but discard the final resultAdd a value to the monoid)Modify the result of a writer computation Safe<(mapD f) applies f to all values going 'D 'ownstream. 3mapD f1 >-> mapD f2 = mapD (f2 . f1) mapD id = idT(mapU g) applies g to all values going 'U 'pstream. 3mapU g1 >-> mapU g2 = mapU (g1 . g2) mapU id = idT (mapB f g) applies f$ to all values going downstream and g" to all values going upstream.Mnemonic: map 'B 'idirectional FmapB f1 g1 >-> mapB f2 g2 = mapB (f2 . f1) (g1 . g2) mapB id id = idT (mapMD f) applies the monadic function f to all values going downstream =mapMD f1 >-> mapMD f2 = mapMD (f1 >=> f2) mapMD return = idT (mapMU g) applies the monadic function g to all values going upstream =mapMU g1 >-> mapMU g2 = mapMU (g2 >=> g1) mapMU return = idT (mapMB f g) applies the monadic function f= to all values going downstream and the monadic function g to all values going upstream. VmapMB f1 g1 >-> mapMB f2 g2 = mapMB (f1 >=> f2) (g2 >=> g1) mapMB return return = idT(useD f) executes the monadic function f on all values flowing 'D 'ownstream MuseD f1 >-> useD f2 = useD (\a -> f1 a >> f2 a) useD (\_ -> return ()) = idT(useU g) executes the monadic function g on all values flowing 'U'pstream PuseU g1 >-> useU g2 = useU (\a' -> g2 a' >> g1 a') useU (\_ -> return ()) = idT (useB f g) executes the monadic function f? on all values flowing downstream and the monadic function g on all values flowing upstream }useB f1 g1 >-> useB f2 g2 = useB (\a -> f1 a >> f2 a) (\a' -> g2 a' >> g1 a') useB (\_ -> return ()) (\_ -> return ()) = idT (execD md) executes md. every time values flow downstream through it. EexecD md1 >-> execD md2 = execD (md1 >> md2) execD (return ()) = idT (execU mu) executes mu, every time values flow upstream through it. EexecU mu1 >-> execU mu2 = execU (mu2 >> mu1) execU (return ()) = idT (execB md mu) executes mu> every time values flow upstream through it, and executes md. every time values flow downstream through it. ZexecB md1 mu1 >-> execB md2 mu2 = execB (md1 >> md2) (mu2 >> mu1) execB (return ()) = idT (takeB n) allows n/ upstream/downstream roundtrips to pass through PtakeB n1 >=> takeB n2 = takeB (n1 + n2) -- n1 >= 0 && n2 >= 0 takeB 0 = return   is  with a ()' return value, convenient for composing (takeWhileD p)L allows values to pass downstream so long as they satisfy the predicate p. -- Using the "All" monoid over functions: mempty = \_ -> True (p1 <> p2) a = p1 a && p2 a takeWhileD p1 >-> takeWhileD p2 = takeWhileD (p1 <> p2) takeWhileD mempty = idT (takeWhileU p)J allows values to pass upstream so long as they satisfy the predicate p. PtakeWhileU p1 >-> takeWhileU p2 = takeWhileU (p1 <> p2) takeWhileD mempty = idT  (dropD n) discards n values going downstream MdropD n1 >-> dropD n2 = dropD (n1 + n2) -- n2 >= 0 && n2 >= 0 dropD 0 = idT  (dropU n) discards n values going upstream MdropU n1 >-> dropU n2 = dropU (n1 + n2) -- n2 >= 0 && n2 >= 0 dropU 0 = idT(dropWhileD p)G discards values going downstream until one violates the predicate p. -- Using the "Any" monoid over functions: mempty = \_ -> False (p1 <> p2) a = p1 a || p2 a dropWhileD p1 >-> dropWhileD p2 = dropWhileD (p1 <> p2) dropWhileD mempty = idT(dropWhileU p)E discards values going upstream until one violates the predicate p. PdropWhileU p1 >-> dropWhileU p2 = dropWhileU (p1 <> p2) dropWhileU mempty = idT (filterD p)A discards values going downstream if they fail the predicate p -- Using the "All" monoid over functions: mempty = \_ -> True (p1 <> p2) a = p1 a && p2 a filterD p1 >-> filterD p2 = filterD (p1 <> p2) filterD mempty = idT (filterU p); discards values going upstream if they fail the predicate p DfilterU p1 >-> filterU p2 = filterU (p1 <> p2) filterU mempty = idTConvert a list into a  KfromListS xs >=> fromListS ys = fromListS (xs ++ ys) fromListS [] = returnConvert a list into a  KfromListC xs >=> fromListC ys = fromListC (xs ++ ys) fromListC [] = return version of b version of b version of c version of cFold values flowing 'D 'ownstream 8foldD f >-> foldD g = foldD (f <> g) foldD mempty = idTFold values flowing 'U'pstream 8foldU f >-> foldU g = foldU (g <> f) foldU mempty = idTFold that returns whether d values flowing 'D%'ownstream satisfy the predicate Fold that returns whether d values flowing 'U#'pstream satisfy the predicate Fold that returns whether d values flowing 'D$'ownstream satisfy the predicate8 terminates on the first value that fails the predicate Fold that returns whether d values flowing 'U"'pstream satisfy the predicate8 terminates on the first value that fails the predicate Fold that returns whether e value flowing 'D''ownstream satisfies the predicate Fold that returns whether e value flowing 'U%'pstream satisfies the predicate  Fold that returns whether e value flowing 'D&'ownstream satisfies the predicate < terminates on the first value that satisfies the predicate !Fold that returns whether e value flowing 'U$'pstream satisfies the predicate!< terminates on the first value that satisfies the predicate " Compute the f of all values that flow 'D 'ownstream# Compute the f of all values that flow 'U'pstream$ Compute the g of all values that flow 'D 'ownstream% Compute the g of all values that flow 'U'pstream&Count how many values flow 'D 'ownstream'Count how many values flow 'U'pstream( Retrieve the first value going 'D 'ownstream) Retrieve the first value going 'D 'ownstream)+ terminates on the first value it receives * Retrieve the first value going 'U'pstream+ Retrieve the first value going 'U'pstream++ terminates on the first value it receives ,Retrieve the last value going 'D 'ownstream-Retrieve the last value going 'U'pstream.Fold the values flowing 'D'ownstream into a list/Fold the values flowing 'U'pstream into a list0Fold equivalent to h.To see why, consider this isomorphic type for h: 'foldr :: (a -> b -> b) -> [a] -> Endo b1Fold equivalent to h2Left strict fold over 'D'ownstream values3Left strict fold over 'U'pstream values4Zip values flowing downstream5=Interleave values flowing downstream using simple alternation6Compose 67 with a closed upstream end to create a polymorphic end7Compose 79 with a closed downstream end to create a polymorphic end<      !"#$%&'()*+,-./01234567\ijkldmneopfqrgstuvwxyz{|}~      !"#$%&'()*+,-./01234567<      !"#$%&'()*+,-./01234567<      !"#$%&'()*+,-./01234567SafeOT8 Compose a 'K!'leisli arrow with itself foreverUse 89 to abstract away the following common recursion pattern: -p a = do ... a' <- respond b p a'Using 8, you can instead write: -p = foreverK $ \a -> do ... respond b9 Repeat a 'K'leisli arrow multiple times:#Convenience function equivalent to (lift .) <liftK f >=> liftK g = liftK (f >=> g) liftK return = return89:89:89:89:Safe;A  that sends lines from stdin downstream<A  that sends lines from stdin upstream= input from stdin one line at a time and send 'D 'ownstream> input from stdin one line at a time and send 'U'pstream?#s all values flowing through it to stdoutPrefixes upstream values with "U: " and downstream values with "D: "@s all values flowing 'D'ownstream to stdoutAs all values flowing 'U 'pstream to stdoutB#s all values flowing through it to stdoutPrefixes upstream values with "U: " and downstream values with "D: "Cs all values flowing 'D'ownstream to stdoutDs all values flowing 'U 'pstream to stdoutEConvert 'stdin'/'stdout' into a line-based FConvert 'stdin'/'stdout' into a line-based GA * that sends lines from a handle downstreamHA  that sends lines from a Handle upstreamI%s all values flowing through it to a HandlePrefixes upstream values with "U: " and downstream values with "D: "Js all values flowing 'D'ownstream to a HandleKs all values flowing 'U'pstream to a HandleL%s all values flowing through it to a HandlePrefixes upstream values with "U: " and downstream values with "D: "Ms all values flowing 'D'ownstream to a HandleNs all values flowing 'U'pstream to a Handle;<=>?@ABCDEFGHIJKLMN;<=>?@ABCDEFGHIJKLMN;<=>?@ABCDEFGHIJKLMN;<=>?@ABCDEFGHIJKLMNSafesijkldmneopfqrgstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNSafeijkldmneopfqrgstuvwxyz{|}~W !"#$%./0123456789<:;=>?@ABCDEFGHIJKL_`abc      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNSafeijkldmneopfqrgstuvwxyz{|}~W !"#$%./0123456789<:;=>?@ABCDEFGHIJKLMRSTU_`abc      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNSafe !"##$% !"&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abc()de0fghijklmnoppqrstuvwxyz{|}~ % * + , - . /  b c )   d e 0             !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNLMOLMPLMQLMRLSTLSUVWXYZLSPLSRL[\L[]L[^LS_LS`LSaLbcLbdLefLegLehLeiLjkLSlLemLemLenLefLeoLegLepLehLeqLeiLerLesLesLetLeuLeuLevVwxVwyVwzVw{V|}V|~V|V|V|V|LLLLLLVW"pipes-3.1.0-8oXv4ACi0aQFggaenaPB3tControl.Proxy.Synonym Control.PipeControl.MFunctorControl.Proxy.ClassControl.Proxy.TransControl.PFunctorControl.Proxy.Core.FastControl.Proxy.Trans.IdentityControl.Proxy.PipeControl.Proxy.Core.CorrectControl.Proxy.Trans.EitherControl.Proxy.Trans.MaybeControl.Proxy.Trans.ReaderControl.Proxy.Trans.StateControl.Proxy.Trans.WriterControl.Proxy.Prelude.BaseControl.Proxy.Prelude.KleisliControl.Proxy.Prelude.IOPProxyControl.Proxy.PreludeControl.Proxy.Core Control.ProxyControl.Proxy.TutorialCSessionClientServer CoConsumer CoProducerCoPipeConsumerProducerPipePipeCunPipeCPipelineAwaitYieldMPureawaityieldpipe<+<>+>idPrunPipe$fCategoryTYPEPipeC$fMonadTransPipe $fMonadPipe$fApplicativePipe $fFunctorPipeMFunctorhoisthoistKraiseraiseK$fMFunctorWriterT$fMFunctorWriterT0$fMFunctorStateT$fMFunctorStateT0$fMFunctorRWST$fMFunctorReaderT$fMFunctorMaybeT$fMFunctorIdentityTMonadIOPliftIO_P MonadPlusPmzero_Pmplus_PInteract\>\/>/requestrespond>->>~>return_P?>=lift_Phoist_PidTcoidT<-<<~</>>idGHC.Basereturn>>=transformers-0.5.2.0Control.Monad.Trans.Classlift_bind_lift Data.EitherEitherLeftRightMaybeNothingmzeroGHC.EnumenumFrom enumFromTo Data.MonoidAllAnySumProduct Data.FoldablefoldrMonoidEndoappEndogetAllgetAnygetSum getProductFirstgetFirstLastgetLastControl.Monad.Trans.Writer.Lazy execWriterT runWriterWriterT runWriterT Control.Monad.Trans.State.Strict execStateT execStaterunStateStateT runStateT Text.Readread System.IOprintputStrLn Control.Monadforever<=<>=> MonadTrans