Fix overview of Stream module

This commit is contained in:
Harendra Kumar 2024-01-26 20:27:18 +05:30
parent f1ae6209cd
commit 60b8920b26

View File

@ -8,16 +8,17 @@
-- Stability : released
-- Portability : GHC
--
-- Streamly is a framework for modular data flow based programming and
-- declarative concurrency. Powerful stream fusion framework in streamly
-- allows high performance combinatorial programming even when using byte level
-- streams. Streamly API is similar to Haskell lists.
-- The 'Stream' type represents a producer of a sequence of values, the
-- corresponding dual type is 'Streamly.Data.Fold.Fold' which represents a
-- consumer. Both types can perform equivalent transformations on a stream. But
-- only 'Fold' can be used to compose multiple consumers and only 'Stream' can
-- be used to compose multiple producers.
--
-- Streams are represented as state machines, that fuse together when composed
-- statically, eliminating function calls or intermediate constructor
-- allocations - generating tight, efficient loops similar to code generated by
-- low level languages like C. Suitable for high performance looping
-- operations.
-- The 'Stream' type represents streams as state machines, that fuse together
-- when composed statically, eliminating function calls or intermediate
-- constructor allocations. Stream fusion helps generate tight, efficient loops
-- similar to the code generated by low-level languages like C. Streams are
-- suitable for high-performance looping operations.
--
-- Operations in this module are not meant to be used recursively. In other
-- words, they are supposed to be composed statically rather than dynamically.
@ -25,6 +26,14 @@
-- stream operations from the "Streamly.Data.StreamK" module. 'Stream' and
-- 'Streamly.Data.StreamK.StreamK' types are interconvertible.
--
-- Operations in this module are designed to be composed statically rather than
-- dynamically. They are inlined to enable static fusion. More importantly,
-- they are not designed to be used recursively. Recursive use will break
-- fusion and will lead to quadratic performance slowdown. For dynamic or
-- recursive composition use the continuation passing style (CPS) operations
-- from the "Streamly.Data.StreamK" module. 'Stream' and
-- 'Streamly.Data.StreamK.StreamK' types are interconvertible.
--
-- Please refer to "Streamly.Internal.Data.Stream" for more functions that have
-- not yet been released.
--
@ -122,7 +131,7 @@ module Streamly.Data.Stream
-- to a list and converting it to stream. The following works but is not
-- particularly efficient:
--
-- >>> s from then = Stream.fromList $ Prelude.enumFromThen from then
-- >>> f from next = Stream.fromList $ Prelude.enumFromThen from next
--
-- Note: For lists, using enumeration functions e.g. 'Prelude.enumFromThen'
-- turns out to be slightly faster than the idioms like @[from, then..]@.