on master help sign in
remove duplication between exposed/internal modules
a59c72cHarendra Kumar
src/Streamly/Internal/Prelude.hs+71−9
@@ -20,6 +20,11 @@
20-- Stability : experimental
20-- Stability : experimental
21-- Portability : GHC
21-- Portability : GHC
22--
22--
23+-- This is an Internal module consisting of released, unreleased and
24+-- unimplemented APIs. For stable and released APIs please see
25+-- "Streamly.Prelude" module. This module provides documentation only for the
26+-- unreleased and unimplemented APIs. For documentation on released APIs please
27+-- see "Streamly.Prelude" module.
23
28
24module Streamly.Internal.Prelude
29module Streamly.Internal.Prelude
25 (
30 (
@@ -98,7 +103,7 @@ module Streamly.Internal.Prelude
98 , length
103 , length
99 , sum
104 , sum
100 , product
105 , product
101− --, mconcat
106+ , mconcat
102
107
103 -- -- ** To Summary (Maybe) (Full Folds)
108 -- -- ** To Summary (Maybe) (Full Folds)
104 , maximumBy
109 , maximumBy
@@ -168,6 +173,9 @@ module Streamly.Internal.Prelude
168 , scan
173 , scan
169 , postscan
174 , postscan
170
175
176+ -- XXX Once we have pipes the contravariant transformations can be
177+ -- represented by attaching pipes before a transformation.
178+ --
171 -- , lscanl'
179 -- , lscanl'
172 -- , lscanlM'
180 -- , lscanlM'
173 -- , lscanl1'
181 -- , lscanl1'
@@ -219,14 +227,25 @@ module Streamly.Internal.Prelude
219 -- ** Mapping Filters
227 -- ** Mapping Filters
220 , mapMaybe
228 , mapMaybe
221 , mapMaybeM
229 , mapMaybeM
230+
231+ -- ** Window map
222 , rollingMapM
232 , rollingMapM
223 , rollingMap
233 , rollingMap
224
234
225 -- ** Scanning Filters
235 -- ** Scanning Filters
236+ -- -- *** Searching Elements
226 , findIndices
237 , findIndices
227 , elemIndices
238 , elemIndices
239+
240+ -- -- *** Searching Sequences
228 -- , seqIndices -- search a sequence in the stream
241 -- , seqIndices -- search a sequence in the stream
229
242
243+ -- -- *** Searching Multiple Sequences
244+ -- , seqIndicesAny -- search any of the given sequence in the stream
245+
246+ -- -- -- ** Searching Streams
247+ -- -- | Finding a stream within another stream.
248+
230 -- ** Insertion
249 -- ** Insertion
231 , insertBy
250 , insertBy
232 , intersperseM
251 , intersperseM
@@ -234,6 +253,11 @@ module Streamly.Internal.Prelude
234 , intersperseSuffix
253 , intersperseSuffix
235 , intersperseSuffixBySpan
254 , intersperseSuffixBySpan
236 -- , intersperseBySpan
255 -- , intersperseBySpan
256+ -- , intersperseByIndices -- using an index function/stream
257+
258+ -- time domain intersperse
259+ -- , intersperseByTime
260+ -- , intersperseByEvent
237 , interjectSuffix
261 , interjectSuffix
238 , delayPost
262 , delayPost
239
263
@@ -276,24 +300,33 @@ module Streamly.Internal.Prelude
276 , Z.zipAsyncWith
300 , Z.zipAsyncWith
277 , Z.zipAsyncWithM
301 , Z.zipAsyncWithM
278
302
279− -- ** Nested Streams
303+ -- ** Flattening Nested Streams
280 , concatMapM
304 , concatMapM
281 , concatM
305 , concatM
306+ , concatMap
307+ -- XXX add stateful concatMapWith?
308+ , concatMapWith
309+ -- , bindWith
310+
311+ -- ** Flattening Using Unfolds
282 , concatUnfold
312 , concatUnfold
283 , concatUnfoldInterleave
313 , concatUnfoldInterleave
284 , concatUnfoldRoundrobin
314 , concatUnfoldRoundrobin
285− , concatMap
315+
286− , concatMapWith
316+ -- ** Feedback Loops
317+ , concatMapIterateWith
318+ , concatMapTreeWith
319+ , concatMapLoopWith
320+ , concatMapTreeYieldLeavesWith
321+
322+ -- ** Inserting Streams in Streams
287 , gintercalate
323 , gintercalate
288 , gintercalateSuffix
324 , gintercalateSuffix
289 , intercalate
325 , intercalate
290 , intercalateSuffix
326 , intercalateSuffix
291 , interpose
327 , interpose
292 , interposeSuffix
328 , interposeSuffix
293− , concatMapIterateWith
329+ -- , interposeBy
294− , concatMapTreeWith
295− , concatMapLoopWith
296− , concatMapTreeYieldLeavesWith
297
330
298 -- -- ** Breaking
331 -- -- ** Breaking
299
332
@@ -312,8 +345,18 @@ module Streamly.Internal.Prelude
312
345
313 -- By sequences
346 -- By sequences
314 -- , breakOnSeq
347 -- , breakOnSeq
348+ -- , breakOnStream -- on a stream
315
349
316 -- ** Splitting
350 -- ** Splitting
351+ -- | Streams can be sliced into segments in space or in time. We use the
352+ -- term @chunk@ to refer to a spatial length of the stream (spatial window)
353+ -- and the term @session@ to refer to a length in time (time window).
354+
355+ -- In imperative terms, grouped folding can be considered as a nested loop
356+ -- where we loop over the stream to group elements and then loop over
357+ -- individual groups to fold them to a single value that is yielded in the
358+ -- output stream.
359+
317 -- , groupScan
360 -- , groupScan
318
361
319 -- -- *** Chunks
362 -- -- *** Chunks
@@ -332,7 +375,7 @@ module Streamly.Internal.Prelude
332 -- , splitByPrefix
375 -- , splitByPrefix
333 , wordsBy -- stripAndCompactBy
376 , wordsBy -- stripAndCompactBy
334
377
335− -- -- *** Using Sequence Separators
378+ -- -- *** Splitting By Sequences
336 , splitOnSeq
379 , splitOnSeq
337 , splitOnSuffixSeq
380 , splitOnSuffixSeq
338 -- , splitOnPrefixSeq
381 -- , splitOnPrefixSeq
@@ -348,6 +391,9 @@ module Streamly.Internal.Prelude
348 -- , splitOnAnySuffixSeq
391 -- , splitOnAnySuffixSeq
349 -- , splitOnAnyPrefixSeq
392 -- , splitOnAnyPrefixSeq
350
393
394+ -- -- *** Splitting By Streams
395+ -- | Splitting a stream using another stream as separator.
396+
351 -- Nested splitting
397 -- Nested splitting
352 , splitInnerBy
398 , splitInnerBy
353 , splitInnerBySuffix
399 , splitInnerBySuffix
@@ -367,17 +413,33 @@ module Streamly.Internal.Prelude
367
413
368 -- * Windowed Classification
414 -- * Windowed Classification
369
415
416+ -- | Split the stream into windows or chunks in space or time. Each window
417+ -- can be associated with a key, all events associated with a particular
418+ -- key in the window can be folded to a single result. The stream is split
419+ -- into windows of specified size, the window can be terminated early if
420+ -- the closing flag is specified in the input stream.
421+ --
422+ -- The term "chunk" is used for a space window and the term "session" is
423+ -- used for a time window.
424+
370 -- ** Tumbling Windows
425 -- ** Tumbling Windows
426+ -- | A new window starts after the previous window is finished.
427+
371 -- , classifyChunksOf
428 -- , classifyChunksOf
372 , classifySessionsBy
429 , classifySessionsBy
373 , classifySessionsOf
430 , classifySessionsOf
374
431
375 -- ** Keep Alive Windows
432 -- ** Keep Alive Windows
433+ -- | The window size is extended if an event arrives within the specified
434+ -- window size. This can represent sessions with idle or inactive timeout.
435+
376 -- , classifyKeepAliveChunks
436 -- , classifyKeepAliveChunks
377 , classifyKeepAliveSessions
437 , classifyKeepAliveSessions
378
438
379 {-
439 {-
380 -- ** Sliding Windows
440 -- ** Sliding Windows
441+ -- | A new window starts after the specified slide from the previous
442+ -- window. Therefore windows can overlap.
381 , classifySlidingChunks
443 , classifySlidingChunks
382 , classifySlidingSessions
444 , classifySlidingSessions
383 -}
445 -}
src/Streamly/Prelude.hs−138
@@ -174,8 +174,6 @@ module Streamly.Prelude
174 -- ** Right Folds
174 -- ** Right Folds
175 -- $rightfolds
175 -- $rightfolds
176 , foldrM
176 , foldrM
177− -- , foldrS
178− -- , foldrT
179 , foldr
177 , foldr
180
178
181 -- ** Left Folds
179 -- ** Left Folds
@@ -199,7 +197,6 @@ module Streamly.Prelude
199 , length
197 , length
200 , sum
198 , sum
201 , product
199 , product
202− --, mconcat
203
200
204 -- -- ** To Summary (Maybe) (Full Folds)
201 -- -- ** To Summary (Maybe) (Full Folds)
205 -- -- | Folds that summarize a non-empty stream to a 'Just' value and return
202 -- -- | Folds that summarize a non-empty stream to a 'Just' value and return
@@ -209,7 +206,6 @@ module Streamly.Prelude
209 , minimumBy
206 , minimumBy
210 , minimum
207 , minimum
211 , the
208 , the
212− -- , toListRev -- experimental
213
209
214 -- ** Lazy Folds
210 -- ** Lazy Folds
215 --
211 --
@@ -252,19 +248,13 @@ module Streamly.Prelude
252 , eqBy
248 , eqBy
253 , cmpBy
249 , cmpBy
254 , isPrefixOf
250 , isPrefixOf
255− -- , isSuffixOf
256− -- , isInfixOf
257 , isSubsequenceOf
251 , isSubsequenceOf
258
252
259 -- trimming sequences
253 -- trimming sequences
260 , stripPrefix
254 , stripPrefix
261− -- , stripSuffix
262− -- , stripInfix
263
255
264 -- * Transformation
256 -- * Transformation
265
257
266− --, transform
267−
268 -- ** Mapping
258 -- ** Mapping
269 -- | In imperative terms a map operation can be considered as a loop over
259 -- | In imperative terms a map operation can be considered as a loop over
270 -- the stream that transforms the stream into another stream by performing
260 -- the stream that transforms the stream into another stream by performing
@@ -343,8 +333,6 @@ module Streamly.Prelude
343 , scanlM'
333 , scanlM'
344 , postscanl'
334 , postscanl'
345 , postscanlM'
335 , postscanlM'
346− -- , prescanl'
347− -- , prescanlM'
348 , scanl1'
336 , scanl1'
349 , scanl1M'
337 , scanl1M'
350
338
@@ -352,16 +340,6 @@ module Streamly.Prelude
352 , scan
340 , scan
353 , postscan
341 , postscan
354
342
355− -- , lscanl'
356− -- , lscanlM'
357− -- , lscanl1'
358− -- , lscanl1M'
359− --
360− -- , lpostscanl'
361− -- , lpostscanlM'
362− -- , lprescanl'
363− -- , lprescanlM'
364−
365 -- ** Filtering
343 -- ** Filtering
366 -- | Remove some elements from the stream based on a predicate. In
344 -- | Remove some elements from the stream based on a predicate. In
367 -- imperative terms a filter over a stream corresponds to a loop with a
345 -- imperative terms a filter over a stream corresponds to a loop with a
@@ -380,9 +358,6 @@ module Streamly.Prelude
380 -- | Deleting elements is a special case of de-interleaving streams.
358 -- | Deleting elements is a special case of de-interleaving streams.
381 , deleteBy
359 , deleteBy
382 , uniq
360 , uniq
383− -- , uniqBy -- by predicate e.g. to remove duplicate "/" in a path
384− -- , uniqOn -- to remove duplicate sequences
385− -- , pruneBy -- dropAround + uniqBy - like words
386
361
387 -- ** Inserting Elements
362 -- ** Inserting Elements
388 -- | Inserting elements is a special case of interleaving/merging streams.
363 -- | Inserting elements is a special case of interleaving/merging streams.
@@ -390,73 +365,27 @@ module Streamly.Prelude
390 , insertBy
365 , insertBy
391 , intersperseM
366 , intersperseM
392 , intersperse
367 , intersperse
393− -- , insertAfterEach
394− -- , intersperseBySpan
395− -- , intersperseByIndices -- using an index function/stream
396− -- , intersperseByTime
397− -- , intersperseByEvent
398−
399− -- -- * Inserting Streams in Streams
400− -- , interposeBy
401− -- , intercalate
402
368
403 -- ** Indexing
369 -- ** Indexing
404 -- | Indexing can be considered as a special type of zipping where we zip a
370 -- | Indexing can be considered as a special type of zipping where we zip a
405 -- stream with an index stream.
371 -- stream with an index stream.
406 , indexed
372 , indexed
407 , indexedR
373 , indexedR
408− -- , timestamped
409− -- , timestampedR -- timer
410
374
411 -- ** Reordering Elements
375 -- ** Reordering Elements
412 , reverse
376 , reverse
413− -- , reverse'
414
377
415 -- ** Trimming
378 -- ** Trimming
416 -- | Take or remove elements from one or both ends of a stream.
379 -- | Take or remove elements from one or both ends of a stream.
417 , take
380 , take
418− -- , takeEnd
419 , takeWhile
381 , takeWhile
420 , takeWhileM
382 , takeWhileM
421− -- , takeWhileEnd
422 , drop
383 , drop
423− -- , dropEnd
424 , dropWhile
384 , dropWhile
425 , dropWhileM
385 , dropWhileM
426− -- , dropWhileEnd
427− -- , dropAround
428
386
429 -- -- ** Breaking
387 -- -- ** Breaking
430
388
431− -- By chunks
432− -- , splitAt -- spanN
433− -- , splitIn -- sessionN
434−
435− -- By elements
436− -- , span -- spanWhile
437− -- , break -- breakBefore
438− -- , breakAfter
439− -- , breakOn
440− -- , breakAround
441− -- , spanBy
442− -- , spanByRolling
443−
444− -- By sequences
445− -- breakOnSeq/breakOnArray -- on a fixed sequence
446− -- breakOnStream -- on a stream
447−
448− -- ** Slicing
449− -- | Streams can be sliced into segments in space or in time. We use the
450− -- term @chunk@ to refer to a spatial length of the stream (spatial window)
451− -- and the term @session@ to refer to a length in time (time window).
452−
453− -- In imperative terms, grouped folding can be considered as a nested loop
454− -- where we loop over the stream to group elements and then loop over
455− -- individual groups to fold them to a single value that is yielded in the
456− -- output stream.
457−
458− -- , groupScan
459−
460 , chunksOf
389 , chunksOf
461 , intervalsOf
390 , intervalsOf
462
391
@@ -468,15 +397,6 @@ module Streamly.Prelude
468 , findIndices
397 , findIndices
469 , elemIndices
398 , elemIndices
470
399
471− -- -- *** Searching Sequences
472− -- , seqIndices -- search a sequence in the stream
473−
474− -- -- *** Searching Multiple Sequences
475− -- , seqIndices -- search a sequence in the stream
476−
477− -- -- ** Searching Streams
478− -- -- | Finding a stream within another stream.
479−
480 -- ** Splitting
400 -- ** Splitting
481 -- | In general we can express splitting in terms of parser combinators.
401 -- | In general we can express splitting in terms of parser combinators.
482 -- These are some common use functions for convenience and efficiency.
402 -- These are some common use functions for convenience and efficiency.
@@ -502,32 +422,10 @@ module Streamly.Prelude
502 -- -- ** Splitting By Elements
422 -- -- ** Splitting By Elements
503 , splitOn
423 , splitOn
504 , splitOnSuffix
424 , splitOnSuffix
505− -- , splitOnPrefix
506
425
507− -- , splitBy
508 , splitWithSuffix
426 , splitWithSuffix
509− -- , splitByPrefix
510 , wordsBy -- strip, compact and split
427 , wordsBy -- strip, compact and split
511
428
512− -- -- *** Splitting By Sequences
513− -- , splitOnSeq
514− -- , splitOnSuffixSeq
515− -- , splitOnPrefixSeq
516−
517− -- Keeping the delimiters
518− -- , splitBySeq
519− -- , splitBySeqSuffix
520− -- , splitBySeqPrefix
521− -- , wordsBySeq
522−
523− -- Splitting By Multiple Sequences
524− -- , splitOnAnySeq
525− -- , splitOnAnySuffixSeq
526− -- , splitOnAnyPrefixSeq
527−
528− -- -- ** Splitting By Streams
529− -- -- | Splitting a stream using another stream as separator.
530−
531 -- ** Grouping
429 -- ** Grouping
532 -- | Splitting a stream by combining multiple contiguous elements into
430 -- | Splitting a stream by combining multiple contiguous elements into
533 -- groups using some criterion.
431 -- groups using some criterion.
@@ -535,40 +433,6 @@ module Streamly.Prelude
535 , groupsBy
433 , groupsBy
536 , groupsByRolling
434 , groupsByRolling
537
435
538− {-
539− -- * Windowed Classification
540− -- | Split the stream into windows or chunks in space or time. Each window
541− -- can be associated with a key, all events associated with a particular
542− -- key in the window can be folded to a single result. The stream is split
543− -- into windows of specified size, the window can be terminated early if
544− -- the closing flag is specified in the input stream.
545− --
546− -- The term "chunk" is used for a space window and the term "session" is
547− -- used for a time window.
548−
549− -- ** Tumbling Windows
550− -- | A new window starts after the previous window is finished.
551− -- , classifyChunksOf
552− -- , classifySessionsOf
553−
554− -- ** Keep Alive Windows
555− -- | The window size is extended if an event arrives within the specified
556− -- window size. This can represent sessions with idle or inactive timeout.
557− -- , classifyKeepAliveChunks
558− -- , classifyKeepAliveSessions
559−
560− {-
561− -- ** Sliding Windows
562− -- | A new window starts after the specified slide from the previous
563− -- window. Therefore windows can overlap.
564− , classifySlidingChunks
565− , classifySlidingSessions
566− -}
567− -- ** Sliding Window Buffers
568− -- , slidingChunkBuffer
569− -- , slidingSessionBuffer
570− -}
571−
572 -- * Combining Streams
436 -- * Combining Streams
573 -- | New streams can be constructed by appending, merging or zipping
437 -- | New streams can be constructed by appending, merging or zipping
574 -- existing streams.
438 -- existing streams.
@@ -660,9 +524,7 @@ module Streamly.Prelude
660 -- > filter p m = S.concatMap (\x -> if p x then S.yield x else S.nil) m
524 -- > filter p m = S.concatMap (\x -> if p x then S.yield x else S.nil) m
661 --
525 --
662
526
663− -- XXX add stateful concatMapWith
664 , concatMapWith
527 , concatMapWith
665− --, bindWith
666 , concatMap
528 , concatMap
667 , concatMapM
529 , concatMapM
668 , concatUnfold
530 , concatUnfold