@@ -145,8 +145,8 @@ module Data.Text
145145 , isInfixOf
146146
147147 -- ** View patterns
148− , prefixed
149− , suffixed
148+ , stripPrefix
149+ , stripSuffix
150150
151151 -- * Searching
152152 , filter
@@ -1408,8 +1408,8 @@ isInfixOf needle haystack
14081408--
14091409-- Examples:
14101410--
1411−-- > prefixed "foo" "foobar" == Just "bar"
1412−-- > prefixed "foo" "quux" == Nothing
1411+-- > stripPrefix "foo" "foobar" == Just "bar"
1412+-- > stripPrefix "foo" "quux" == Nothing
14131413--
14141414-- This is particularly useful with the @ViewPatterns@ extension to
14151415-- GHC, as follows:
@@ -1418,10 +1418,10 @@ isInfixOf needle haystack
14181418-- > import Data.Text as T
14191419-- >
14201420-- > fnordLength :: Text -> Int
1421−-- > fnordLength (prefixed "fnord" -> Just suf) = T.length suf
1421+-- > fnordLength (stripPrefix "fnord" -> Just suf) = T.length suf
14221422-- > fnordLength _ = -1
1423−prefixed :: Text -> Text -> Maybe Text
1424−prefixed p@(Text _arr _off plen) t@(Text arr off len)
1423+stripPrefix :: Text -> Text -> Maybe Text
1424+stripPrefix p@(Text _arr _off plen) t@(Text arr off len)
14251425 | p `isPrefixOf` t = Just $! textP arr (off+plen) (len-plen)
14261426 | otherwise = Nothing
14271427
@@ -1430,8 +1430,8 @@ prefixed p@(Text _arr _off plen) t@(Text arr off len)
14301430--
14311431-- Examples:
14321432--
1433−-- > suffixed "bar" "foobar" == Just "foo"
1434−-- > suffixed "foo" "quux" == Nothing
1433+-- > stripSuffix "bar" "foobar" == Just "foo"
1434+-- > stripSuffix "foo" "quux" == Nothing
14351435--
14361436-- This is particularly useful with the @ViewPatterns@ extension to
14371437-- GHC, as follows:
@@ -1440,10 +1440,10 @@ prefixed p@(Text _arr _off plen) t@(Text arr off len)
14401440-- > import Data.Text as T
14411441-- >
14421442-- > quuxLength :: Text -> Int
1443−-- > quuxLength (suffixed "quux" -> Just pre) = T.length pre
1443+-- > quuxLength (stripSuffix "quux" -> Just pre) = T.length pre
14441444-- > quuxLength _ = -1
1445−suffixed :: Text -> Text -> Maybe Text
1446−suffixed p@(Text _arr _off plen) t@(Text arr off len)
1445+stripSuffix :: Text -> Text -> Maybe Text
1446+stripSuffix p@(Text _arr _off plen) t@(Text arr off len)
14471447 | p `isSuffixOf` t = Just $! textP arr off (len-plen)
14481448 | otherwise = Nothing
14491449