From ada4c28d21d8bf2b118d2705186d54d62c385613 Mon Sep 17 00:00:00 2001 From: Adithya Kumar Date: Thu, 2 Jan 2025 15:06:16 +0530 Subject: [PATCH] Add doc tests for splitEndBySeq and splitEndBySeq_ --- .../Streamly/Internal/Data/Stream/Nesting.hs | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/core/src/Streamly/Internal/Data/Stream/Nesting.hs b/core/src/Streamly/Internal/Data/Stream/Nesting.hs index 854324c422..d3a88e4591 100644 --- a/core/src/Streamly/Internal/Data/Stream/Nesting.hs +++ b/core/src/Streamly/Internal/Data/Stream/Nesting.hs @@ -3601,6 +3601,58 @@ splitOnSuffixSeq withSep patArr (Fold fstep initial _ final) (Stream step state) -- -- >>> splitEndBySeq pat f = Stream.foldMany (Fold.takeEndBySeq pat f) -- +-- Usage: +-- +-- >>> splitOnSuffix p xs = Stream.fold Fold.toList $ Stream.splitEndBySeq (Array.fromList p) Fold.toList (Stream.fromList xs) +-- +-- >>> splitOnSuffix "" "" +-- [] +-- +-- >>> splitOnSuffix "." "" +-- [] +-- +-- >>> splitOnSuffix ".." "" +-- [] +-- +-- >>> splitOnSuffix "..." "" +-- [] +-- +-- >>> splitOnSuffix "" "a...b" +-- ["a",".",".",".","b"] +-- +-- >>> splitOnSuffix "." "a...b" +-- ["a.",".",".","b"] +-- +-- >>> splitOnSuffix ".." "a...b" +-- ["a..",".b"] +-- +-- >>> splitOnSuffix "..." "a...b" +-- ["a...","b"] +-- +-- >>> splitOnSuffix "." "abc" +-- ["abc"] +-- +-- >>> splitOnSuffix ".." "abc" +-- ["abc"] +-- +-- >>> splitOnSuffix "..." "abc" +-- ["abc"] +-- +-- >>> splitOnSuffix "." "." +-- ["."] +-- +-- >>> splitOnSuffix ".." ".." +-- [".."] +-- +-- >>> splitOnSuffix "..." "..." +-- ["..."] +-- +-- >>> splitOnSuffix "." ".a" +-- [".","a"] +-- +-- >>> splitOnSuffix "." "a." +-- ["a."] +-- -- Uses Rabin-Karp algorithm for substring search. -- {-# INLINE_NORMAL splitEndBySeq #-} @@ -3618,6 +3670,58 @@ splitEndBySeq = splitOnSuffixSeq True -- -- >>> splitEndBySeq_ pat f = Stream.foldMany (Fold.takeEndBySeq_ pat f) -- +-- Usage: +-- +-- >>> splitOnSuffix p xs = Stream.fold Fold.toList $ Stream.splitEndBySeq_ (Array.fromList p) Fold.toList (Stream.fromList xs) +-- +-- >>> splitOnSuffix "" "" +-- [] +-- +-- >>> splitOnSuffix "." "" +-- [] +-- +-- >>> splitOnSuffix ".." "" +-- [] +-- +-- >>> splitOnSuffix "..." "" +-- [] +-- +-- >>> splitOnSuffix "" "a...b" +-- ["a",".",".",".","b"] +-- +-- >>> splitOnSuffix "." "a...b" +-- ["a","","","b"] +-- +-- >>> splitOnSuffix ".." "a...b" +-- ["a",".b"] +-- +-- >>> splitOnSuffix "..." "a...b" +-- ["a","b"] +-- +-- >>> splitOnSuffix "." "abc" +-- ["abc"] +-- +-- >>> splitOnSuffix ".." "abc" +-- ["abc"] +-- +-- >>> splitOnSuffix "..." "abc" +-- ["abc"] +-- +-- >>> splitOnSuffix "." "." +-- [""] +-- +-- >>> splitOnSuffix ".." ".." +-- [""] +-- +-- >>> splitOnSuffix "..." "..." +-- [""] +-- +-- >>> splitOnSuffix "." ".a" +-- ["","a"] +-- +-- >>> splitOnSuffix "." "a." +-- ["a"] +-- -- Uses Rabin-Karp algorithm for substring search. -- {-# INLINE_NORMAL splitEndBySeq_ #-}