h$)J&i      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijk l m n o p q r s t u v  Safe-Inferred>?boxclose a continuation(close $ glue showStdout <$> qList [1..3]123box fmap then close over a Codensity(process (glue showStdout) (qList [1..3])123box fmap then close over a Codensity!glue showStdout <$|> qList [1..3]123box"apply to a continuation and close.,glue <$> (pure showStdout) <*|> qList [1..3]123wxyz{|}~33 Safe-InferredeboxMonadically Foldablebox/An endofunctor in the category of endofunctors.Like    but without a  constraint.   Safe-Inferred>? boxAn   continuation. boxan    s values of type Maybe a. Source & Producer are also appropriate metaphors.An Emitter reaches into itself for the value to emit, where itself is an opaque thing from the pov of usage.'e = Emitter (pure (Just "I'm emitted"))emit eJust "I'm emitted" emit memptyNothingbox:Collect emits into a list, and close on the first Nothing.toListM <$|> qList [1..3][1,2,3]box A monadic .https://hackage.haskell.org/package/witherable Witherableclose $ toListM <$> witherE (\x -> bool (print x >> pure Nothing) (pure (Just x)) (even x)) <$> (qList [1..3])13[2]box Read parse  &, returning the original text on errorprocess (toListM . readE) (qList ["1","2","3","four"]) :: IO [Either Text Int]%[Right 1,Right 2,Right 3,Left "four"]box7Convert a list emitter to a (Stateful) element emitter.import Control.Monad.State.Lazyclose $ flip runStateT [] . toListM . unlistE <$> (qList [[0..3],[5..7]])([0,1,2,3,5,6,7],[])box Take n emits.import Control.Monad.State.Lazy?close $ flip evalStateT 0 <$> toListM . takeE 4 <$> qList [0..] [0,1,2,3]box'Take from an emitter until a predicate.2process (toListM . takeUntilE (==3)) (qList [0..])[0,1,2]boxPop from a State sequence.%import qualified Data.Sequence as Seq,import Control.Monad.State.Lazy (evalStateT)3flip evalStateT (Seq.fromList [1..3]) $ toListM pop[1,2,3]boxThis fold completes on the first Nothing emitted, which may not be what you want.   Safe-Inferred,>?box continuation.box A Committer !s values of type a and signals success or otherwise. A Sink and a Consumer are some other metaphors for this.A Committer absorbs the value being committed; the value disappears into the opaque thing that is a Committer from the pov of usage. commit toStdout "I'm committed!"I'm committed!True"box A monadic .https://hackage.haskell.org/package/witherable Witherableglue (witherC (\x -> pure $ bool Nothing (Just x) (even x)) showStdout) <$|> qList [0..5]024#box;Convert a committer to be a list committer. Think mconcat.#glue showStdout <$|> qList [[1..3]][1,2,3]+glue (listC showStdout) <$|> qList [[1..3]]123$boxPush to a state sequence.import Control.Monad.State.Lazy%import qualified Data.Sequence as Seqflip execStateT Seq.empty . glue push . foist lift <$|> qList [1..3]fromList [1,2,3] !"#$ !"#$ Safe-Inferred >?N +box qList [1..3]123<box0Glues a committer and emitter, and takes n emits,glueN 3 <$> pure showStdout <*|> qList [1..]123Note that glueN counts the number of events passing across the connection and doesn't take into account post-transmission activity in the Committer, egglueN 4 (witherC (\x -> bool (pure Nothing) (pure (Just x)) (even x)) showStdout) <$|> qList [0..9]02=box,Glue a Committer to an Emitter within a box. ,fuse (pure . pure) == \(Box c e) -> glue c eA command-line echoer :fuse (pure . Just . ("echo " <>)) (Box toStdout fromStdin)>boxConstruct a CoBox cobox = Box <$> c <*> efuse (pure . Just . ("show: " <>) . pack . show) <$|> (cobox (pure toStdout) (qList [1..3]))show: 1show: 2show: 3?boxState monad queue.+,-./0123456789:;<=>?5678.+,-:9;<=234/01>?None >?PFboxF" specifies how messages are queuedMboxCreate an unbounded queue, returning the result from the Committer action.3queueL New (\c -> glue c <$|> qList [1..3]) toListMNboxCreate an unbounded queue, returning the result from the Emitter action.3queueR New (\c -> glue c <$|> qList [1..3]) toListM[3]Obox2Create an unbounded queue, returning both results.8queue Unbounded (\c -> glue c <$|> qList [1..3]) toListM ((),[1,2,3])Pbox)Turn a box action into a box continuationQboxHook a committer action to a queue, creating an emitter continuation.RboxHook a committer action to a queue, creating an emitter continuation. FHIGJKLMNOPQR FHIGJKLMNOPQRNone ,>?G Sbox Queue a list.pushList <$|> qList [1,2,3][1,2,3]Tbox6Directly supply a list to a committer action, via pop.popList [1..3] showStdout123Ubox&Push an Emitter into a list, via push.pushList <$|> qList [1..3][1,2,3]Vbox&Push an Emitter into a list, finitely.pushListN 2 <$|> qList [1..3][1,2]WboxCreate a finite Committer.'glue <$> sink 2 print <*|> qList [1..3]12XboxCreate a finite Emitter.'glue toStdout <$|> source 2 (pure "hi")hihiYbox=Glues an emitter to a committer, then resupplies the emitter.:(c1,l1) <- refCommitter :: IO (Committer IO Int, IO [Int])=close $ toListM <$> (forkEmit <$> (qList [1..3]) <*> pure c1)[1,2,3]l1[1,2,3]ZboxBuffer a committer.[boxBuffer an emitter.\boxConcurrently run two emitters.+This differs to (<>), which is left-biased.Note that functions such as toListM, which complete on the first Nothing emitted, will not work as expected.close $ (fmap toListM) (join $ concurrentE Single <$> qList [1..3] <*> qList [5..9])[1,2,3]5In the code below, the ordering is non-deterministic. (c,l) <- refCommitter :: IO (Committer IO Int, IO [Int]) close $ glue c <$> (join $ concurrentE Single <$> qList [1..30] <*> qList [40..60])]box Concurrently run two committers.!import Data.Functor.Contravariantimport Data.Text (pack)cFast = witherC (\b -> pure (Just b)) . contramap ("fast: " <>) $ toStdoutcSlow = witherC (\b -> sleep 0.1 >> pure (Just b)) . contramap ("slow: " <>) $ toStdoutclose $ (popList ((pack . show) <$> [1..3]) <$> (concurrentC Unbounded cFast cSlow)) <> pure (sleep 1)fast: 1fast: 2fast: 3slow: 1slow: 2slow: 3 STUVWXYZ[\] STUVWXYZ[\]None  >?# ^boxEmit text from stdin %> emit fromStdin hello Just "hello" _boxCommit to stdout*commit toStdout ("I'm committed!" :: Text)I'm committed!True`boxFinite console emitter  > toListM <$|9> fromStdinN 2 hello hello again ["hello","hello again"] aboxFinite console committerglue <$> contramap (pack . show) <$> (toStdoutN 2) <*|> qList [1..3]12bbox,Read from console, throwing away read errors> glueN 2 showStdout (readStdin :: Emitter IO Int) 1 1 hippo 2cboxShow to stdout!glue showStdout <$|> qList [1..3]123dbox"Emits lines of Text from a handle.ebox!Commit lines of Text to a handle.fboxEmit lines of Text from a file.gboxCommit lines of Text to a file.hbox*Commit lines of Text, appending to a file.iboxCommit to an IORef:(c1,l1) <- refCommitter :: IO (Committer IO Int, IO [Int])glue c1 <$|> qList [1..3]l1[1,2,3]jboxEmit from a list IORefe <- refEmitter [1..3] toListM e[1,2,3] ^_`abcdefghij ^_`abcdeijfgh None,/?%kbox"A value with a UTCTime annotation.oboxSleep for x seconds.pboxAdd the current timeqboxAdd the current time stamp. > process (toListM . stampE) (qList [1..3]) [(2022-02-09 01:18:00.293883,1),(2022-02-09 01:18:00.293899,2),(2022-02-09 01:18:00.293903,3)] rboxWait s seconds before emittingsbox glueN 4 showStdout  $|' replay 1 (Emitter $ sleep 0.1 >> Just  $ stampNow ()) klnmopqrs oklnmpqrs None,>?%wxyz{|}~  !"#$+,-./0123456789:;<=>?FLKJGHIMNOPQRSTUVWXYZ[\]^_`abcdefghijklnmopqrs  !"#$%&'()*++,-./01234566789:;<=>  ?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr s s t u v w x y z { | }~~~~~~~~~~~~~~ box-0.8.0-6k88t5F9vRS7mvI1mfnUxV Box.Codensity Box.Functor Box.Emitter Box.CommitterBox.Box Box.QueueBox.ConnectorsBox.IOBox.TimeControl.Monad.MorphMFunctorBoxcloseprocess<$|><*|>$fMonoidCodensity$fSemigroupCodensity FoldableMfoldrMFFunctorfoist CoEmitterEmitteremittoListMwitherEreadEunlistEtakeE takeUntilEpop$fFoldableMEmitter$fMonoidEmitter$fSemigroupEmitter$fMonadPlusEmitter$fAlternativeEmitter$fMonadEmitter$fApplicativeEmitter$fFunctorEmitter$fFFunctorEmitter CoCommitter CommittercommitwitherClistCpush$fDecidableCommitter$fDivisibleCommitter$fContravariantCommitter$fMonoidCommitter$fSemigroupCommitter$fFFunctorCommitterCoBoxMuncoboxCoBoxDecAltchoicelossDivapdivapconpur committeremitterfoistbbmapglueglueNfusecoboxseqBox $fMonoidBox$fSemigroupBox$fProfunctorBox $fDivapBox $fDecAltBox$fSemigroupoidTYPECoBoxMQueue UnboundedBoundedSingleLatestNewestNewqueueLqueueRqueue fromActionemitQcommitQqListpopListpushList pushListNsinksourceforkEmitbufferCommitter bufferEmitter concurrentE concurrentC fromStdintoStdout fromStdinN toStdoutN readStdin showStdouthandleEhandleCfileE fileWriteC fileAppendC refCommitter refEmitterStampedstampvaluesleepstampNowstampEemitInreplay $fEqStamped $fShowStamped $fReadStamped+kan-extensions-5.2.3-HXkFxvEWJZU1tb0dz3xAu2Control.Monad.Codensityshiftreset wrapCodensityimproveranToCodensitycodensityToRancomposedRepToCodensitycodensityToComposedRepadjunctionToCodensitycodensityToAdjunctionlowerCodensity Codensity runCodensitybaseGHC.BaseMonad*contravariant-1.5.5-Ahm1naNh6BQEDiMrfTOLxo$Data.Functor.Contravariant.Divisible Decidable AlternativedivideconquerliftA2pure