on master help sign in
Rename splitSuffixOn to splitOnSuffixSeq
e399354Harendra Kumar
src/Streamly/Internal/Data/Stream/IsStream.hs+35−25
@@ -4167,33 +4167,43 @@ splitOnAny subseq f m = undefined -- D.fromStreamD $ D.splitOnAny f subseq (D.to
4167-- | Like 'splitSuffixBy' but the separator is a sequence of elements, instead
4167-- | Like 'splitSuffixBy' but the separator is a sequence of elements, instead
4168-- of a predicate for a single element.
4168-- of a predicate for a single element.
4169--
4169--
4170−-- > splitSuffixOn_ pat xs = S.toList $ S.splitSuffixOn (A.fromList pat) (FL.toList) (S.fromList xs)
4170+-- > splitOnSuffixSeq_ pat xs = S.toList $ S.splitOnSuffixSeq (A.fromList pat) (FL.toList) (S.fromList xs)
4171--
4171--
4172−-- >>> splitSuffixOn_ "." ""
4172+-- >>> splitOnSuffixSeq_ "." ""
4173-- []
4173-- []
4174--
4174--
4175−-- >>> splitSuffixOn_ "." "."
4175+-- >>> splitOnSuffixSeq_ "." "."
4176-- [""]
4176-- [""]
4177--
4177--
4178−-- >>> splitSuffixOn_ "." "a"
4178+-- >>> splitOnSuffixSeq_ "." "a"
4179-- ["a"]
4179-- ["a"]
4180--
4180--
4181−-- >>> splitSuffixOn_ "." ".a"
4181+-- >>> splitOnSuffixSeq_ "." ".a"
4182-- > ["","a"]
4182-- > ["","a"]
4183--
4183--
4184−-- >>> splitSuffixOn_ "." "a."
4184+-- >>> splitOnSuffixSeq_ "." "a."
4185-- > ["a"]
4185-- > ["a"]
4186--
4186--
4187−-- >>> splitSuffixOn_ "." "a.b"
4187+-- >>> splitOnSuffixSeq_ "." "a.b"
4188-- > ["a","b"]
4188-- > ["a","b"]
4189--
4189--
4190−-- >>> splitSuffixOn_ "." "a.b."
4190+-- >>> splitOnSuffixSeq_ "." "a.b."
4191-- > ["a","b"]
4191-- > ["a","b"]
4192--
4192--
4193−-- >>> splitSuffixOn_ "." "a..b.."
4193+-- >>> splitOnSuffixSeq_ "." "a..b.."
4194-- > ["a","","b",""]
4194-- > ["a","","b",""]
4195--
4195--
4196−-- > lines = splitSuffixOn "\n"
4196+-- > lines = splitOnSuffixSeq "\n"
4197+--
4198+-- 'splitOnSuffixSeq' is an inverse of 'intercalateSuffix'. The following law
4199+-- always holds:
4200+--
4201+-- > intercalateSuffix . splitOnSuffixSeq == id
4202+--
4203+-- The following law holds when the separator is non-empty and contains none of
4204+-- the elements present in the input lists:
4205+--
4206+-- > splitSuffixOn . intercalateSuffix == id
4197--
4207--
4198-- /Internal/
4208-- /Internal/
4199{-# INLINE splitOnSuffixSeq #-}
4209{-# INLINE splitOnSuffixSeq #-}
@@ -4201,7 +4211,7 @@ splitOnSuffixSeq
4201 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
4211 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
4202 => Array a -> Fold m a b -> t m a -> t m b
4212 => Array a -> Fold m a b -> t m a -> t m b
4203splitOnSuffixSeq patt f m =
4213splitOnSuffixSeq patt f m =
4204− D.fromStreamD $ D.splitSuffixOn False patt f (D.toStreamD m)
4214+ D.fromStreamD $ D.splitOnSuffixSeq False patt f (D.toStreamD m)
4205
4215
4206{-
4216{-
4207-- | Like 'splitOn' but drops any empty splits.
4217-- | Like 'splitOn' but drops any empty splits.
@@ -4254,32 +4264,32 @@ splitBySeq
4254splitBySeq patt f m =
4264splitBySeq patt f m =
4255 intersperseM (fold f (A.toStream patt)) $ splitOnSeq patt f m
4265 intersperseM (fold f (A.toStream patt)) $ splitOnSeq patt f m
4256
4266
4257−-- | Like 'splitSuffixOn' but keeps the suffix intact in the splits.
4267+-- | Like 'splitOnSuffixSeq' but keeps the suffix intact in the splits.
4258--
4268--
4259−-- > splitSuffixOn'_ pat xs = S.toList $ FL.splitSuffixOn' (A.fromList pat) (FL.toList) (S.fromList xs)
4269+-- > splitWithSuffixSeq'_ pat xs = S.toList $ S.splitWithSuffixSeq (A.fromList pat) (FL.toList) (S.fromList xs)
4260--
4270--
4261−-- >>> splitSuffixOn'_ "." ""
4271+-- >>> splitWithSuffixSeq' "." ""
4262-- [""]
4272-- [""]
4263--
4273--
4264−-- >>> splitSuffixOn'_ "." "."
4274+-- >>> splitWithSuffixSeq' "." "."
4265-- ["."]
4275-- ["."]
4266--
4276--
4267−-- >>> splitSuffixOn'_ "." "a"
4277+-- >>> splitWithSuffixSeq' "." "a"
4268-- ["a"]
4278-- ["a"]
4269--
4279--
4270−-- >>> splitSuffixOn'_ "." ".a"
4280+-- >>> splitWithSuffixSeq' "." ".a"
4271-- > [".","a"]
4281-- > [".","a"]
4272--
4282--
4273−-- >>> splitSuffixOn'_ "." "a."
4283+-- >>> splitWithSuffixSeq' "." "a."
4274-- > ["a."]
4284-- > ["a."]
4275--
4285--
4276−-- >>> splitSuffixOn'_ "." "a.b"
4286+-- >>> splitWithSuffixSeq' "." "a.b"
4277-- > ["a.","b"]
4287-- > ["a.","b"]
4278--
4288--
4279−-- >>> splitSuffixOn'_ "." "a.b."
4289+-- >>> splitWithSuffixSeq' "." "a.b."
4280-- > ["a.","b."]
4290-- > ["a.","b."]
4281--
4291--
4282−-- >>> splitSuffixOn'_ "." "a..b.."
4292+-- >>> splitWithSuffixSeq' "." "a..b.."
4283-- > ["a.",".","b.","."]
4293-- > ["a.",".","b.","."]
4284--
4294--
4285-- /Internal/
4295-- /Internal/
@@ -4288,16 +4298,16 @@ splitWithSuffixSeq
4288 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
4298 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
4289 => Array a -> Fold m a b -> t m a -> t m b
4299 => Array a -> Fold m a b -> t m a -> t m b
4290splitWithSuffixSeq patt f m =
4300splitWithSuffixSeq patt f m =
4291− D.fromStreamD $ D.splitSuffixOn True patt f (D.toStreamD m)
4301+ D.fromStreamD $ D.splitOnSuffixSeq True patt f (D.toStreamD m)
4292
4302
4293{-
4303{-
4294-- This can be implemented easily using Rabin Karp
4304-- This can be implemented easily using Rabin Karp
4295-- | Split post any one of the given patterns.
4305-- | Split post any one of the given patterns.
4296−{-# INLINE splitSuffixOnAny #-}
4306+{-# INLINE splitOnSuffixSeqAny #-}
4297−splitSuffixOnAny
4307+splitOnSuffixSeqAny
4298 :: (IsStream t, Monad m, Storable a, Integral a)
4308 :: (IsStream t, Monad m, Storable a, Integral a)
4299 => [Array a] -> Fold m a b -> t m a -> t m b
4309 => [Array a] -> Fold m a b -> t m a -> t m b
4300−splitSuffixOnAny subseq f m = undefined
4310+splitOnSuffixSeqAny subseq f m = undefined
4301 -- D.fromStreamD $ D.splitPostAny f subseq (D.toStreamD m)
4311 -- D.fromStreamD $ D.splitPostAny f subseq (D.toStreamD m)
4302-}
4312-}
4303
4313
src/Streamly/Internal/Data/Stream/StreamD.hs+4−4
@@ -169,7 +169,7 @@ module Streamly.Internal.Data.Stream.StreamD
169 , splitSuffixBy'
169 , splitSuffixBy'
170
170
171 , splitOnSeq
171 , splitOnSeq
172− , splitSuffixOn
172+ , splitOnSuffixSeq
173
173
174 , splitInnerBy
174 , splitInnerBy
175 , splitInnerBySuffix
175 , splitInnerBySuffix
@@ -2080,15 +2080,15 @@ data SplitOnSuffixSeqState rb rh ck w fs s b x =
2080 | SplitOnSuffixSeqKRCheck fs s rb !rh
2080 | SplitOnSuffixSeqKRCheck fs s rb !rh
2081 | SplitOnSuffixSeqKRDone Int !fs rb !rh
2081 | SplitOnSuffixSeqKRDone Int !fs rb !rh
2082
2082
2083−{-# INLINE_NORMAL splitSuffixOn #-}
2083+{-# INLINE_NORMAL splitOnSuffixSeq #-}
2084−splitSuffixOn
2084+splitOnSuffixSeq
2085 :: forall m a b. (MonadIO m, Storable a, Enum a, Eq a)
2085 :: forall m a b. (MonadIO m, Storable a, Enum a, Eq a)
2086 => Bool
2086 => Bool
2087 -> Array a
2087 -> Array a
2088 -> Fold m a b
2088 -> Fold m a b
2089 -> Stream m a
2089 -> Stream m a
2090 -> Stream m b
2090 -> Stream m b
2091−splitSuffixOn withSep patArr (Fold fstep initial done) (Stream step state) =
2091+splitOnSuffixSeq withSep patArr (Fold fstep initial done) (Stream step state) =
2092 Stream stepOuter SplitOnSuffixSeqInit
2092 Stream stepOuter SplitOnSuffixSeqInit
2093
2093
2094 where
2094 where