!\K+      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~(c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone +;<=>?DF]3v streamlyA monad that can perform concurrent or parallel IO operations. Streams that can be composed concurrently require the underlying monad to be .streamlyVAn SVar or a Stream Var is a conduit to the output from multiple streams running concurrently and asynchronously. An SVar can be thought of as an asynchronous IO handle. We can write any number of streams to an SVar in a non-blocking manner and then read them back at any time at any pace. The SVar would run the streams asynchronously and accumulate results. An SVar may not really execute the stream completely and accumulate all the results. However, it ensures that the reader can read the results at whatever paces it wants to read. The SVar monitors and adapts to the consumer's pace.An SVar is a mini scheduler, it has an associated workLoop that holds the stream tasks to be picked and run by a pool of worker threads. It has an associated output queue where the output stream elements are placed by the worker threads. A outputDoorBell is used by the worker threads to intimate the consumer thread about availability of new results in the output queue. More workers are added to the SVar by  fromStreamVar" on demand if the output produced is not keeping pace with the consumer. On bounded SVars, workers block on the output queue to provide throttling of the producer when the consumer is not pulling fast enough. The number of workers may even get reduced depending on the consuming pace.{New work is enqueued either at the time of creation of the SVar or as a result of executing the parallel combinators i.e. <| and <|>< when the already enqueued computations get evaluated. See joinStreamVarAsync.XXX can we use forall t m.streamlyhIdentify the type of the SVar. Two computations using the same style can be scheduled on the same SVar.streamly=Sorting out-of-turn outputs in a heap for Ahead style streamsstreamly7Events that a child thread may send to a parent thread.streamlyThis function is used by the producer threads to queue output for the consumer thread to consume. Returns whether the queue has more space.streamly}This is safe even if we are adding more threads concurrently because if a child thread is adding another thread then anyway  will not be empty.streamly<In contrast to pushWorker which always happens only from the consumer thread, a pushWorkerPar can happen concurrently from multiple threads on the producer side. So we need to use a thread safe modification of workerThreads. Alternatively, we can use a CreateThread event to avoid using a CAS based modification.streamlyWrite a stream to an Q in a non-blocking manner. The stream can then be read back from the SVar using fromSVar.8(c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone+.;<=>?DQV]qSstreamlySame as .streamlyDClass of types that can represent a stream of elements of some type a in some monad m.streamly_Constructs a stream by adding a monadic action at the head of an existing stream. For example: M> toList $ getLine `consM` getLine `consM` nil hello world ["hello","world"] Concurrent (do not use  parallely to construct infinite streams)streamlyOperator equivalent of . We can read it as "parallel colon" to remember that | comes before :. C> toList $ getLine |: getLine |: nil hello world ["hello","world"]  let delay = threadDelay 1000000 >> print 1 runStream $ serially $ delay |: delay |: delay |: nil runStream $ parallely $ delay |: delay |: delay |: nil Concurrent (do not use  parallely to construct infinite streams)streamly The type  Stream m a/ represents a monadic stream of values of type a% constructed using actions in monad ma. It uses stop, singleton and yield continuations equivalent to the following direct style type: <data Stream m a = Stop | Singleton a | Yield a (Stream m a) CTo facilitate parallel composition we maintain a local state in an W that is shared across and is used for synchronization of the streams being composed.The singleton case can be expressed in terms of stop and yield but we have it as a separate case to optimize composition operations for streams with single element. We build singleton streams in the implementation of $ for Applicative and Monad, and in  for MonadTrans. streamlyAAdapt any specific stream type to any other specific stream type.streamlyBuild a stream from an Q, a stop continuation, a singleton stream continuation and a yield continuation. streamlyAn empty stream. > toList nil [] streamlyuConstruct a stream by adding a pure value at the head of an existing stream. For serial streams this is the same as (return a) `consM` rM but more efficient. For concurrent streams this is not concurrent whereas  is concurrent. For example: 2> toList $ 1 `cons` 2 `cons` 3 `cons` nil [1,2,3] streamlyOperator equivalent of  . &> toList $ 1 .: 2 .: 3 .: nil [1,2,3] streamly.Make an empty stream from a callback function.streamly:Make a singleton stream from a one shot callback function.streamly,Construct a stream from a callback function.streamlyACreate a singleton stream from a pure value. In monadic streams,  or  can be used in place of ', however, in Zip applicative streams  is equivalent to .streamly9Create a singleton stream from a monadic action. Same as  m `consM` nil but more efficient. *> toList $ yieldM getLine hello ["hello"] streamlySame as yieldMstreamly6Generate an infinite stream by repeating a pure value.streamlyConstruct a stream from a  containing pure values.streamlylFold a stream by providing an SVar, a stop continuation, a singleton continuation and a yield continuation.streamlyLazy right associative fold.streamly-Lazy right fold with a monadic step function.streamlyStrict left fold with an extraction function. Like the standard strict left fold, but applies a user supplied extraction function (the third argument) to the folded value at the end. This is designed to work with the foldl library. The suffix x is a mnemonic for extraction.streamlyStrict left associative fold.streamlyLike #, but with a monadic step function.streamlyLike " but with a monadic step function.streamly/Extract the last element of the stream, if any.streamly[Apply a monadic action to each element of the stream and discard the output of the action.streamlyConcatenates two streams sequentially i.e. the first stream is exhausted completely before yielding any element from the second stream.? 55 5 5(c) 2018 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone+;<=>?CDQV] streamlypA stream consists of a step function that generates the next step given a current state, and the current state.streamlyA stream is a succession of s. A < produces a single value and the next state of the stream. 3 indicates there are no more values in the stream.streamly An empty .streamly#Can fuse but has O(n^2) complexity.streamlyCreate a singleton  from a pure value.streamlyCreate a singleton  from a monadic action.streamly'Convert a list of monadic actions to a streamly#Convert a list of pure values to a streamly1Run a streaming composition, discard the results.streamly1Execute a monadic action for each element of the streamlyMap a monadic function over a 2      !"#$%&'((c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone +.0;<=>?K streamlystreamly5An interleaving serial IO stream of elements of type a. See ! documentation for more details.streamlySWide serial composition or serial composition with a breadth first traversal. The  instance of  traverses the two streams in a breadth first manner. In other words, it interleaves two streams, yielding one element from each stream alternately. !import Streamly import qualified Streamly.Prelude as S main = (toList . ; $ (fromFoldable [1,2]) <> (fromFoldable [3,4])) >>= print   [1,3,2,4] Similarly, the )o instance interleaves the iterations of the inner and the outer loop, nesting loops in a breadth first manner. main =  runStream . \ $ do x <- return 1 <> return 2 y <- return 3 <> return 4 S.once $ print (x, y)  (1,3) (2,3) (1,4) (2,4) Note that a serial composition with breadth first traversal can only combine a finite number of streams as it needs to retain state for each unfinished stream.streamlystreamly'A serial IO stream of elements of type a. See ! documentation for more details.streamlyODeep serial composition or serial composition with depth first traversal. The  instance of  appends two streams serially in a depth first manner, yielding all elements from the first stream, and then all elements from the second stream. !import Streamly import qualified Streamly.Prelude as S main = (toList . ; $ (fromFoldable [1,2]) <> (fromFoldable [3,4])) >>= print   [1,2,3,4] The ) instance runs the monadic continuation+ for each element of the stream, serially. main =  runStream . 9 $ do x <- return 1 <> return 2 S.once $ print x  1 2 0 nests streams serially in a depth first manner. main =  runStream . \ $ do x <- return 1 <> return 2 y <- return 3 <> return 4 S.once $ print (x, y)  (1,3) (1,4) (2,3) (2,4) This behavior of  is exactly like a list transformer. We call the monadic code being run for each element of the stream a monadic continuation. In imperative paradigm we can think of this composition as nested foro loops and the monadic continuation is the body of the loop. The loop iterates for all elements of the stream.The : combinator can be omitted as the default stream type is . Note that serial composition with depth first traversal can be used to combine an infinite number of streams as it explores only one stream at a time.streamly(Fix the type of a polymorphic stream as .streamlyPolymorphic version of the  operation  of . Appends two streams sequentially, yielding all elements from the first stream, and then all elements from the second stream.streamly(Fix the type of a polymorphic stream as .streamlySame as .streamlyPolymorphic version of the  operation  of N. Interleaves two streams, yielding one element from each stream alternately.streamlySame as .*5(c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone +;<=>?DQV]+streamlyPull a stream from an SVar.,streamlyWrite a stream to an Q in a non-blocking manner. The stream can then be read back from the SVar using -.streamlyMSpecify the maximum number of threads that can be spawned concurrently when using concurrent streams. This is not the grand total number of threads but the maximum number of threads at each point of concurrency. A value of 0 resets the thread limit to default, a negative value means there is no limit. The default value is 1500.streamly;Specify the maximum size of the buffer for storing the results from concurrent computations. If the buffer becomes full we stop spawning more concurrent tasks until there is space in the buffer. A value of 0 resets the buffer size to default, a negative value means there is no limit. The default value is 1500.-,. (c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone +.0;<=>?K streamly4A parallely composing IO stream of elements of type a. See   documentation for more details. streamly=Async composition with simultaneous traversal of all streams.The Semigroup instance of   concurrently merges two streams, running both strictly concurrently and yielding elements from both streams as they arrive. When multiple streams are combined using   each one is evaluated in its own thread and the results produced are presented in the combined stream on a first come first serve basis.AsyncT and WAsyncT are concurrent lookahead streams each with a specific type of consumption pattern (depth first or breadth first). Since they are lookahead, they may introduce certain default latency in starting more concurrent tasks for efficiency reasons or may put a default limitation on the resource consumption (e.g. number of concurrent threads for lookahead). If we look at the implementation detail, they both can share a pool of worker threads to evaluate the streams in the desired pattern and at the desired rate. However,  9 uses a separate runtime thread to evaluate each stream.WAsyncT is similar to  z, as both of them evaluate the constituent streams fairly in a round robin fashion. However, the key difference is that WAsyncT! is lazy or pull driven whereas   is strict or push driven.  z immediately starts concurrent evaluation of both the streams (in separate threads) and later picks the results whereas WAsyncT may wait for a certain latency threshold before initiating concurrent evaluation of the next stream. The concurrent scheduling of the next stream or the degree of concurrency is driven by the feedback from the consumer. In case of  @ each stream is evaluated in a separate thread and results are pushedd to a shared output buffer, the evaluation rate is controlled by blocking when the buffer is full.@Concurrent lookahead streams are generally more efficient than   and can work pretty efficiently even for smaller tasks because they do not necessarily use a separate thread for each task. So they should be preferred over  d especially when efficiency is a concern and simultaneous strict evaluation is not a requirement.  ] is useful for cases when the streams are required to be evaluated simultaneously irrespective of how the consumer consumes them e.g. when we want to race two tasks and want to start both strictly at the same time or if we have timers in the parallel tasks and our results depend on the timers being started at the same time. We can say that  A is almost the same (modulo some implementation differences) as WAsyncT\ when the latter is used with unlimited lookahead and zero latency in initiating lookahead. main = (toList . &; $ (fromFoldable [1,2]) <> (fromFoldable [3,4])) >>= print   [1,3,2,4] zWhen streams with more than one element are merged, it yields whichever stream yields first without any bias, unlike the Async style streams.Any exceptions generated by a constituent stream are propagated to the output stream. The output and exceptions from a single stream are guaranteed to arrive in the same order in the resulting stream as they were generated in the input stream. However, the relative ordering of elements from different streams in the resulting stream can vary depending on scheduling and generation delays.Similarly, the ) instance of   runs all& iterations of the loop concurrently. import Streamly import qualified Streamly.Prelude( as S import Control.Concurrent main =  runStream . & $ do n <- return 3 <> return 2 <> return 1 S.once $ do threadDelay (n * 1000000) myThreadId >>= \tid -> putStrLn (show tid ++ ": Delay " ++ show n)  ?ThreadId 40: Delay 1 ThreadId 39: Delay 2 ThreadId 38: Delay 3 Note that parallel composition can only combine a finite number of streams as it needs to retain state for each unfinished stream./streamlynXXX we can implement it more efficienty by directly implementing instead of combining streams using parallel.!streamlyPolymorphic version of the  operation  of  " Merges two streams concurrently."streamlyiParallel function application operator for streams; just like the regular function application operator 0} except that it is concurrent. The following code prints a value every second even though each stage adds a 1 second delay. qrunStream $ S.mapM (\x -> threadDelay 1000000 >> print x) |$ S.repeatM (threadDelay 1000000 >> return 1)  Concurrent#streamlyyParallel reverse function application operator for streams; just like the regular reverse function application operator & except that it is concurrent. rrunStream $ S.repeatM (threadDelay 1000000 >> return 1) |& S.mapM (\x -> threadDelay 1000000 >> print x)  Concurrent$streamly2Parallel function application operator; applies a run or fold_ function to a stream such that the fold consumer and the stream producer run in parallel. A run or foldF function reduces the stream to a value in the underlying monad. The .I at the end of the operator is a mnemonic for termination of the stream. o S.foldlM' (\_ a -> threadDelay 1000000 >> print a) () |$. S.repeatM (threadDelay 1000000 >> return 1)  Concurrent%streamlylParallel reverse function application operator for applying a run or fold functions to a stream. Just like $' except that the operands are reversed. p S.repeatM (threadDelay 1000000 >> return 1) |&. S.foldlM' (\_ a -> threadDelay 1000000 >> print a) ()  Concurrent&streamly(Fix the type of a polymorphic stream as  .  !1"#$%&"0#1$0%1 (c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone +.0;<=>?Kw'streamly@A round robin parallely composing IO stream of elements of type a. See ( documentation for more details.(streamlyeWide async composition or async composition with breadth first traversal. The Semigroup instance of ( concurrently  traverses the composed streams using a depth first travesal or in a round robin fashion, yielding elements from both streams alternately. main = (toList . 0; $ (fromFoldable [1,2]) <> (fromFoldable [3,4])) >>= print   [1,3,2,4] Any exceptions generated by a constituent stream are propagated to the output stream. The output and exceptions from a single stream are guaranteed to arrive in the same order in the resulting stream as they were generated in the input stream. However, the relative ordering of elements from different streams in the resulting stream can vary depending on scheduling and generation delays.Similarly, the ) instance of ( runs all@ iterations fairly concurrently using a round robin scheduling. import Streamly import qualified Streamly.Prelude( as S import Control.Concurrent main =  runStream . 0 $ do n <- return 3 <> return 2 <> return 1 S.once $ do threadDelay (n * 1000000) myThreadId >>= \tid -> putStrLn (show tid ++ ": Delay " ++ show n)  ?ThreadId 40: Delay 1 ThreadId 39: Delay 2 ThreadId 38: Delay 3 Unlike *L all iterations are guaranteed to run fairly concurrently, unconditionally.Note that async composition with breadth first traversal can only combine a finite number of streams as it needs to retain state for each unfinished stream.)streamlyOA demand driven left biased parallely composing IO stream of elements of type a. See * documentation for more details.*streamly\Deep async composition or async composition with depth first traversal. In a left to right  composition it tries to yield elements from the left stream as long as it can, but it can run the right stream in parallel if it needs to, based on demand. The right stream can be run if the left stream blocks on IO or cannot produce elements fast enough for the consumer. main = (toList . .; $ (fromFoldable [1,2]) <> (fromFoldable [3,4])) >>= print   [1,2,3,4] Any exceptions generated by a constituent stream are propagated to the output stream. The output and exceptions from a single stream are guaranteed to arrive in the same order in the resulting stream as they were generated in the input stream. However, the relative ordering of elements from different streams in the resulting stream can vary depending on scheduling and generation delays.!Similarly, the monad instance of * may run each iteration concurrently based on demand. More concurrent iterations are started only if the previous iterations are not able to produce enough output for the consumer. import Streamly import qualified Streamly.Prelude( as S import Control.Concurrent main =  runStream . . $ do n <- return 3 <> return 2 <> return 1 S.once $ do threadDelay (n * 1000000) myThreadId >>= \tid -> putStrLn (show tid ++ ": Delay " ++ show n)  ?ThreadId 40: Delay 1 ThreadId 39: Delay 2 ThreadId 38: Delay 3 ?All iterations may run in the same thread if they do not block.Note that async composition with depth first traversal can be used to combine infinite number of streams as it explores only a bounded number of streams at a time.+streamlyEMake a stream asynchronous, triggers the computation and returns a stream in the underlying monad representing the output generated by the original computation. The returned action is exhaustible and must be drained once. If not drained fully we may have a thread blocked forever and once exhausted it will always return empty.2streamly;Create a new SVar and enqueue one stream computation on it.3streamly/Join two computations on the currently running  queue for concurrent execution. When we are using parallel composition, an SVar is passed around as a state variable. We try to schedule a new parallel computation on the SVar passed to us. The first time, when no SVar exists, a new SVar is created. Subsequently, 4n may get called when a computation already scheduled on the SVar is further evaluated. For example, when (a parallel b) is evaluated it calls a 4 to put a and b! on the current scheduler queue.The \ required by the current composition context is passed as one of the parameters. If the scheduling and composition style of the new computation being scheduled is different than the style of the current SVar, then we create a new SVar and schedule it on that. The newly created SVar joins as one of the computations on the current SVar queue.+Cases when we need to switch to a new SVar:(x parallel y) parallel (t parallel1 u) -- all of them get scheduled on the same SVar(x parallel y) parallel (t , u) -- t and uN get scheduled on a new child SVar because of the scheduling policy change.if we   a stream of type , to a stream of type Parallel1, we create a new SVar at the transitioning bind.When the stream is switching from disjunctive composition to conjunctive composition and vice-versa we create a new SVar to isolate the scheduling of the two.,streamlyPolymorphic version of the  operation  of *g. Merges two streams possibly concurrently, preferring the elements from the left one when available.-streamlySame as ,.5streamlykXXX we can implement it more efficienty by directly implementing instead of combining streams using async..streamly(Fix the type of a polymorphic stream as *.6streamlylXXX we can implement it more efficienty by directly implementing instead of combining streams using wAsync./streamlyPolymorphic version of the  operation  of (F. Merges two streams concurrently choosing elements from both fairly.0streamly(Fix the type of a polymorphic stream as (. '()*+7,-./0 (c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone +.0;<=>?Kd1streamly'A serial IO stream of elements of type a" with concurrent lookahead. See 2 documentation for more details.2streamlyfDeep ahead composition or ahead composition with depth first traversal. The semigroup composition of 24 appends streams in a depth first manner just like SerialTM except that it can produce elements concurrently ahead of time. It is like AsyncT except that AsyncT, produces the output as it arrives whereas 2* orders the output in the traversal order. main = (toList . 3; $ (fromFoldable [1,2]) <> (fromFoldable [3,4])) >>= print   [1,2,3,4] VAny exceptions generated by a constituent stream are propagated to the output stream.!Similarly, the monad instance of 2c may run each iteration concurrently ahead of time but presents the results in the same order as SerialT. import Streamly import qualified Streamly.Prelude( as S import Control.Concurrent main =  runStream . 3 $ do n <- return 3 <> return 2 <> return 1 S.once $ do threadDelay (n * 1000000) myThreadId >>= \tid -> putStrLn (show tid ++ ": Delay " ++ show n)  ?ThreadId 40: Delay 1 ThreadId 39: Delay 2 ThreadId 38: Delay 3 ?All iterations may run in the same thread if they do not block.Note that ahead composition with depth first traversal can be used to combine infinite number of streams as it explores only a bounded number of streams at a time.8streamlykXXX we can implement it more efficienty by directly implementing instead of combining streams using ahead.3streamly(Fix the type of a polymorphic stream as 2.4streamlyPolymorphic version of the  operation  of 2A. Merges two streams sequentially but with concurrent lookahead.1234 (c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone +.0;<=>?K 5streamly>An IO stream whose applicative instance zips streams wAsyncly.6streamlyLike 9P but zips in parallel, it generates all the elements to be zipped concurrently. main = (toList . > $ (,,) <$> s1 <*> s2 <*> s3) >>= print where s1 = fromFoldable [1, 2] s2 = fromFoldable [3, 4] s3 = fromFoldable [5, 6]  [(1,3,5),(2,4,6)] The 6 instance of this type works the same way as that of SerialT.7streamly>An IO stream whose applicative instance zips streams serially.8streamly9streamlyThe applicative instance of 9} zips a number of streams serially i.e. it produces one element from each stream serially and then zips all those elements. main = (toList . : $ (,,) <$> s1 <*> s2 <*> s3) >>= print where s1 = fromFoldable [1, 2] s2 = fromFoldable [3, 4] s3 = fromFoldable [5, 6]  [(1,3,5),(2,4,6)] The 6 instance of this type works the same way as that of SerialT.9streamly7Zip two streams serially using a pure zipping function.:streamly:Zip two streams serially using a monadic zipping function.:streamly(Fix the type of a polymorphic stream as 9.;streamlySame as :.<streamly}Zip two streams concurrently (i.e. both the elements being zipped are generated concurrently) using a pure zipping function.=streamly{Zip two streams asyncly (i.e. both the elements being zipped are generated concurrently) using a monadic zipping function.>streamly(Fix the type of a polymorphic stream as 6.?streamlySame as >. 567899::;<=>? (c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone +.0;<=>?KQV @streamlyZRun a streaming composition, discard the results. By default it interprets the stream as O, to run other types of streams use the type adapting combinators for example  runStream . asyncly.AstreamlySame as @BstreamlySame as  runStream.CstreamlySame as runStream . wSerially.DstreamlySame as runStream . parallely.EstreamlySame as runStream . asyncly.FstreamlySame as runStream . zipping.GstreamlySame as runStream . zippingAsync.Hstreamly A variant of  that allows you to fold a @ container of streams using the specified stream sum operation.  foldWith async $ map return [1..3]Istreamly A variant of ;9 that allows you to map a monadic streaming action on a F container and then fold it using the specified stream sum operation.  foldMapWith async return [1..3]JstreamlyLike Id but with the last two arguments reversed i.e. the monadic streaming function is the last argument. @ABCDEFGHIJ(c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone ;<=>?QV:7KstreamlyLDecompose a stream into its head and tail. If the stream is empty, returns <&. If the stream is non-empty, returns  Just (a, ma), where a is the head of the stream and ma its tail.LstreamlyBuild a stream by unfolding a pure step function starting from a seed. The step function returns the next element in the stream and the next seed value. When it is done it returns <# and the stream ends. For example, elet f b = if b > 3 then Nothing else Just (b, b + 1) in toList $ unfoldr f 0  [0,1,2,3] MstreamlyBuild a stream by unfolding a monadic step function starting from a seed. The step function returns the next element in the stream and the next seed value. When it is done it returns <# and the stream ends. For example, let f b = if b > 3 then return Nothing else print b >> return (Just (b, b + 1)) in runStream $ unfoldrM f 0   0 1 2 3 When run concurrently, the next unfold step can run concurrently with the processing of the output of the previous step. Note that more than one step cannot run concurrently as the next step depends on the output of the previous step. (asyncly $ S.unfoldrM (\n -> liftIO (threadDelay 1000000) >> return (Just (n, n + 1))) 0) & S.foldlM' (\_ a -> threadDelay 1000000 >> print a) ()  Concurrent Since: 0.1.0Pstreamly1Generate a stream by performing a monadic action n times. runStream $ serially $ S.replicateM 10 $ (threadDelay 1000000 >> print 1) runStream $ asyncly $ S.replicateM 10 $ (threadDelay 1000000 >> print 1)  ConcurrentQstreamlyCGenerate a stream by repeatedly executing a monadic action forever. runStream $ serially $ S.take 10 $ S.repeatM $ (threadDelay 1000000 >> print 1) runStream $ asyncly $ S.take 10 $ S.repeatM $ (threadDelay 1000000 >> print 1) &Concurrent, infinite (do not use with  parallely)RstreamlyIIterate a pure function from a seed value, streaming the results forever.SstreamlyMIterate a monadic function from a seed value, streaming the results forever.When run concurrently, the next iteration can run concurrently with the processing of the previous iteration. Note that more than one iteration cannot run concurrently as the next iteration depends on the output of the previous iteration. runStream $ serially $ S.take 10 $ S.iterateM (\x -> threadDelay 1000000 >> print x >> return (x + 1)) 0 runStream $ asyncly $ S.take 10 $ S.iterateM (\x -> threadDelay 1000000 >> print x >> return (x + 1)) 0  ConcurrentTstreamlyXConstruct a stream from a list containing pure values. This can be more efficient than # for lists as it can fuse the list.Ustreamly\Construct a stream from a list containing monadic actions. This can be more efficient than V8 especially for serial streams as it can fuse the list.VstreamlyConstruct a stream from a  containing monadic actions. runStream $ serially $ S.fromFoldableM $ replicate 10 (threadDelay 1000000 >> print 1) runStream $ asyncly $ S.fromFoldableM $ replicate 10 (threadDelay 1000000 >> print 1) Concurrent (do not use with  parallely on infinite containers)WstreamlySame as  fromFoldable.Xstreamly6Read lines from an IO Handle into a stream of Strings.YstreamlyYLazy right fold with a monadic step function. For example, to fold a stream into a list: `>> runIdentity $ foldrM (\x xs -> return (x : xs)) [] (serially $ fromFoldable [1,2,3]) [1,2,3] ZstreamlyGLazy right associative fold. For example, to fold a stream into a list: H>> runIdentity $ foldr (:) [] (serially $ fromFoldable [1,2,3]) [1,2,3] [streamlyStrict left fold with an extraction function. Like the standard strict left fold, but applies a user supplied extraction function (the third argument) to the folded value at the end. This is designed to work with the foldl library. The suffix x is a mnemonic for extraction.\streamly]streamlyStrict left associative fold.^streamlyLike [#, but with a monadic step function._streamly`streamlyLike ]" but with a monadic step function.astreamly&Determine whether the stream is empty.bstreamly0Extract the first element of the stream, if any.cstreamly8Extract all but the first element of the stream, if any.dstreamly/Extract the last element of the stream, if any.estreamly6Determine whether an element is present in the stream.fstreamly:Determine whether an element is not present in the stream.gstreamly#Determine the length of the stream.hstreamly?Determine whether all elements of a stream satisfy a predicate.istreamlyFDetermine whether any of the elements of a stream satisfy a predicate.jstreamly8Determine the sum of all elements of a stream of numberskstreamly<Determine the product of all elements of a stream of numberslstreamly*Determine the minimum element in a stream.mstreamly*Determine the maximum element in a stream.nstreamly[Apply a monadic action to each element of the stream and discard the output of the action.ostreamly5Convert a stream into a list in the underlying monad.pstreamly*Write a stream of Strings to an IO Handle.qstreamly3Strict left scan with an extraction function. Like ty, but applies a user supplied extraction function (the third argument) at each step. This is designed to work with the foldl library. The suffix x is a mnemonic for extraction.rstreamlysstreamlyLike t" but with a monadic step function.tstreamlyStrict left scan. Like ], but returns the folded value at each step, generating a stream of all intermediate fold results. The first element of the stream is the user supplied initial value, and the last element of the stream is the same as the result of ].ustreamly2Include only those elements that pass a predicate.vstreamlySame as u but with a monadic predicate.wstreamly Take first n/ elements from the stream and discard the rest.xstreamly<End the stream as soon as the predicate fails on an element.ystreamlySame as x but with a monadic predicate.zstreamlyDiscard first n, elements from the stream and take the rest.{streamlydDrop elements in the stream as long as the predicate succeeds and then take the rest of the stream.|streamlySame as { but with a monadic predicate.}streamly_Replace each element of the stream with the result of a monadic action applied on the element. runStream $ S.replicateM 10 (return 1) & (serially . S.mapM (\x -> threadDelay 1000000 >> print x)) runStream $ S.replicateM 10 (return 1) & (asyncly . S.mapM (\x -> threadDelay 1000000 >> print x)) Concurrent (do not use with  parallely on infinite streams)~streamlyOReduce a stream of monadic actions to a stream of the output of those actions. runStream $ S.replicateM 10 (return $ threadDelay 1000000 >> print 1) & (serially . S.sequence) runStream $ S.replicateM 10 (return $ threadDelay 1000000 >> print 1) & (asyncly . S.sequence) Concurrent (do not use with  parallely on infinite streams)streamlyMap a =0 returning function to a stream, filter out the <9 elements, and return a stream of values extracted from >.streamlyLike  but maps a monadic function.Concurrent (do not use with  parallely on infinite streams)streamlyPReturns the elements of the stream in reverse order. The stream must be finite.streamly:Zip two streams serially using a monadic zipping function.streamly7Zip two streams serially using a pure zipping function.D <=KLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~D KLMPQRSNOTUVXZY]`[^abcdefghimljknoptsquvwxyz{|}~<= Wr\_(c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCNone=e@  !"#$%&'()*+,-./0123456789:;>?@ABCDEFGHIJ@2*( 96@"#$%+4,/!HIJ.30&:> 1)'75ABCEDFG8;?-(c) 2017 Harendra KumarBSD3harendra.kumar@gmail.com experimentalGHCSafeJstreamlyXRun an action forever periodically at the given frequency specified in per second (Hz).streamlyRun a computation on every clock tick, the clock runs at the specified frequency. It allows running a computation at high frequency efficiently by maintaining a local clock and adjusting it with the provided base clock at longer intervals. The first argument is a base clock returning some notion of time in microseconds. The second argument is the frequency in per second (Hz). The third argument is the action to run, the action is provided the local time as an argument.(c) 2017 Harendra KumarBSD3harendra.kumar@gmail.comNoneK'? !"#$%&'()*+,-./01 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ]^_`abcdefghijklmnopqrstuvwxyz{|}~abmlnpqsw*^_`gStuvxy{|+abhgS^`_!lmsptuvwxy{|+  %streamly-0.4.0-GYtBJRcVhEDBfoDofG3zAXStreamlyStreamly.Prelude Streamly.Time Streamly.SVarStreamly.Streams.StreamKStreamly.Streams.StreamDStreamly.Streams.SerialStreamly.Streams.SVarStreamly.Streams.ParallelStreamly.Streams.AsyncStreamly.Streams.AheadStreamly.Streams.ZipStreamly.Streams.Prelude Data.FoldablefoldStreamly.TutorialbaseGHC.Base<> Semigroupstimessconcat MonadAsync StreamingIsStreamconsM|:adaptnilcons.:oncerepeat fromFoldable InterleavedTWSerialWSerialTStreamTSerialSerialTseriallyserialmap wSerially interleavingwSerial<=> maxThreads maxBufferParallel ParallelTparallel|$|&|$.|&. parallelyWAsyncWAsyncTAsyncAsyncTmkAsyncasync<|asynclywAsyncwAsynclyAheadAheadTaheadlyaheadZipAsync ZipAsyncM ZipSerial ZipStream ZipSerialM zipSeriallyzipping zipAsyncWith zipAsyncWithM zipAsyncly zippingAsync runStream runStreaming runStreamTrunInterleavedT runParallelT runAsyncT runZipStream runZipAsyncfoldWith foldMapWith forEachWithunconsunfoldrunfoldrMyieldyieldM replicateMrepeatMiterateiterateMfromList fromListM fromFoldableMeach fromHandlefoldrMfoldrfoldxfoldlfoldl'foldxMfoldlMfoldlM'nullheadtaillastelemnotElemlengthallanysumproductminimummaximummapM_toListtoHandlescanxscanscanlM'scanl'filterfilterMtake takeWhile takeWhileMdrop dropWhile dropWhileMmapMsequencemapMaybe mapMaybeMreversezipWithMzipWithperiodic withClockSVar SVarStyleAheadHeapEntry ChildEventsendallThreadsDone workerThreads pushWorkerPar toStreamVarState streamVar yieldLimit threadsHigh bufferHigh svarStyle outputQueue maxYieldLimitoutputDoorBell readOutputQ postProcessenqueue isWorkDone needDoorBellworkLoop workerCount accountThreadAsyncVar WAsyncVar ParallelVarAheadVarAheadEntryPureAheadEntryStream ChildYield ChildStopdefaultMaxThreadsdefaultMaxBufferdefStaterstStateatomicModifyIORefCAS sendYieldsendStop enqueueLIFO workLoopLIFO enqueueFIFO workLoopFIFO enqueueAheadqueueEmptyAhead dequeueAheaddequeueFromHeap delThreadreadOutputQBoundedpostProcessBounded sendWorker newAheadVarnewParallelVarStreampuretransformers-0.5.5.0Control.Monad.Trans.ClassliftmkStreamnilKyieldKconsKreturnFoldable foldStreamtoStream fromStreamunStream consMSerial fromStreamK toStreamKbindWith withLocalStepYieldStop enumFromStepNMonad fromStreamVartoSVarfromSVar maxYields consMParallel$ mkParallel newWAsyncVar forkSVarAsyncjoinStreamVarAsync consMAsync consMWAsyncmkAsync' consMAheadfoldMapNothingMaybeJust