h&:,6P      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~              Safe-Inferredboxclose 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]12303 Safe-InferredboxMonadically 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 Drop n emits.import Control.Monad.State.Lazy'toListM <$|> (dropE 2 =<< qList [0..3])[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 ,box qList [1..3]123=boxConnect a Stateful emitter to a (non-stateful) committer of the same type, supplying initial state.5glueES 0 (showStdout) <$|> (takeE 2 <$> qList [1..3])12>boxConnect a Stateful emitter to a (similarly-stateful) committer of the same type, supplying initial state.?glueS 0 (foist lift showStdout) <$|> (takeE 2 <$> qList [1..3])12?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)AboxConstruct a CoBox cobox = Box <$> c <*> efuse (pure . Just . ("show: " <>) . pack . show) <$|> (cobox (pure toStdout) (qList [1..3]))show: 1show: 2show: 3BboxState monad queue.box cps composition of monadic boxes,-./0123456789:;<=>?@AB6789/,-.;:@345012AB Safe-Inferred IboxI" specifies how messages are queuedbox:create a queue, supplying the ends and a sealing function.box#write to a queue, checking the sealbox*read from a queue, and retry if not sealedPbox$turn a queue into a box (and a seal)Qboxturn a queue into a box (and a seal), and lift from stm to the underlying monad.boxrun two actions concurrently, but wait and return on the left result.boxrun two actions concurrently, but wait and return on the right result.boxconnect a committer and emitter action via spawning a queue, and wait for the Committer action to complete.boxconnect a committer and emitter action via spawning a queue, and wait for the Emitter action to complete.boxconnect a committer and emitter action via spawning a queue, and wait for both to complete.RboxCreate an unbounded queue, returning the result from the Committer action.3queueL New (\c -> glue c <$|> qList [1..3]) toListMSboxCreate an unbounded queue, returning the result from the Emitter action.3queueR New (\c -> glue c <$|> qList [1..3]) toListM[3]Tbox2Create an unbounded queue, returning both results.8queue Unbounded (\c -> glue c <$|> qList [1..3]) toListM ((),[1,2,3])boxlift a box from STMUbox)Turn a box action into a box continuationVbox)Turn a box action into a box continuationbox3Connect up two box actions via two Unbounded queuesbox)Connect up two box actions via two queuesWboxHook a committer action to a queue, creating an emitter continuation.XboxHook a committer action to a queue, creating an emitter continuation.IKLJMNOPQRSTUVWXIKLJMNORSTUWXVQP Safe-Inferred .(RYboxQueue a list Unbounded.pushList <$|> qList [1,2,3][1,2,3]ZboxQueue a list with an explicit I.&pushList <$|> qListWith Single [1,2,3][1,2,3][box6Directly supply a list to a committer action, via pop.popList [1..3] showStdout123\box&Push an Emitter into a list, via push.pushList <$|> qList [1..3][1,2,3]]box&Push an Emitter into a list, finitely.pushListN 2 <$|> qList [1..3][1,2]^box*Create a finite Committer Unbounded Queue. 'glue <$> sink 2 print <*|> qList [1..3]1 2_box Create a finite Committer Queue.`box,Create a finite (Co)Emitter Unbounded Queue.'glue toStdout <$|> source 2 (pure "hi")hihiabox,Create a finite (Co)Emitter Unbounded Queue.2glue toStdout <$|> sourceWith Single 2 (pure "hi")hihibbox=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]cboxBuffer a committer.dboxBuffer an emitter.eboxConcurrently 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])fbox 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: 3gboxTake and queue n emits.import Control.Monad.State.Lazy-toListM <$|> (takeQ Single 4 =<< qList [0..]) [0,1,2,3]hbox1queue a stateful emitter, supplying initial stateimport Control.Monad.State.Lazy8toListM <$|> (evalEmitter 0 <$> takeE 4 =<< qList [0..]) [0,1,2,3]ibox1queue a stateful emitter, supplying initial stateYZ[\]^_`abcdefghiYZ[\]^_`abcdefghi Safe-Inferred "/jboxEmit text from stdin %> emit fromStdin hello Just "hello" kboxCommit to stdout*commit toStdout ("I'm committed!" :: Text)I'm committed!TruelboxFinite console emitter  > toListM <$|9> fromStdinN 2 hello hello again ["hello","hello again"] mboxFinite console committer glue <$> contramap (pack . show) <$> (toStdoutN 2) <*|> qList [1..3]1 2nbox,Read from console, throwing away read errors> glueN 2 showStdout (readStdin :: Emitter IO Int) 1 1 hippo 2 2oboxShow to stdout!glue showStdout <$|> qList [1..3]123pboxEmits lines of Text from a handle. handleEText = handleE Text.hGetLine"Emits lines of Text from a handle.qbox!Commit lines of Text to a handle.rboxCommit lines of Text to a handle. handleCBS = handleC Char8.hPutStrLnEmits lines of Text from a handle. handleCText = handleC Text.hPutStrLnEmit lines of Text from a file.uboxCommit lines of Text to a file.xboxCommit to an IORef:(c1,l1) <- refCommitter :: IO (Committer IO Int, IO [Int])glue c1 <$|> qList [1..3]l1[1,2,3]yboxEmit from a list IORefe <- refEmitter [1..3] toListM e[1,2,3]zbox'simple console logger for rough testing{box'simple console logger for rough testing|box(Pause an emitter based on a Bool emitter}boxCreate an emitter that indicates when another emitter has changed.~box&quit a process based on a Bool emitter ;quit <$> speedEffect (pure 2) <$> (resetGap 5) <*|> pure io0 1 2 3 4 Left Truebox.restart a process if flagged by a Bool emitterjklmnopqrstuvwxyz{|}~jklmnoxypqrustvw{z|}~  Safe-Inferred.15: boxSleep for x seconds.box convenience conversion to Doublebox"convenience conversion from DoubleboxAdd the current timeboxAdd the current time stamp. > toListM . stampE  $| (qList [1..3]) [(2022-08-30 01:55:16.517127,1),(2022-08-30 01:55:16.517132,2),(2022-08-30 01:55:16.517135,3)] box7Convert stamped emitter to gap between emits in seconds toListM <$|> (gaps =<< (fromGapsNow =<< (qList (zip (0:repeat 1) [1..4])))) (0.0,1),(1.0,2),(1.0,3),(1.0,4)boxConvert gaps in seconds to stamps starting from an initial supplied box (fromGapsNow =<< (qList (zip (0:repeat 1) [1..4]))) (2022-08-30 22:57:33.835228,1),(2022-08-30 22:57:34.835228,2),(2022-08-30 22:57:35.835228,3),(2022-08-30 22:57:36.835228,4)boxConvert a (Gap,a) emitter to an a emitter, with delays between emits of the gap.box5Only add a Gap effect if greater than the Int emitter8effect is similar to a fast-forward of the first n emitsbox.Only add a Gap if greater than the Int emitter8effect is similar to a fast-forward of the first n emitsbox (replay 0.1 1 =<< (fromGapsNow =<< (qList (zip (0:repeat 1) [1..4])))) (2022-08-31 02:29:39.643831,1),(2022-08-31 02:29:39.643841,2),(2022-08-31 02:29:39.746998,3),(2022-08-31 02:29:39.849615,4)    Safe-Inferred.5  !"#$%,-./0123456978:;<=>?@ABIONMJKLPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  !"#$%&'()*+,,-./01234567789:;<=>?  @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                box-0.9.0-3hmFU1NFdns2rK7vhHYWe1 Box.Codensity Box.Functor Box.Emitter Box.CommitterBox.Box Box.QueueBox.ConnectorsBox.IOBox.TimeControl.Monad.MorphMFunctorBoxcloseprocess<$|><*|>$fMonoidCodensity$fSemigroupCodensity FoldableMfoldrMFFunctorfoist CoEmitterEmitteremittoListMwitherEreadEunlistEtakeEdropE takeUntilEpop$fFoldableMEmitter$fMonoidEmitter$fSemigroupEmitter$fMonadPlusEmitter$fAlternativeEmitter$fMonadEmitter$fApplicativeEmitter$fFunctorEmitter$fFFunctorEmitter CoCommitter CommittercommitwitherClistCpush$fDecidableCommitter$fDivisibleCommitter$fContravariantCommitter$fMonoidCommitter$fSemigroupCommitter$fFFunctorCommitterCoBoxMuncoboxCoBoxDecAltchoicelossDivapdivapconpur committeremitterfoistbbmapglueglueESglueSglueNfusecoboxseqBox $fMonoidBox$fSemigroupBox$fProfunctorBox $fDivapBox $fDecAltBox$fSemigroupoidTYPECoBoxMQueue UnboundedBoundedSingleLatestNewestNewtoBoxSTMtoBoxMqueueLqueueRqueue fromActionfromActionWithemitQcommitQqList qListWithpopListpushList pushListNsinksinkWithsource sourceWithforkEmitbufferCommitter bufferEmitter concurrentE concurrentCtakeQ evalEmitterevalEmitterWith fromStdintoStdout fromStdinN toStdoutN readStdin showStdouthandleEhandleCfileE fileETextfileEBSfileC fileCTextfileCBS refCommitter refEmitter logConsoleE logConsoleCpauserchangerquitrestartGapsleepstampNowstampEgapsfromGaps fromGapsNow gapEffect speedEffect gapSkipEffectspeedSkipEffectskipreplay+kan-extensions-5.2.5-4Arv4wrPc0EGxTcLaW1JNkControl.Monad.Codensityshiftreset wrapCodensityimproveranToCodensitycodensityToRancomposedRepToCodensitycodensityToComposedRepadjunctionToCodensitycodensityToAdjunctionlowerCodensity Codensity runCodensitybaseGHC.BaseMonad*contravariant-1.5.5-469aslisNQV7ShPhxUzaR3$Data.Functor.Contravariant.Divisible Decidable AlternativedivideconquerliftA2puredotcoends writeCheck readCheckconcurrentlyLeftconcurrentlyRightwithQLwithQRwithQliftB fuseActionsfuseActionsWithfromNominalDiffTimetoNominalDiffTime!time-1.9.3-FC13fzPSqx87xfmmE8p3rw&Data.Time.LocalTime.Internal.LocalTime LocalTime