Skip to content

Commit

Permalink
Add doc tests for splitEndBySeq and splitEndBySeq_
Browse files Browse the repository at this point in the history
  • Loading branch information
adithyaov committed Jan 2, 2025
1 parent 4d1373b commit e7916c4
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
104 changes: 104 additions & 0 deletions core/src/Streamly/Internal/Data/Stream/Nesting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 #-}
Expand All @@ -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_ #-}
Expand Down
2 changes: 1 addition & 1 deletion core/streamly-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ library

-- Only those modules should be here which are fully re-exported via some
-- other module.
other-modules:
exposed-modules:
Streamly.Internal.Data.Fold.Step
, Streamly.Internal.Data.Fold.Type
, Streamly.Internal.Data.Fold.Combinators
Expand Down

0 comments on commit e7916c4

Please sign in to comment.