@@ -666,11 +666,23 @@ reverse :: Text -> Text
666reverse t = S.reverse (stream t)
666reverse t = S.reverse (stream t)
667{-# INLINE reverse #-}
667{-# INLINE reverse #-}
669−-- | /O(m+n)/ Replace every occurrence of one substring with another.
669+-- | /O(m+n)/ Replace every occurrence of @needle@ in @haystack@ with @repl@.
671+-- If @needle@ occurs in @repl@, it won't be replaced twice:
673+-- > replace "oo" "foo" "oo" == "foo"
675+-- If several instances of @needle@ overlap, only the first one will be
678+-- > replace "ofo" "bar" "ofofo" == "barfo"
671-- In (unlikely) bad cases, this function's time complexity degrades
680-- In (unlikely) bad cases, this function's time complexity degrades
672-- towards /O(n*m)/.
681-- towards /O(n*m)/.
673−replace :: Text -> Text -> Text -> Text
682+replace :: Text -- ^ @needle@ to search for
683+ -> Text -- ^ @repl@ to replace @needle@ with
684+ -> Text -- ^ @haystack@ in which to search
674replace needle@(Text _ _ neeLen)
686replace needle@(Text _ _ neeLen)
675 (Text repArr repOff repLen)
687 (Text repArr repOff repLen)
676 haystack@(Text hayArr hayOff hayLen)
688 haystack@(Text hayArr hayOff hayLen)