@@ -150,8 +150,8 @@ module Data.Text.Lazy
150 , isInfixOf
150 , isInfixOf
152 -- ** View patterns
152 -- ** View patterns
153− , prefixed
153+ , stripPrefix
154− , suffixed
154+ , stripSuffix
156 -- * Searching
156 -- * Searching
@@ -1217,8 +1217,8 @@ isInfixOf needle haystack
1218-- Examples:
1218-- Examples:
1220−-- > prefixed "foo" "foobar" == Just "bar"
1220+-- > stripPrefix "foo" "foobar" == Just "bar"
1221−-- > prefixed "foo" "quux" == Nothing
1221+-- > stripPrefix "foo" "quux" == Nothing
1223-- This is particularly useful with the @ViewPatterns@ extension to
1223-- This is particularly useful with the @ViewPatterns@ extension to
1224-- GHC, as follows:
1224-- GHC, as follows:
@@ -1227,11 +1227,11 @@ isInfixOf needle haystack
1227-- > import Data.Text as T
1227-- > import Data.Text as T
1229-- > fnordLength :: Text -> Int
1229-- > fnordLength :: Text -> Int
1230−-- > fnordLength (prefixed "fnord" -> Just suf) = T.length suf
1230+-- > fnordLength (stripPrefix "fnord" -> Just suf) = T.length suf
1231-- > fnordLength _ = -1
1231-- > fnordLength _ = -1
1232−prefixed :: Text -> Text -> Maybe Text
1232+stripPrefix :: Text -> Text -> Maybe Text
1233-- Yes, this could be much more efficient.
1233-- Yes, this could be much more efficient.
1234−prefixed p t
1234+stripPrefix p t
1235 | p `isPrefixOf` t = Just (drop (length p) t)
1235 | p `isPrefixOf` t = Just (drop (length p) t)
1236 | otherwise = Nothing
1236 | otherwise = Nothing
@@ -1240,8 +1240,8 @@ prefixed p t
1241-- Examples:
1241-- Examples:
1243−-- > suffixed "bar" "foobar" == Just "foo"
1243+-- > stripSuffix "bar" "foobar" == Just "foo"
1244−-- > suffixed "foo" "quux" == Nothing
1244+-- > stripSuffix "foo" "quux" == Nothing
1246-- This is particularly useful with the @ViewPatterns@ extension to
1246-- This is particularly useful with the @ViewPatterns@ extension to
1247-- GHC, as follows:
1247-- GHC, as follows:
@@ -1250,11 +1250,11 @@ prefixed p t
1250-- > import Data.Text as T
1250-- > import Data.Text as T
1252-- > quuxLength :: Text -> Int
1252-- > quuxLength :: Text -> Int
1253−-- > quuxLength (suffixed "quux" -> Just pre) = T.length pre
1253+-- > quuxLength (stripSuffix "quux" -> Just pre) = T.length pre
1254-- > quuxLength _ = -1
1254-- > quuxLength _ = -1
1255−suffixed :: Text -> Text -> Maybe Text
1255+stripSuffix :: Text -> Text -> Maybe Text
1256-- Yes, this could be much more efficient.
1256-- Yes, this could be much more efficient.
1257−suffixed p t
1257+stripSuffix p t
1258 | p `isSuffixOf` t = Just (take (length t - length p) t)
1258 | p `isSuffixOf` t = Just (take (length t - length p) t)
1259 | otherwise = Nothing
1259 | otherwise = Nothing