Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 4091895

Browse files
committed
Use total function
1 parent 1a59411 commit 4091895

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/Haskell/Ide/Engine/Plugin/HsImport.hs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ extractImportableTerm dirtyMsg = do
475475
let n' = T.strip n
476476
return (n', s)
477477
where
478-
importMsg = head
478+
importMsg = S.headMay
479479
-- Get rid of the rename suggestion parts
480480
$ T.splitOn "Perhaps you meant "
481481
$ T.replace "\n" " "
@@ -486,11 +486,14 @@ extractImportableTerm dirtyMsg = do
486486
$ T.replace "" "" dirtyMsg
487487

488488
extractedTerm = asum
489-
[ (\name -> (name, Import Symbol))
490-
<$> T.stripPrefix "Variable not in scope: " importMsg
491-
, (\name -> (T.init name, Import Type))
492-
<$> T.stripPrefix
493-
"Not in scope: type constructor or class ‘"
494-
importMsg
495-
, (\name -> (name, Import Constructor))
496-
<$> T.stripPrefix "Data constructor not in scope: " importMsg]
489+
[ importMsg
490+
>>= T.stripPrefix "Variable not in scope: "
491+
>>= \name -> Just (name, Import Symbol)
492+
, importMsg
493+
>>= T.stripPrefix "Not in scope: type constructor or class ‘"
494+
>>= \name -> Just (T.init name, Import Type)
495+
, importMsg
496+
>>= T.stripPrefix "Data constructor not in scope: "
497+
>>= \name -> Just (name, Import Constructor)]
498+
499+

0 commit comments

Comments
 (0)