úÎŽ3‰KR      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQNone*+IN data type is equivalent to FreeTe and can represent any effectful succession of steps, where the steps are specified by the first functor parameter.  Rdata Stream f m r = Step !(f (Stream f m r)) | Delay (m (Stream f m r)) | Return rThe producer! concept uses the simple functor  (a,_)  - or the stricter  Of a _ J. Then the news at each step or layer is just: an individual item of type a . Since Stream (Of a) m r is equivalent to Pipe.Producer a m r, much of the pipes Prelude can easily be mirrored in a  streaming Prelude. Similarly, a simple Consumer a m r or  Parser a m r- concept arises when the base functor is  (a -> _)  . Stream ((->) input) m result consumes input until it returns a result.To avoid breaking reasoning principles, the constructors should not be used directly. A pattern-match should go by way of  " - or, in the producer case, * The constructors are exported by the Internal module.2Map a stream to its church encoding; compare list R 3Reflect a church-encoded stream; cp. GHC.Exts.build CInspect the first stage of a freely layered sequence. Compare  Pipes.next and the replica Streaming.Prelude.next. This is the uncons for the general  . Hunfold inspect = id Streaming.Prelude.unfoldr StreamingPrelude.next = id Build a Stream* by unfolding steps starting from a seed. Ïunfold inspect = id -- modulo the quotient we work with unfold Pipes.next :: Monad m => Producer a m r -> Stream ((,) a) m r unfold (curry (:>) . Pipes.next) :: Monad m => Producer a m r -> Stream (Of a) m r BMap layers of one functor to another with a natural transformation SMap layers of one functor to another with a transformation involving the base monad    None+-./IN1HA left-strict pair; the base functor for streams of individual elements.0Apply an action to all values flowing downstream let debug str = chain print str!BReduce a stream, performing its actions but ignoring its elements."BIgnore the first n elements of a stream, but carry out the actions#2Ignore elements of a stream until a test succeeds.$,Stream the elements of a foldable container.%/Skip elements of a stream that fail a predicate&2Skip elements of a stream that fail a monadic test'Strict fold of a  of elements MControl.Foldl.purely fold :: Monad m => Fold a b -> Stream (Of a) m () -> m b(Strict fold of a , of elements that preserves the return value RControl.Foldl.purely fold' :: Monad m => Fold a b -> Stream (Of a) m r -> m (b, r))9Strict, monadic fold of the elements of a 'Stream (Of a)' QControl.Foldl.impurely foldM :: Monad m => FoldM a b -> Stream (Of a) m () -> m b*9Strict, monadic fold of the elements of a 'Stream (Of a)' VControl.Foldl.impurely foldM' :: Monad m => FoldM a b -> Stream (Of a) m r -> m (b, r)+XA natural right fold for consuming a stream of elements. See also the more general  in the  Streaming( module and the still more general ªfoldrT (a p -> Pipes.yield a >> p) :: Monad m => Stream (Of a) m r -> Producer a m r foldrT (a p -> Conduit.yield a >> p) :: Monad m => Stream (Of a) m r -> Conduit a m r,WA natural right fold for consuming a stream of elements. See also the more general  in the  Streaming' module and the still more general -forv replaces each element of a stream with an associated stream. Note that the associated stream may layer any functor. SHIterate a pure function from a seed value, streaming the results foreverTKIterate a monadic function from a seed value, streaming the results forever.)Standard map on the elements of a stream./MFor each element of a stream, stream a foldable container of elements instead)D.print $ D.mapFoldable show $ D.yield 12'1''2'0DReplace each element of a stream with the result of a monadic action1:Reduce a stream to its return value with a monadic action.0mapM_ Prelude.print $ each [1..3] >> return True123True2ŠMap free layers of a functor to a corresponding stream of individual elements. This simplifies the use of folds marked with a ''' in Streaming.Prelude ¸maps' sum' :: (Monad m, Num a) => Stream (Stream (Of a) m) m r -> Stream (Of a) m r maps' (Pipes.fold' (+) (0::Int) id) :: Monad m => Stream (Producer Int m) m r -> Stream (Of Int) m r3rThe standard way of inspecting the first item in a stream of elements, if the stream is still 'running'. The Right< case contains a Haskell pair, where the more general inspectE would return a left-strict pair. There is no reason to prefer inspect since, if the RightW case is exposed, the first element in the pair will have been evaluated to whnf.žnext :: Monad m => Stream (Of a) m r -> m (Either r (a, Stream (Of a) m r)) inspect :: Monad m => Stream (Of a) m r -> m (Either r (Of a (Stream (Of a) m r)))ÌIOStreams.unfoldM (liftM (either (const Nothing) Just) . next) :: Stream (Of a) IO b -> IO (InputStream a) Conduit.unfoldM (liftM (either (const Nothing) Just) . next) :: Stream (Of a) m r -> Source a m r4~Inspect the first item in a stream of elements, without a return value. Useful for unfolding into another streaming type.†IOStreams.unfoldM uncons :: Stream (Of a) IO b -> IO (InputStream a) Conduit.unfoldM uncons :: Stream (Of o) m r -> Conduit.Source m o5Fold a  of numbers into their product6Fold a 4 of numbers into their product with the return value I mapsFold product' :: Stream (Stream (Of Int)) m r -> Stream (Of Int) m r7KMake a stream of strings into a stream of parsed values, skipping bad cases9(Repeat an action, streaming the results.:=Strict left scan, streaming, e.g. successive partial results. ZControl.Foldl.purely scan :: Monad m => Fold a b -> Stream (Of a) m r -> Stream (Of b) m r;Strict, monadic left scan `Control.Foldl.impurely scanM :: Monad m => FoldM a m b -> Stream (Of a) m r -> Stream (Of b) m r< Like the © but streaming. The result type is a stream of a's, but is not accumulated; the effects of the elements of the original stream are interleaved in the resulting stream.>Fold a  of numbers into their sum?Fold a 0 of numbers into their sum with the return value E mapsFold sum' :: Stream (Stream (Of Int)) m r -> Stream (Of Int) m r@?Stream elements until one fails the condition, return the rest.AAEnd stream after n elements; the original return value is lost. splitAtB preserves this information. Note the function is functor-general.BQEnd stream when an element fails a condition; the original return value is lost @ preserves this information.C.Convert a pure 'Stream (Of a) into a list of aD5Convert an effectful 'Stream (Of a)' into a list of aNote: D is not an idiomatic use of pipes?, but I provide it for simple testing purposes. Idiomatic pipess style consumes the elements immediately as they are generated instead of loading all elements into memory.EConvert an effectful ' into a list alongside the return valueNote: E is not an idiomatic use of  streaming?, but I provide it for simple testing purposes. Idiomatic  streaming style, like idiomatic pipesg style consumes the elements as they are generated instead of loading all elements into memory. F mapsFold toListM' :: Stream (Stream (Of a)) m r -> Stream (Of [a]) m FBuild a StreamT by unfolding steps starting from a seed. This is one natural way to consume a . The more general  B would require dealing with the left-strict pair we are using.—unfoldr Pipes.next :: Monad m => Producer a m r -> Stream (Of a) m r unfold (curry (:>) . Pipes.next) :: Monad m => Producer a m r -> Stream (Of a) m rGA singleton streamHZip two Streamss IZip two Streams's using the provided combining functionJrepeatedly stream lines as U from stdinK7 values from V, ignoring failed parsesLRead U s from a W using XTerminates on end of inputO.Evaluate all values flowing downstream to WHNFPWrite Us to Y using ZUnlike M, P. gracefully terminates on a broken output pipeQWrite Us to Y using ZQThis does not handle a broken output pipe, but has a polymorphic return value? !"#$[\]%&'()*+,-ST./01234567^8_9:;<=>?@ABCDEFGHIJKLMNOPQ;  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQ;$GFJKL89PQ1NM!.02 </%&-AB"# :;7=O34@'()*>?56CDE,+HI> !"#$[\]%&'()*+,-ST./01234567^8_9:;<=>?@ABCDEFGHIJKLMNOPQNoneIN -2 - 2 `    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a]bc]de]fg]hi]dj]klmnopqrstrea_IHwzw6b0vcLLSalgBcwa8I StreamingStreaming.InternalStreaming.Preludenext Data.ListsequencePipesProducermmorp_8dNpUU8QFPe77rrwKAb20bControl.Monad.MorphhoistMFunctortrans_3eG64VdP2vzGjP6wJiCp5XControl.Monad.Trans.Class MonadTransliftStreamStepDelayReturndestroy constructinspectunfoldmapsmapsM intercalatesiterTMiterTconcatssplitchunksOf$fMonadIOStream$fMFunctorStream$fMonadTransStream$fApplicativeStream $fMonadStream$fFunctorStreamOf:>lazilystrictlybreakchainconcatdraindrop dropWhileeachfilterfilterMfoldfold'foldMfoldM'foldrTfoldrMformap mapFoldablemapMmapM_maps'unconsproductproduct'readrepeatM replicateMscanscanMshowsumsum'spantake takeWhiletoListtoListMtoListM'unfoldryieldzipzipWithstdinLnreadLn fromHandletoHandleprintseqstdoutLn stdoutLn'base Data.FoldablefoldriterateiterateMGHC.BaseStringGHC.IO.Handle.FDstdinGHC.IO.Handle.TypesHandleGHC.IO.Handle.TexthGetLinestdout System.IOputStrLnenumFrom enumFromTo enumFromStepNrepeat replicate