@@ -303,6 +303,17 @@ import qualified Streamly.Internal.Data.Stream.StreamD as S
303303
304304import Prelude hiding (zipWith, concatMap, concat)
305305
306+-- $setup
307+-- >>> :m
308+-- >>> import Prelude hiding (zipWith, concatMap, concat)
309+-- >>> import qualified Streamly.Prelude as Stream
310+-- >>> import Streamly.Internal.Data.Stream.IsStream as Stream
311+-- >>> import qualified Streamly.Data.Fold as Fold
312+-- >>> import qualified Streamly.Internal.Data.Fold as Fold
313+-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
314+-- >>> import qualified Streamly.Internal.Data.Parser as Parser
315+-- >>> import qualified Streamly.Data.Array.Foreign as Array
316+
306317-------------------------------------------------------------------------------
307318-- Appending
308319-------------------------------------------------------------------------------
@@ -339,9 +350,10 @@ append m1 m2 = fromStreamD $ D.append (toStreamD m1) (toStreamD m2)
339350-- early the other stream continues alone until it too finishes.
340351--
341352-- >>> :set -XOverloadedStrings
342−-- >>> interleave "ab" ",,,," :: SerialT Identity Char
353+-- >>> import Data.Functor.Identity (Identity)
354+-- >>> Stream.interleave "ab" ",,,," :: Stream.SerialT Identity Char
343355-- fromList "a,b,,,"
344−-- >>> interleave "abcd" ",," :: SerialT Identity Char
356+-- >>> Stream.interleave "abcd" ",," :: Stream.SerialT Identity Char
345357-- fromList "a,b,cd"
346358--
347359-- 'interleave' is dual to 'interleaveMin', it can be called @interleaveMax@.
@@ -361,9 +373,10 @@ interleave m1 m2 = fromStreamD $ D.interleave (toStreamD m1) (toStreamD m2)
361373-- still continues to yield elements until it finishes.
362374--
363375-- >>> :set -XOverloadedStrings
364−-- >>> interleaveSuffix "abc" ",,,," :: SerialT Identity Char
376+-- >>> import Data.Functor.Identity (Identity)
377+-- >>> Stream.interleaveSuffix "abc" ",,,," :: Stream.SerialT Identity Char
365378-- fromList "a,b,c,"
366−-- >>> interleaveSuffix "abc" "," :: SerialT Identity Char
379+-- >>> Stream.interleaveSuffix "abc" "," :: Stream.SerialT Identity Char
367380-- fromList "a,bc"
368381--
369382-- 'interleaveSuffix' is a dual of 'interleaveInfix'.
@@ -384,9 +397,10 @@ interleaveSuffix m1 m2 =
384397-- has finished.
385398--
386399-- >>> :set -XOverloadedStrings
387−-- >>> interleaveInfix "abc" ",,,," :: SerialT Identity Char
400+-- >>> import Data.Functor.Identity (Identity)
401+-- >>> Stream.interleaveInfix "abc" ",,,," :: Stream.SerialT Identity Char
388402-- fromList "a,b,c"
389−-- >>> interleaveInfix "abc" "," :: SerialT Identity Char
403+-- >>> Stream.interleaveInfix "abc" "," :: Stream.SerialT Identity Char
390404-- fromList "a,bc"
391405--
392406-- 'interleaveInfix' is a dual of 'interleaveSuffix'.
@@ -406,9 +420,10 @@ interleaveInfix m1 m2 =
406420-- stream.
407421--
408422-- >>> :set -XOverloadedStrings
409−-- >>> interleaveMin "ab" ",,,," :: SerialT Identity Char
423+-- >>> import Data.Functor.Identity (Identity)
424+-- >>> Stream.interleaveMin "ab" ",,,," :: Stream.SerialT Identity Char
410425-- fromList "a,b,"
411−-- >>> interleaveMin "abcd" ",," :: SerialT Identity Char
426+-- >>> Stream.interleaveMin "abcd" ",," :: Stream.SerialT Identity Char
412427-- fromList "a,b,c"
413428--
414429-- 'interleaveMin' is dual to 'interleave'.
@@ -453,8 +468,9 @@ roundrobin m1 m2 = fromStreamD $ D.roundRobin (toStreamD m1) (toStreamD m2)
453468-- also remain sorted in ascending order.
454469--
455470-- @
456−-- > S.toList $ S.mergeBy compare (S.fromList [1,3,5]) (S.fromList [2,4,6,8])
471+-- >>> Stream.toList $ Stream.mergeBy compare (Stream.fromList [1,3,5]) (Stream.fromList [2,4,6,8])
457472-- [1,2,3,4,5,6,8]
473+--
458474-- @
459475--
460476-- @since 0.6.0
@@ -763,10 +779,10 @@ gintercalate unf1 str1 unf2 str2 =
763779--
764780-- | 'intersperse' followed by unfold and concat.
765781--
766−-- > unwords = intercalate " " UF.fromList
782+-- > unwords = intercalate " " Unfold.fromList
767783--
768−-- >>> intercalate " " UF.fromList ["abc", "def", "ghi"]
769−-- > "abc def ghi"
784+-- >>> Stream.toList $ Stream.intercalate " " Unfold.fromList $ Stream.fromList ["abc", "def", "ghi"]
785+-- "abc def ghi"
770786--
771787-- /Internal/
772788{-# INLINE intercalate #-}
@@ -792,10 +808,10 @@ gintercalateSuffix unf1 str1 unf2 str2 =
792808--
793809-- | 'intersperseSuffix' followed by unfold and concat.
794810--
795−-- > unlines = intercalateSuffix "\n" UF.fromList
811+-- > unlines = intercalateSuffix "\n" Unfold.fromList
796812--
797−-- >>> intercalate "\n" UF.fromList ["abc", "def", "ghi"]
798−-- > "abc\ndef\nghi\n"
813+-- >>> Stream.toList $ Stream.intercalateSuffix "\n" Unfold.fromList $ Stream.fromList ["abc", "def", "ghi"]
814+-- "abc\ndef\nghi\n"
799815--
800816-- /Internal/
801817{-# INLINE intercalateSuffix #-}
@@ -932,11 +948,11 @@ iterateMapLeftsWith combine f = iterateMapWith combine (either f (const K.nil))
932948--
933949-- >>> f = Fold.takeLE 2 Fold.sum
934950-- >>> Stream.toList $ Stream.foldManyPost f $ Stream.fromList []
935−-- > [0]
951+-- [0]
936952-- >>> Stream.toList $ Stream.foldManyPost f $ Stream.fromList [1..9]
937−-- > [3,7,11,15,9]
953+-- [3,7,11,15,9]
938954-- >>> Stream.toList $ Stream.foldManyPost f $ Stream.fromList [1..10]
939−-- > [3,7,11,15,19,0]
955+-- [3,7,11,15,19,0]
940956--
941957-- /Internal/
942958--
@@ -955,12 +971,12 @@ foldManyPost f m = D.fromStreamD $ D.foldManyPost f (D.toStreamD m)
955971--
956972-- >>> f = Fold.takeLE 2 Fold.sum
957973-- >>> Stream.toList $ Stream.foldMany f $ Stream.fromList [1..10]
958−-- > [3,7,11,15,19]
974+-- [3,7,11,15,19]
959975--
960976-- On an empty stream the output is empty:
961977--
962978-- >>> Stream.toList $ Stream.foldMany f $ Stream.fromList []
963−-- > []
979+-- []
964980--
965981-- Note @foldMany (takeLE 0)@ would result in an infinite loop in a non-empty
966982-- stream.
@@ -992,10 +1008,14 @@ foldSequence _f _m = undefined
9921008-- generate the first fold, the fold is applied on the stream and the result of
9931009-- the fold is used to generate the next fold and so on.
9941010--
995−-- >>> f x = Fold.takeLE 2 (Fold.mconcatTo x)
996−-- >>> s = Stream.map Sum $ Stream.fromList [1..10]
997−-- >>> Stream.toList $ Stream.map getSum $ Stream.foldIterate f 0 s
998−-- > [3,10,21,36,55,55]
1011+-- @
1012+-- > import Data.Monoid (Sum(..))
1013+-- > f x = Fold.takeLE 2 (Fold.sconcat x)
1014+-- > s = Stream.map Sum $ Stream.fromList [1..10]
1015+-- > Stream.toList $ Stream.map getSum $ Stream.foldIterate f 0 s
1016+-- [3,10,21,36,55,55]
1017+--
1018+-- @
9991019--
10001020-- This is the streaming equivalent of monad like sequenced application of
10011021-- folds where next fold is dependent on the previous fold.
@@ -1022,11 +1042,14 @@ foldIterate _f _i _m = undefined
10221042-- This is the streaming equivalent of the 'Streamly.Internal.Data.Parser.many'
10231043-- parse combinator.
10241044--
1025−-- >>> S.toList $ S.parseMany (PR.take 2 $ PR.fromFold FL.sum) $ S.fromList [1..10]
1026−-- > [3,7,11,15,19]
1045+-- >>> Stream.toList $ Stream.parseMany (Parser.takeBetween 0 2 Fold.sum) $ Stream.fromList [1..10]
1046+-- [3,7,11,15,19]
1047+--
1048+-- @
1049+-- > Stream.toList $ Stream.parseMany (Parser.line Fold.toList) $ Stream.fromList "hello\\nworld"
1050+-- ["hello\\n","world"]
10271051--
1028−-- >>> S.toList $ S.parseMany (PR.line FL.toList) $ S.fromList "hello\nworld"
1029−-- > ["hello\n","world"]
1052+-- @
10301053--
10311054-- @
10321055-- foldMany f = parseMany (fromFold f)
@@ -1089,8 +1112,9 @@ parseManyTill = undefined
10891112-- used to generate the first parser, the parser is applied on the stream and
10901113-- the result is used to generate the next parser and so on.
10911114--
1092−-- >>> S.toList $ S.map getSum $ S.parseIterate (\b -> PR.take 2 (FL.mconcatTo b)) 0 $ S.map Sum $ S.fromList [1..10]
1093−-- > [3,10,21,36,55,55]
1115+-- >>> import Data.Monoid (Sum(..))
1116+-- >>> Stream.toList $ Stream.map getSum $ Stream.parseIterate (\b -> Parser.takeBetween 0 2 (Fold.sconcat b)) 0 $ Stream.map Sum $ Stream.fromList [1..10]
1117+-- [3,10,21,36,55,55]
10941118--
10951119-- This is the streaming equivalent of monad like sequenced application of
10961120-- parsers where next parser is dependent on the previous parser.
@@ -1196,8 +1220,8 @@ groupScan split fold m = undefined
11961220-- group is folded using the fold @f@ and the result of the fold is emitted in
11971221-- the output stream.
11981222--
1199−-- >>> S.toList $ S.groupsBy (>) FL.toList $ S.fromList [1,3,7,0,2,5]
1200−-- > [[1,3,7],[0,2,5]]
1223+-- >>> Stream.toList $ Stream.groupsBy (>) Fold.toList $ Stream.fromList [1,3,7,0,2,5]
1224+-- [[1,3,7],[0,2,5]]
12011225--
12021226-- @since 0.7.0
12031227{-# INLINE groupsBy #-}
@@ -1217,8 +1241,8 @@ groupsBy cmp f m = D.fromStreamD $ D.groupsBy cmp f (D.toStreamD m)
12171241-- comparison fails a new group is started. Each group is folded using the fold
12181242-- @f@.
12191243--
1220−-- >>> S.toList $ S.groupsByRolling (\a b -> a + 1 == b) FL.toList $ S.fromList [1,2,3,7,8,9]
1221−-- > [[1,2,3],[7,8,9]]
1244+-- >>> Stream.toList $ Stream.groupsByRolling (\a b -> a + 1 == b) Fold.toList $ Stream.fromList [1,2,3,7,8,9]
1245+-- [[1,2,3],[7,8,9]]
12221246--
12231247-- @since 0.7.0
12241248{-# INLINE groupsByRolling #-}
@@ -1236,8 +1260,8 @@ groupsByRolling cmp f m = D.fromStreamD $ D.groupsRollingBy cmp f (D.toStreamD
12361260--
12371261-- Groups contiguous spans of equal elements together in individual groups.
12381262--
1239−-- >>> S.toList $ S.groups FL.toList $ S.fromList [1,1,2,2]
1240−-- > [[1,1],[2,2]]
1263+-- >>> Stream.toList $ Stream.groups Fold.toList $ Stream.fromList [1,1,2,2]
1264+-- [[1,1],[2,2]]
12411265--
12421266-- @since 0.7.0
12431267{-# INLINE groups #-}
@@ -1262,9 +1286,9 @@ groups = groupsBy (==)
12621286-- separator elements determined by the supplied predicate, separator is
12631287-- considered as infixed between two segments:
12641288--
1265−-- >>> splitOn' p xs = S.toList $ S.splitOn p FL.toList (S.fromList xs)
1289+-- >>> splitOn' p xs = Stream.toList $ Stream.splitOn p Fold.toList (Stream.fromList xs)
12661290-- >>> splitOn' (== '.') "a.b"
1267−-- > ["a","b"]
1291+-- ["a","b"]
12681292--
12691293-- An empty stream is folded to the default value of the fold:
12701294--
@@ -1278,13 +1302,13 @@ groups = groupsBy (==)
12781302-- ["",""]
12791303--
12801304-- >>> splitOn' (== '.') ".a"
1281−-- > ["","a"]
1305+-- ["","a"]
12821306--
12831307-- >>> splitOn' (== '.') "a."
1284−-- > ["a",""]
1308+-- ["a",""]
12851309--
12861310-- >>> splitOn' (== '.') "a..b"
1287−-- > ["a","","b"]
1311+-- ["a","","b"]
12881312--
12891313-- splitOn is an inverse of intercalating single element:
12901314--
@@ -1318,12 +1342,12 @@ splitOn predicate f =
13181342-- | Split on a suffixed separator element, dropping the separator. The
13191343-- supplied 'Fold' is applied on the split segments.
13201344--
1321−-- > splitOnSuffix' p xs = S.toList $ S.splitOnSuffix p (FL.toList) (S.fromList xs)
1345+-- >>> splitOnSuffix' p xs = Stream.toList $ Stream.splitOnSuffix p Fold.toList (Stream.fromList xs)
13221346-- >>> splitOnSuffix' (== '.') "a.b."
1323−-- > ["a","b"]
1347+-- ["a","b"]
13241348--
13251349-- >>> splitOnSuffix' (== '.') "a."
1326−-- > ["a"]
1350+-- ["a"]
13271351--
13281352-- An empty stream results in an empty output stream:
13291353--
@@ -1337,7 +1361,7 @@ splitOn predicate f =
13371361-- [""]
13381362--
13391363-- >>> splitOnSuffix' (== '.') "a..b.."
1340−-- > ["a","","b",""]
1364+-- ["a","","b",""]
13411365--
13421366-- A suffix is optional at the end of the stream:
13431367--
@@ -1345,10 +1369,10 @@ splitOn predicate f =
13451369-- ["a"]
13461370--
13471371-- >>> splitOnSuffix' (== '.') ".a"
1348−-- > ["","a"]
1372+-- ["","a"]
13491373--
13501374-- >>> splitOnSuffix' (== '.') "a.b"
1351−-- > ["a","b"]
1375+-- ["a","b"]
13521376--
13531377-- > lines = splitOnSuffix (== '\n')
13541378--
@@ -1371,33 +1395,42 @@ splitOnSuffix predicate f = foldMany (FL.sliceSepBy predicate f)
13711395-- | Split on a prefixed separator element, dropping the separator. The
13721396-- supplied 'Fold' is applied on the split segments.
13731397--
1374−-- >>> splitOnPrefix' p xs = S.toList $ S.splitOnPrefix p (FL.toList) (S.fromList xs)
1375−-- >>> splitOnPrefix' (== '.') ".a.b"
1376−-- > ["a","b"]
1398+-- @
1399+-- > splitOnPrefix' p xs = Stream.toList $ Stream.splitOnPrefix p (Fold.toList) (Stream.fromList xs)
1400+-- > splitOnPrefix' (== '.') ".a.b"
1401+-- ["a","b"]
1402+-- @
13771403--
13781404-- An empty stream results in an empty output stream:
1379−-- >>> splitOnPrefix' (== '.') ""
1405+-- @
1406+-- > splitOnPrefix' (== '.') ""
13801407-- []
1408+-- @
13811409--
13821410-- An empty segment consisting of only a prefix is folded to the default output
13831411-- of the fold:
13841412--
1385−-- >>> splitOnPrefix' (== '.') "."
1413+-- @
1414+-- > splitOnPrefix' (== '.') "."
13861415-- [""]
13871416--
1388−-- >>> splitOnPrefix' (== '.') ".a.b."
1389−-- > ["a","b",""]
1417+-- > splitOnPrefix' (== '.') ".a.b."
1418+-- ["a","b",""]
1419+--
1420+-- > splitOnPrefix' (== '.') ".a..b"
1421+-- ["a","","b"]
13901422--
1391−-- >>> splitOnPrefix' (== '.') ".a..b"
1392−-- > ["a","","b"]
1423+-- @
13931424--
13941425-- A prefix is optional at the beginning of the stream:
13951426--
1396−-- >>> splitOnPrefix' (== '.') "a"
1427+-- @
1428+-- > splitOnPrefix' (== '.') "a"
13971429-- ["a"]
13981430--
1399−-- >>> splitOnPrefix' (== '.') "a.b"
1400−-- > ["a","b"]
1431+-- > splitOnPrefix' (== '.') "a.b"
1432+-- ["a","b"]
1433+-- @
14011434--
14021435-- 'splitOnPrefix' is an inverse of 'intercalatePrefix' with a single element:
14031436--
@@ -1420,16 +1453,16 @@ splitOnPrefix _predicate _f = undefined
14201453-- @["a","b"]@. In other words, its like parsing words from whitespace
14211454-- separated text.
14221455--
1423−-- > wordsBy' p xs = S.toList $ S.wordsBy p (FL.toList) (S.fromList xs)
1456+-- >>> wordsBy' p xs = Stream.toList $ Stream.wordsBy p Fold.toList (Stream.fromList xs)
14241457--
14251458-- >>> wordsBy' (== ',') ""
1426−-- > []
1459+-- []
14271460--
14281461-- >>> wordsBy' (== ',') ","
1429−-- > []
1462+-- []
14301463--
14311464-- >>> wordsBy' (== ',') ",a,,b,"
1432−-- > ["a","b"]
1465+-- ["a","b"]
14331466--
14341467-- > words = wordsBy isSpace
14351468--
@@ -1447,7 +1480,7 @@ wordsBy predicate f m =
14471480-- | Like 'splitOnSuffix' but keeps the suffix attached to the resulting
14481481-- splits.
14491482--
1450−-- > splitWithSuffix' p xs = S.toList $ S.splitWithSuffix p (FL.toList) (S.fromList xs)
1483+-- >>> splitWithSuffix' p xs = Stream.toList $ splitWithSuffix p Fold.toList (Stream.fromList xs)
14511484--
14521485-- >>> splitWithSuffix' (== '.') ""
14531486-- []
@@ -1459,19 +1492,19 @@ wordsBy predicate f m =
14591492-- ["a"]
14601493--
14611494-- >>> splitWithSuffix' (== '.') ".a"
1462−-- > [".","a"]
1495+-- [".","a"]
14631496--
14641497-- >>> splitWithSuffix' (== '.') "a."
1465−-- > ["a."]
1498+-- ["a."]
14661499--
14671500-- >>> splitWithSuffix' (== '.') "a.b"
1468−-- > ["a.","b"]
1501+-- ["a.","b"]
14691502--
14701503-- >>> splitWithSuffix' (== '.') "a.b."
1471−-- > ["a.","b."]
1504+-- ["a.","b."]
14721505--
14731506-- >>> splitWithSuffix' (== '.') "a..b.."
1474−-- > ["a.",".","b.","."]
1507+-- ["a.",".","b.","."]
14751508--
14761509-- @since 0.7.0
14771510
@@ -1529,34 +1562,34 @@ splitOnAny subseq f m = undefined -- D.fromStreamD $ D.splitOnAny f subseq (D.to
15291562--
15301563-- | Like 'splitOnSeq' but splits the separator as well, as an infix token.
15311564--
1532−-- > splitOn'_ pat xs = S.toList $ S.splitOn' (A.fromList pat) (FL.toList) (S.fromList xs)
1565+-- >>> splitOn'_ pat xs = Stream.toList $ Stream.splitBySeq (Array.fromList pat) Fold.toList (Stream.fromList xs)
15331566--
15341567-- >>> splitOn'_ "" "hello"
1535−-- > ["h","","e","","l","","l","","o"]
1568+-- ["h","","e","","l","","l","","o"]
15361569--
15371570-- >>> splitOn'_ "hello" ""
1538−-- > [""]
1571+-- [""]
15391572--
15401573-- >>> splitOn'_ "hello" "hello"
1541−-- > ["","hello",""]
1574+-- ["","hello",""]
15421575--
15431576-- >>> splitOn'_ "x" "hello"
1544−-- > ["hello"]
1577+-- ["hello"]
15451578--
15461579-- >>> splitOn'_ "h" "hello"
1547−-- > ["","h","ello"]
1580+-- ["","h","ello"]
15481581--
15491582-- >>> splitOn'_ "o" "hello"
1550−-- > ["hell","o",""]
1583+-- ["hell","o",""]
15511584--
15521585-- >>> splitOn'_ "e" "hello"
1553−-- > ["h","e","llo"]
1586+-- ["h","e","llo"]
15541587--
15551588-- >>> splitOn'_ "l" "hello"
1556−-- > ["he","l","","l","o"]
1589+-- ["he","l","","l","o"]
15571590--
15581591-- >>> splitOn'_ "ll" "hello"
1559−-- > ["he","ll","o"]
1592+-- ["he","ll","o"]
15601593--
15611594-- /Internal/
15621595{-# INLINE splitBySeq #-}
@@ -1569,7 +1602,7 @@ splitBySeq patt f m =
15691602-- | Like 'splitSuffixBy' but the separator is a sequence of elements, instead
15701603-- of a predicate for a single element.
15711604--
1572−-- > splitOnSuffixSeq_ pat xs = S.toList $ S.splitOnSuffixSeq (A.fromList pat) (FL.toList) (S.fromList xs)
1605+-- >>> splitOnSuffixSeq_ pat xs = Stream.toList $ Stream.splitOnSuffixSeq (Array.fromList pat) Fold.toList (Stream.fromList xs)
15731606--
15741607-- >>> splitOnSuffixSeq_ "." ""
15751608-- []
@@ -1581,19 +1614,19 @@ splitBySeq patt f m =
15811614-- ["a"]
15821615--
15831616-- >>> splitOnSuffixSeq_ "." ".a"
1584−-- > ["","a"]
1617+-- ["","a"]
15851618--
15861619-- >>> splitOnSuffixSeq_ "." "a."
1587−-- > ["a"]
1620+-- ["a"]
15881621--
15891622-- >>> splitOnSuffixSeq_ "." "a.b"
1590−-- > ["a","b"]
1623+-- ["a","b"]
15911624--
15921625-- >>> splitOnSuffixSeq_ "." "a.b."
1593−-- > ["a","b"]
1626+-- ["a","b"]
15941627--
15951628-- >>> splitOnSuffixSeq_ "." "a..b.."
1596−-- > ["a","","b",""]
1629+-- ["a","","b",""]
15971630--
15981631-- > lines = splitOnSuffixSeq "\n"
15991632--
@@ -1627,10 +1660,10 @@ wordsOn subseq f m = undefined -- D.fromStreamD $ D.wordsOn f subseq (D.toStream
16271660
16281661-- | Like 'splitOnSuffixSeq' but keeps the suffix intact in the splits.
16291662--
1630−-- > splitWithSuffixSeq'_ pat xs = S.toList $ S.splitWithSuffixSeq (A.fromList pat) (FL.toList) (S.fromList xs)
1663+-- >>> splitWithSuffixSeq' pat xs = Stream.toList $ Stream.splitWithSuffixSeq (Array.fromList pat) Fold.toList (Stream.fromList xs)
16311664--
16321665-- >>> splitWithSuffixSeq' "." ""
1633−-- [""]
1666+-- []
16341667--
16351668-- >>> splitWithSuffixSeq' "." "."
16361669-- ["."]
@@ -1639,19 +1672,19 @@ wordsOn subseq f m = undefined -- D.fromStreamD $ D.wordsOn f subseq (D.toStream
16391672-- ["a"]
16401673--
16411674-- >>> splitWithSuffixSeq' "." ".a"
1642−-- > [".","a"]
1675+-- [".","a"]
16431676--
16441677-- >>> splitWithSuffixSeq' "." "a."
1645−-- > ["a."]
1678+-- ["a."]
16461679--
16471680-- >>> splitWithSuffixSeq' "." "a.b"
1648−-- > ["a.","b"]
1681+-- ["a.","b"]
16491682--
16501683-- >>> splitWithSuffixSeq' "." "a.b."
1651−-- > ["a.","b."]
1684+-- ["a.","b."]
16521685--
16531686-- >>> splitWithSuffixSeq' "." "a..b.."
1654−-- > ["a.",".","b.","."]
1687+-- ["a.",".","b.","."]
16551688--
16561689-- /Internal/
16571690{-# INLINE splitWithSuffixSeq #-}
@@ -1679,8 +1712,8 @@ splitOnSuffixSeqAny subseq f m = undefined
16791712-- | Group the input stream into groups of @n@ elements each and then fold each
16801713-- group using the provided fold function.
16811714--
1682−-- >> S.toList $ S.chunksOf 2 FL.sum (S.enumerateFromTo 1 10)
1683−-- > [3,7,11,15,19]
1715+-- >>> Stream.toList $ Stream.chunksOf 2 Fold.sum (Stream.enumerateFromTo 1 10)
1716+-- [3,7,11,15,19]
16841717--
16851718-- This can be considered as an n-fold version of 'takeLE' where we apply
16861719-- 'takeLE' repeatedly on the leftover stream until the stream exhausts.
@@ -1718,12 +1751,13 @@ arraysOf n = D.fromStreamD . A.arraysOf n . D.toStreamD
17181751
17191752-- XXX we can implement this by repeatedly applying the 'lrunFor' fold.
17201753-- XXX add this example after fixing the serial stream rate control
1721−-- >>> S.toList $ S.take 5 $ intervalsOf 1 FL.sum $ constRate 2 $ S.enumerateFrom 1
1722−-- > [3,7,11,15,19]
17231754--
17241755-- | Group the input stream into windows of @n@ second each and then fold each
17251756-- group using the provided fold function.
17261757--
1758+-- >>> Stream.toList $ Stream.take 5 $ Stream.intervalsOf 1 Fold.sum $ Stream.constRate 2 $ Stream.enumerateFrom 1
1759+-- [...,...,...,...,...]
1760+--
17271761-- @since 0.7.0
17281762{-# INLINE intervalsOf #-}
17291763intervalsOf
@@ -2188,12 +2222,18 @@ classifyChunksOf wsize = classifyChunksBy wsize False
21882222-- @
21892223--
21902224-- @
2191−-- >>> S.mapM_ print
2192−-- $ S.classifySessionsOf 3 (const (return False)) (fmap Right FL.toList)
2193−-- $ S.map (\(ts,(k,a)) -> (k, a, ts))
2194−-- $ S.timestamped
2195−-- $ S.delay 1
2196−-- $ (,) <$> S.fromList [1,2,3] <*> S.fromList [1,2,3]
2225+-- > :{
2226+-- Stream.mapM_ print
2227+-- $ Stream.classifySessionsOf 3 (const (return False)) (fmap Right Fold.toList)
2228+-- $ Stream.map (\\(ts,(k,a)) -> (k, a, ts))
2229+-- $ Stream.timestamped
2230+-- $ Stream.delay 1
2231+-- $ (,) <$> Stream.fromList [1,2,3] <*> Stream.fromList [1,2,3]
2232+-- :}
2233+-- (1,Right [1,2,3])
2234+-- (2,Right [1,2,3])
2235+-- (3,Right [1,2,3])
2236+--
21972237-- @
21982238--
21992239-- /Internal/