From c2f6c19ed99116b602524bfa87863eee29bd0ab2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=CB=8Cbod=CA=B2=C9=AA=CB=88=C9=A1r=CA=B2im?=
 <andrew.lelechenko@gmail.com>
Date: Fri, 28 Jan 2022 06:43:19 +0000
Subject: [PATCH] Implement stripPrefix via T.stripPrefix (#2645)

---
 ghcide/src/Development/IDE/Plugin/Completions/Logic.hs | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
index 9ce4c80c..f1017eea 100644
--- a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
+++ b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
@@ -31,6 +31,7 @@ import           Data.Function                            (on)
 import           Data.Functor
 import qualified Data.HashMap.Strict                      as HM
 import qualified Data.HashSet                             as HashSet
+import           Data.Monoid                              (First(..))
 import           Data.Ord                                 (Down (Down))
 import qualified Data.Set                                 as Set
 import           Development.IDE.Core.Compile
@@ -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.
 stripPrefix :: T.Text -> T.Text
-stripPrefix name = T.takeWhile (/=':') $ go prefixes
-  where
-    go [] = name
-    go (p:ps)
-      | T.isPrefixOf p name = T.drop (T.length p) name
-      | otherwise = go ps
+stripPrefix name = T.takeWhile (/=':') $ fromMaybe name $
+  getFirst $ foldMap (First . (`T.stripPrefix` name)) prefixes
 
 -- | Prefixes that can occur in a GHC OccName
 prefixes :: [T.Text]
-- 
GitLab