Skip to content
Snippets Groups Projects
Unverified Commit c2f6c19e authored by Bodigrim's avatar Bodigrim Committed by GitHub
Browse files

Implement stripPrefix via T.stripPrefix (#2645)

parent 0905e682
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,7 @@ import Data.Function (on) ...@@ -31,6 +31,7 @@ import Data.Function (on)
import Data.Functor import Data.Functor
import qualified Data.HashMap.Strict as HM import qualified Data.HashMap.Strict as HM
import qualified Data.HashSet as HashSet import qualified Data.HashSet as HashSet
import Data.Monoid (First(..))
import Data.Ord (Down (Down)) import Data.Ord (Down (Down))
import qualified Data.Set as Set import qualified Data.Set as Set
import Development.IDE.Core.Compile import Development.IDE.Core.Compile
...@@ -757,12 +758,8 @@ openingBacktick line prefixModule prefixText Position { _character=(fromIntegral ...@@ -757,12 +758,8 @@ openingBacktick line prefixModule prefixText Position { _character=(fromIntegral
-} -}
-- TODO: Turn this into an alex lexer that discards prefixes as if they were whitespace. -- TODO: Turn this into an alex lexer that discards prefixes as if they were whitespace.
stripPrefix :: T.Text -> T.Text stripPrefix :: T.Text -> T.Text
stripPrefix name = T.takeWhile (/=':') $ go prefixes stripPrefix name = T.takeWhile (/=':') $ fromMaybe name $
where getFirst $ foldMap (First . (`T.stripPrefix` name)) prefixes
go [] = name
go (p:ps)
| T.isPrefixOf p name = T.drop (T.length p) name
| otherwise = go ps
-- | Prefixes that can occur in a GHC OccName -- | Prefixes that can occur in a GHC OccName
prefixes :: [T.Text] prefixes :: [T.Text]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment