Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisFrezzato committed Jun 23, 2020
1 parent 2b640a0 commit b7dc398
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Development/IDE/Plugin/CodeAction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ suggestInstanceConstraint contents Diagnostic {..} missingConstraint
| otherwise = []
where
findExistingConstraints :: T.Text -> T.Text
findExistingConstraints =
T.lines >>> flip (!!) 1 >>> T.strip >>> T.replace "from the context: " ""
findExistingConstraints t =
T.replace "from the context: " "" . T.strip $ T.lines t !! 1

readPositionNumber :: T.Text -> Int
readPositionNumber = T.unpack >>> read >>> pred
Expand Down Expand Up @@ -500,7 +500,7 @@ suggestFunctionConstraint contents Diagnostic{..} missingConstraint
findExistingConstraints :: T.Text -> Maybe T.Text
findExistingConstraints message =
if message =~ ("from the context:" :: String)
then matchRegex message "\\. ([^=]+)" <&> head <&> T.strip
then fmap (T.strip . head) $ matchRegex message "\\. ([^=]+)"
else Nothing

buildNewConstraints :: T.Text -> Maybe T.Text -> T.Text
Expand Down

0 comments on commit b7dc398

Please sign in to comment.