P       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklm n o p q r s t u v w x y z { | } ~     Safe The  class defines the ability to:Request input using the  commandReplace existing  commands using ()Respond with output using the  commandReplace existing  commands using ()Laws:() and  form a category: Grequest \>\ f = f f \>\ request = f (f \>\ g) \>\ h = f \>\ (g \>\ h)() and  form a category: Grespond />/ f = f f />/ respond = f (f />/ g) />/ h = f />/ (g />/ h)Minimal complete definition:,() or (),, and() or ().: 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. @ binds the upstream's response to its own return value. f \>\ g replaces all s in g with f.f /</ g replaces all s in f with g.B with an output for downstream and bind downstream's next  respond b satisfies a downstream  by supplying the value b  blocks until downstream ;s a new value and binds the argument from the next  as its return value. f />/ g replaces all s in f with g.f \<\ g replaces all s in g with f.The G class defines an interface to a bidirectional flow of information.Laws:( ) and  form a category: ?idT >-> f = f f >-> idT = f (f >-> g) >-> h = f >-> (g >-> h)Minimal complete definition:( ) or ( ). acts like a 'T'ransparent proxy, passing all requests further upstream, and passing all responses further downstream. cCompose two proxies, satisfying all requests from downstream with responses from upstream. cCompose two proxies, satisfying all requests from downstream with responses from upstream.      8888 7 7Safe  " defines a functor that preserves Proxy) composition and Kleisli composition.Laws:Functor between Proxy categories 1mapP (f <-< g) = mapP f <-< mapP g mapP idT = idT"Functor between Kleisli categories 7mapP (f <=< g) = mapP f <=< mapP g mapP return = returnMinimal complete definition:   or   . Defining   is more efficient.     SafeOT#A functor in the category of monadsLift a monad morphism from m to n$ into a monad morphism from (t m) to (t n) Safe:DThe   proxy transformerRun an  'K!'leisi arrow, returning either a   or #Abort the computation and return a   result Synonym for  Synonym for  Resume from an aborted operation with the arguments flippedOriginal computationHandlerHandled computationHandlerOriginal computationHandled computation !"   !"Safe:D#The Identity proxy transformer&Run an # 'K 'leisli arrow#$%&'()*+,-./01#$%&#$%& #$%&'()*+,-./01Safe:D2The  proxy transformer5Run a 2 'K''leisli arrow, returning the result or 6A synonym for 7A synonym for 23456789:;<=>?@A23456723456723456789:;<=>?@ASafe:DBThe Reader proxy transformerERun a B' computation, supplying the environmentFRun a B 'K('leisli arrow, supplying the environmentG>Modify a computation's environment (a more general version of J)HGet the environmentI!Get a function of the environmentJ8Modify a computation's environment (a specialization of G)BCDEFGHIJKLMNOPQRSTU BCDEFGHIJ BCDEFGHJIBCDEFGHIJKLMNOPQRSTUSafe:D V The strict State proxy transformerYRun a V2 computation, producing the final result and stateZRun a V 'K3'leisli arrow, procuding the final result and state[ Evaluate a V) computation, but discard the final state\ Evaluate a V 'K*'leisli arrow, but discard the final state] Evaluate a V* computation, but discard the final result^ Evaluate a V 'K+'leisli arrow, but discard the final result_Get the current state`Set the current statea)Modify the current state using a functionb)Get the state filtered through a functionVWXYZ[\]^_`abcdefghijkl VWXYZ[\]^_`ab VWXYZ[\]^_`abVWXYZ[\]^_`abcdefghijkl Safe:Dm The strict Writer proxy transformerpRun a m3 computation, producing the final result and monoidqRun a m 'K4'leisli arrow, producing the final result and monoidr Evaluate a m* computation, but discard the final results Evaluate a m 'K+'leisli arrow, but discard the final resulttAdd a value to the monoidu)Modify the result of a writer computationmnopqrstuvwxyz{|}~ mnopqrstu mnopqrstumnopqrstuvwxyz{|}~ SafeThe empty type, denoting a 'C 'losed end Safe A self-contained , ready to be run by s never  anything or  to anything. Client req resp sends requests of type req$ and receives responses of type resp.s only  and never  to anything. Server req resp receives requests of type req! and sends responses of type resp.s only  and never  anything. A " converts one interface to anotherThe base functor for the  typeRun 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 a self-contained 9 Kleisli arrow, converting it back to the base monad Run a self-contained L Kleisli arrow, converting it back to a Kleisli arrow in the base monad Discard all responsesIgnore all requests Safe 1A self-contained pipeline that is ready to be runA pipe that consumes valuesA pipe that produces valuesThe type variables of  Pipe a b m r signify:a1 - The type of input received from upstream pipesb3 - The type of output delivered to downstream pipesm - The base monadr - The type of the return value Wait for input from upstream! blocks until input is available #Convert a pure function into a pipeDeliver output downstream: restores control back downstream and binds the result to . Corresponds to (<<<)/() from Control.CategoryCorresponds to (>>>) from Control.CategoryCorresponds to  from Control.CategoryRun the 8 monad transformer, converting it back to the base monad  9 9 Safe Compose a 'K!'leisli arrow with itself forever Repeat a 'K'leisli arrow multiple times#Convenience function equivalent to (lift .) 8mapK f >=> mapK g = mapK (f >=> g) mapK return = returnSafe (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(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 (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 (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 (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 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 (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 pM 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 pJ 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)E discards values going upstream 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)G discards values going downstream 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  version of  version of  version of SafeGet input from  one line at a time and send 'D 'ownstreamGet input from  one line at a time and send 'U'pstream input from  one line at a time and send 'D 'ownstream input from  one line at a time and send 'U'pstream#s all values flowing through it to  Prefixes upstream values with "U: " and downstream values with "D: "s all values flowing 'D'ownstream to  s all values flowing 'U 'pstream to  !#s all values flowing through it to  Prefixes upstream values with "U: " and downstream values with "D: "!s all values flowing 'D'ownstream to  !s all values flowing 'U 'pstream to  Convert 'stdin'/'stdout' into a line-based Convert 'stdin'/'stdout' into a line-based 5Get input from a handle one line at a time and send 'D 'ownstream5Get input from a handle one line at a time and send 'U'pstream%s all values flowing through it to a "Prefixes upstream values with "U: " and downstream values with "D: "s all values flowing 'D'ownstream to a "s all values flowing 'U'pstream to a "!%s all values flowing through it to a "Prefixes upstream values with "U: " and downstream values with "D: "!s all values flowing 'D'ownstream to a "!s all values flowing 'U'pstream to a "Safe0SafeY  SafeSafeSafe  s form a #/ instance when you rearrange the type variables1A 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 valueThe base functor for the  typeWait for input from upstream./ blocks until input is available from upstream.Deliver output downstream.8 restores control back upstream and binds the result to .#Convert a pure function into a pipe 4pipe f = forever $ do x <- await yield (f x)Corresponds to ($)/(%) from Control.CategoryCorresponds to (&) from Control.CategoryCorresponds to ' from Control.CategoryRun the ; monad transformer, converting it back into the base monad. imposes two conditions:9The pipe's input, if any, is trivially satisfiable (i.e. ())The pipe does not  any outputThe latter restriction makes [ less polymorphic than it could be, and I settled on the restriction for three reasons:)It prevents against accidental data loss.#It protects against silent failures`It prevents wastefully draining a scarce resource by gratuitously driving it to completionIf you believe that discarding output is the appropriate behavior, you can specify this by explicitly feeding your output to a pipe that gratuitously discards it: runPipe $ forever await <+< p9 9 SafeSafeDQRIndexed equivalent to FreeTIndexed equivalent to FreeFIndexed equivalent to wrapIndexed equivalent to liftF Safe%&QR s form a #/ instance when you rearrange the type variablesA self-contained  that is ready to be runA  is like a  with an indexed input end:b - The type of the s outputm - The base monadi' - The initial index of the input end (pen or losed)j% - The final index of the input end (pen or losed)r - The return value4Base functor for a pipe that can close its input endb - Output typex - Next stepi - Current step's index?Index representing an open input end, receiving values of type Maybe a?Index representing an open input end, receiving values of type a% the most current finalizer for this  alongside the value" a value from upstream, returning  if upstream terminates9 the input end, calling the finalizers of every upstream . a value upstream alongside an empty finalizer; a value from upstream and terminate if upstream terminates catchD m p calls the finalizer m if a downstream  terminates before p finishes. catchF m p calls the finalizer m if any  terminates before p finishes. finallyD m p calls the finalizer m if a downstream  terminates before p finishes or if p completes normally. finallyF m p calls the finalizer m if any  terminates before p finishes or if p completes normally.Corresponds to ($)/(%) from Control.CategoryCorresponds to (&) from Control.CategoryCorresponds to ' from Control.Category Run the 9 monad transformer, converting it back to the base monad.  is the  equivalent to # and requires a self-contained . ()*+, -    ()*+, -  9 9 SafeSafe. !"#$%&'()**+,-./0123456789:;<<=>?@ABCDEFGHIJJKLMNOPQRSTUVWXYYZ[\]^_`abcdefghijkllmnopqrstuvwxyz{|}~                $#                         ! "# $%  & $' () *+ *, * *- *./01234"pipes-2.4.0-2Y0f0XUYb6ZGGD5X0cYyjtControl.Proxy.ClassControl.Proxy.TransControl.MFunctorControl.Proxy.Trans.EitherControl.Proxy.Trans.IdentityControl.Proxy.Trans.MaybeControl.Proxy.Trans.ReaderControl.Proxy.Trans.StateControl.Proxy.Trans.Writer Data.ClosedControl.Proxy.CoreControl.Proxy.PipeControl.Proxy.Prelude.KleisliControl.Proxy.Prelude.BaseControl.Proxy.Prelude.IOControl.Pipe.CoreControl.IMonad.Trans.Free Control.FrameControl.Proxy.Prelude Control.ProxyControl.Proxy.Trans.TutorialControl.Proxy.Tutorial Control.PipeControl.Frame.TutorialControl.Pipe.TutorialInteractrequest\>\//\<\ChannelidT>-><-< ProxyTransliftPmapPMFunctormapTEitherP runEitherP runEitherKleftrightthrowcatchhandle$fProxyTransEitherP$fChannelEitherP$fMFunctorEitherP$fMonadIOEitherP$fMonadTransEitherP$fMonadPlusEitherP$fAlternativeEitherP$fMonadEitherP$fApplicativeEitherP$fFunctorEitherP IdentityP runIdentityP runIdentityK$fProxyTransIdentityP$fInteractIdentityP$fChannelIdentityP$fMFunctorIdentityP$fMonadIOIdentityP$fMonadTransIdentityP$fMonadPlusIdentityP$fAlternativeIdentityP$fMonadIdentityP$fApplicativeIdentityP$fFunctorIdentityPMaybeP runMaybeP runMaybeKnothingjust$fProxyTransMaybeP$fChannelMaybeP$fMFunctorMaybeP$fMonadIOMaybeP$fMonadTransMaybeP$fMonadPlusMaybeP$fAlternativeMaybeP $fMonadMaybeP$fApplicativeMaybeP$fFunctorMaybePReaderP unReaderP runReaderP runReaderK withReaderPaskaskslocal$fProxyTransReaderP$fInteractReaderP$fChannelReaderP$fMFunctorReaderP$fMonadIOReaderP$fMonadTransReaderP$fMonadPlusReaderP$fAlternativeReaderP$fMonadReaderP$fApplicativeReaderP$fFunctorReaderPStatePunStateP runStateP runStateK evalStateP evalStateK execStateP execStateKgetputmodifygets$fProxyTransStateP$fChannelStateP$fMFunctorStateP$fMonadIOStateP$fMonadTransStateP$fMonadPlusStateP$fAlternativeStateP $fMonadStateP$fApplicativeStateP$fFunctorStatePWriterP unWriterP runWriterP runWriterK execWriterP execWriterKtellcensor$fProxyTransWriterP$fChannelWriterP$fMFunctorWriterP$fMonadIOWriterP$fMonadTransWriterP$fMonadPlusWriterP$fAlternativeWriterP$fMonadWriterP$fApplicativeWriterP$fFunctorWriterPCSessionClientServerProxyunProxyProxyFRequestRespondrunProxy runProxyK runSession runSessionKdiscardignore$fMFunctorProxy$fInteractProxy$fChannelProxy$fMonadIOProxy$fMonadTransProxy $fMonadProxy$fApplicativeProxy$fFunctorProxy$fFunctorProxyFPipelineConsumerProducerPipeawaitpipeyield<+<>+>idPrunPipeforeverK replicateKmapKmapBmapDmapUmapMBmapMDmapMUexecBexecDexecUtakeBtakeB_ takeWhileD takeWhileUdropDdropU dropWhileD dropWhileUfilterDfilterU fromListS fromListC enumFromS enumFromC enumFromToS enumFromToCgetLineSgetLineCreadLnSreadLnCprintBprintDprintU putStrLnB putStrLnD putStrLnUpromptSpromptC hGetLineD hGetLineUhPrintBhPrintDhPrintU hPutStrLnB hPutStrLnD hPutStrLnUPipeCunPipeCPipeFAwaitYield$fCategoryTYPEPipeC$fFunctorPipeFIFreeT runIFreeTIFreeFReturnWrapwrapliftF$fIMonadTransTYPEIFreeT$fIMonadTYPEIFreeT$fIFunctorTYPETYPEIFreeTFrameCunFrameCStackFrameFrameFCloseMOyieldFawaitFclosecatchDcatchFfinallyDfinallyFidFrunFrame$fCategoryTYPEFrameC$fIFunctorTYPETYPEFrameFbase Data.EitherEitherLeftRightGHC.BasereturnMaybeNothingmzeroidT'<-/? runProxy'.idrunPipe'GHC.EnumenumFrom enumFromToGHC.IO.Handle.FDstdin Text.Readread System.IOprintstdoutputStrLnGHC.IO.Handle.TypesHandleControl.CategoryCategory<<<>>><~<<~|heapstackwarn runFrame'