Skip to content

Commit

Permalink
Remove Data.Text.Class.splitAtLastOccurrence weed
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Jul 20, 2021
1 parent 9d48355 commit d442875
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions lib/text-class/src/Data/Text/Class.hs
Expand Up @@ -30,7 +30,6 @@ module Data.Text.Class

-- * Helpers
, showT
, splitAtLastOccurrence
) where

import Prelude
Expand All @@ -44,7 +43,7 @@ import Data.List
import Data.List.Extra
( enumerate )
import Data.Maybe
( isNothing, listToMaybe )
( listToMaybe )
import Data.Text
( Text )
import Data.Text.Read
Expand Down Expand Up @@ -294,15 +293,3 @@ fromCaseStyle = \case
-- | Show a data-type through its 'ToText' instance
showT :: ToText a => a -> String
showT = T.unpack . toText

-- | Splits the given 'Text' into a prefix and a suffix using the last
-- occurrence of the specified separator character as a splitting point.
-- Evaluates to 'Nothing' if the specified 'Text' does not contain the
-- separator character.
splitAtLastOccurrence :: Char -> Text -> Maybe (Text, Text)
splitAtLastOccurrence c s
| isNothing (T.find (== c) s) = Nothing
| otherwise = pure (prefix, suffix)
where
(prefixPlusOne, suffix) = T.breakOnEnd (T.pack [c]) s
prefix = T.dropEnd 1 prefixPlusOne

0 comments on commit d442875

Please sign in to comment.