See API Changelog for a complete list of signature changes and new APIs introduced.
Streamly.Prelude
fold
: this function may now terminate early without consuming the entire stream. For example, fold Fold.head stream
would now terminate immediately after consuming the head element from stream
. This may result in change of behavior in existing programs if the program relies on the evaluation of the full stream.Streamly.Data.Unicode.Stream
Streamly.Data.Fold
:
Streamly.Data.Fold.Tee
module, please use the Tee
type to adapt to the changes.Streamly.Prelude
:
bracket
, handle
, and finally
now also work correctly on streams that aren’t fully drained. Also, the resource acquisition and release is atomic with respect to async exceptions.iterate
, iterateM
now consume O(1) space instead of O(n).fromFoldableM
is fixed to be concurrent.Streamly.Network.Inet.TCP
: accept
and connect
APIs now close the socket if an exception is thrown.Streamly.Network.Socket
: accept
now closes the socket if an exception is thrown.use-c-malloc
build flag to use the c library malloc
for array allocations. This could be useful to avoid pinned memory fragmentation.Breaking changes:
Fold
type has changed to accommodate terminating folds.Streamly.Internal.Prelude
=> Streamly.Internal.Data.Stream.IsStream
Bug fixes:
MicroSecond64
and MilliSecond64
(commit e5119626)classifySessionsBy
now flushes sessions at the end and terminates.Applicative
and Functor
instances of the Fold
data type.stack
or stack ghci
.primitive
package version >= 0.5.4 && <= 0.6.4.0QuickCheck
package version >= 2.14 && < 2.15.findIndices
to return wrong indices in some cases.tap
, chunksOf
that caused memory consumption to increase in some cases.async
, wAsync
, and ahead
) that caused memory consumption to increase with the number of elements in the stream, especially when built with -threaded
and used with -N
RTS option. The issue occurs only in cases when a worker thread happens to be used continuously for a long time.containers
package version < 0.5.8.network
package version >= 3.0.0.0 && < 3.1.0.0.Streamly.Network.Inet.TCP
no longer use TCP NoDelay
and ReuseAddr
socket options by default. These options can now be specified using appropriate combinators.fusion-plugin
package for predictable stream fusion optimizationsFoldable
instance.foldrM
to ensure that it is lazyiterateM
to ensure that it is lazy.scanx
would now require an additional Monad m
constraint.ParallelT
was unaffected by maxBuffer
directive, now maxBuffer
can limit the buffer of a ParallelT
stream as well. When the buffer becomes full, the producer threads block.ParallelT
streams no longer have an unlimited buffer by default. Now the buffer for parallel streams is limited to 1500 by default, the same as other concurrent stream types.Streamly.Prelude
:
runStream
has been replaced by drain
runN
has been replaced by drainN
runWhile
has been replaced by drainWhile
fromHandle
has been deprecated. Please use Streamly.FileSystem.Handle.read
, Streamly.Data.Unicode.Stream.decodeUtf8
and splitOnSuffix
with Streamly.Data.Fold.toList
to split the stream to a stream of String
separated by a newline.toHandle
has been deprecated. Please use intersperse
and concatUnfold
to add newlines to a stream, Streamly.Data.Unicode.Stream.encodeUtf8
for encoding and Streamly.FileSystem.Handle.write
for writing to a file handle.scanx
, foldx
, foldxM
, foldr1
foldl
, foldlM
scan
with a new signature, to scan using Fold.Streamly
module:
runStream
has been deprecated, please use Streamly.Prelude.drain
Streamly.Time
(moved to Streamly.Internal.Data.Time)Streamly.Internal
(functionality moved to the Internal hierarchy)uniq
function to yield the same element twice.parallel
combinator. The bug manifests when large streams are combined using parallel
.This release contains a lot of new features and major enhancements. For more details on the new features described below please see the haddock docs of the modules on hackage.
See Streamly.Prelude
for new exception handling combinators like before
, after
, bracket
, onException
, finally
, handle
etc.
Streamly.Data.Fold
module provides composable folds (stream consumers). Folds allow splitting, grouping, partitioning, unzipping and nesting a stream onto multiple folds without breaking the stream. Combinators are provided for temporal and spatial window based fold operations, for example, to support folding and aggregating data for timeout or inactivity based sessions.
Streamly.Data.Unfold
module provides composable stream generators. Unfolds allow high performance merging/flattening/combining of stream generators.
Streamly.FileSystem.Handle
provides handle based streaming file IO operations.
Streamly.Network.Socket
provides socket based streaming network IO operations.
Streamly.Network.Inet.TCP
provides combinators to build Inet/TCP clients and servers.
The new concatMapWith
in Streamly.Prelude
combinator performs a concatMap
using a supplied merge/concat strategy. This is a very powerful combinator as you can, for example, concat streams concurrently using this.
Streamly.Data.Unicode.Stream
module provides encoding/decoding of character streams and other character stream operations.Streamly.Memory.Array
module provides arrays for efficient in-memory buffering and efficient interfacing with IO.Streamly.Prelude
:
unfold
, fold
, scan
and postscan
concatUnfold
to concat a stream after unfolding each elementintervalsOf
and chunksOf
splitOn
, splitOnSuffix
, splitWithSuffix
, and wordsBy
groups
, groupsBy
and groupsByRolling
postscanl'
and postscanlM'
intersperse
intersperse an element in between consecutive elements in streamtrace
combinator maps a monadic function on a stream just for side effectstap
redirects a copy of the stream to a Fold
maxThreads
directive to be ignored when rate control was not used.Monad
constraint may be needed on some of the existing APIs (findIndices
and elemIndices
).replicate
, fromIndices
, fromIndicesM
Enumerable
type class, enumerateFrom
, enumerateFromTo
, enumerateFromThen
, enumerateFromThenTo
, enumerate
, enumerateTo
runN
, runWhile
(!!)
, maximumBy
, minimumBy
, the
scanl1'
, `scanl1M’uniq
, insertBy
, deleteBy
, findM
eqBy
, cmpBy
, mergeBy
, mergeByM
, mergeAsyncBy
, mergeAsyncByM
, isPrefixOf
, isSubsequenceOf
, stripPrefix
, concatMap
, concatMapM
, indexed
, indexedR
SerialT m
, WSerialT m
and ZipSerialM m
:
m
~ Identity
: IsList, Eq, Ord, Show, Read, IsString, NFData, NFData1, Traversablem
is Foldable
: FoldableStateT
. Particularly, this bug cannot affect ReaderT
.parallel
, async
, wAsync
, ahead
, serial
, wSerial
combinators. Without this fix combinators that rely on state passing e.g. maxThreads
and maxBuffer
won’t work across these combinators.rate
, avgRate
, minRate
, maxRate
and constRate
to control the yield rate of a stream.foldl1'
, foldr1
, intersperseM
, find
, lookup
, and
, or
, findIndices
, findIndex
, elemIndices
, elemIndex
, init
to PreludeStreamly.Time
module is now deprecated, its functionality is subsumed by the new rate limiting combinators.zipWithM
and zipAsyncWithM
have changedMonad
constraint on the underlying type of the stream.once
has been deprecated and renamed to yieldM
maxThreads
and maxBuffer
.take
is now limited by the number of elements demanded by take
.yield
to construct a singleton stream from a pure valuerepeat
to generate an infinite stream by repeating a pure valuefromList
and fromListM
to generate streams from lists, faster than fromFoldable
and fromFoldableM
map
as a synonym of fmapscanlM'
, the monadic version of scanl’takeWhileM
and dropWhileM
filterM
MonadAsync
constraint.Ahead
fromFoldableM
API that creates a stream from a container of monadic actionsconsM
, |:
, unfoldrM
, replicateM
, repeatM
, iterateM
and fromFoldableM
can now generate streams concurrently when used with concurrent stream types.mapM
and sequence
can now map actions concurrently when used at appropriate stream types.mapMaybe
and mapMaybeM
.take
, filter
, takeWhile
, drop
, dropWhile
, and reverse
.Changed the semantics of the Semigroup instance for InterleavedT
, AsyncT
and ParallelT
. The new semantics are as follows:
InterleavedT
, <>
operation interleaves two streamsAsyncT
, <>
now concurrently merges two streams in a left biased manner using demand based concurrency.ParallelT
, the <>
operation now concurrently meges the two streams in a fairly parallel manner.To adapt to the new changes, replace <>
with serial
wherever it is used for stream types other than StreamT
.
Remove the Alternative
instance. To adapt to this change replace any usage of <|>
with parallel
and empty
with nil
.
Stream type now defaults to the SerialT
type unless explicitly specified using a type combinator or a monomorphic type. This change reduces puzzling type errors for beginners. It includes the following two changes:
SerialT
instead of a polymorphic type. This makes sure that the stream type is always fixed at all exits.parallely
) to only fix the argument stream type and the output stream type remains polymorphic.Stream types may have to be changed or type combinators may have to be added or removed to adapt to this change.
Change the type of foldrM
to make it consistent with foldrM
in base.
async
is renamed to mkAsync
and async
is now a new API with a different meaning.
ZipAsync
is renamed to ZipAsyncM
and ZipAsync
is now ZipAsyncM specialized to the IO Monad.
Remove the MonadError
instance as it was not working correctly for parallel compositions. Use MonadThrow
instead for error propagation.
Remove Num/Fractional/Floating instances as they are not very useful. Use fmap
and liftA2
instead.
Streaming
to IsStream
runStreaming
to runStream
StreamT
to SerialT
InterleavedT
to WSerialT
ZipStream
to ZipSerialM
ZipAsync
to ZipAsyncM
interleaving
to wSerially
zipping
to zipSerially
zippingAsync
to zipAsyncly
<=>
to wSerial
<|
to async
each
to fromFoldable
scan
to scanx
foldl
to foldx
foldlM
to foldxM
runStreamT
runInterleavedT
runAsyncT
runParallelT
runZipStream
runZipAsync
consM
and |:
operator to construct streams from monadic actionsonce
to create a singleton stream from a monadic actionrepeatM
to construct a stream by repeating a monadic actionscanl'
strict left scanfoldl'
strict left foldfoldlM'
strict left fold with a monadic fold functionserial
run two streams serially one after the otherasync
run two streams asynchronouslyparallel
run two streams in parallel (replaces <|>
)WAsyncT
stream type for BFS version of AsyncT
compositioniterate
, iterateM
stream operationspure
was used to inject values in Applicative composition of ZipStream
and ZipAsync
types.cons
right associative and provide an operator form .:
for itnull
, tail
, reverse
, replicateM
, scan
stream operationsfoldl
, dropWhile
)product
operation. Earlier, it always returned 0 due to a buglast
operation, which returned Nothing
for singleton streams