Skip to content

Commit e76194a

Browse files
Apply suggestions from michaelpj
Co-authored-by: Michael Peyton Jones <[email protected]>
1 parent 7d9e078 commit e76194a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lsp-test/src/Language/LSP/Test.hs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -541,11 +541,10 @@ getCodeActions doc range = do
541541
getAndResolveCodeActions :: TextDocumentIdentifier -> Range -> Session [Command |? CodeAction]
542542
getAndResolveCodeActions doc range = do
543543
items <- getCodeActions doc range
544-
forM items leaveCommandResolveCodeAction
545-
where leaveCommandResolveCodeAction l@(InL _) = pure l
546-
leaveCommandResolveCodeAction (InR r) | isJust (r ^. L.data_) =
547-
InR <$> resolveCodeAction r
548-
leaveCommandResolveCodeAction r@(InR _) = pure r
544+
for items \case
545+
l@(InL _) -> pure l
546+
(InR r) | isJust (r ^. L.data_) -> InR <$> resolveCodeAction r
547+
r@(InR _) = pure r
549548

550549
-- | Returns all the code actions in a document by
551550
-- querying the code actions at each of the current
@@ -628,9 +627,9 @@ resolveCodeAction ca = do
628627
rsp <- request SMethod_CodeActionResolve ca
629628
case rsp ^. L.result of
630629
Right ca -> return ca
631-
Left error -> throw (UnexpectedResponseError (SomeLspId $ fromJust $ rsp ^. L.id) error)
630+
Left er -> throw (UnexpectedResponseError (SomeLspId $ fromJust $ rsp ^. L.id) er)
632631

633-
-- |If a code action contains a _data_ field, resolves, the code action, then
632+
-- |If a code action contains a _data_ field: resolves the code action, then
634633
-- executes it. Otherwise, just executes it.
635634
resolveAndExecuteCodeAction :: CodeAction -> Session ()
636635
resolveAndExecuteCodeAction ca@CodeAction{_data_=Just _} = do
@@ -686,7 +685,7 @@ getCompletions doc pos = do
686685
getAndResolveCompletions :: TextDocumentIdentifier -> Position -> Session [CompletionItem]
687686
getAndResolveCompletions doc pos = do
688687
items <- getCompletions doc pos
689-
forM items (\item -> if isJust (item ^. L.data_) then resolveCompletion item else pure item)
688+
for items $ \item -> if isJust (item ^. L.data_) then resolveCompletion item else pure item
690689

691690
-- |Resolves the provided completion item.
692691
resolveCompletion :: CompletionItem -> Session CompletionItem
@@ -797,12 +796,12 @@ getCodeLenses tId = do
797796
rsp <- request SMethod_TextDocumentCodeLens (CodeLensParams Nothing Nothing tId)
798797
pure $ absorbNull $ getResponseResult rsp
799798

800-
-- | RReturns the code lenses for the specified document, resolving any with
799+
-- | Returns the code lenses for the specified document, resolving any with
801800
-- a non empty _data_ field.
802801
getAndResolveCodeLenses :: TextDocumentIdentifier -> Session [CodeLens]
803802
getAndResolveCodeLenses tId = do
804803
codeLenses <- getCodeLenses tId
805-
forM codeLenses (\codeLens -> if isJust (codeLens ^. L.data_) then resolveCodeLens codeLens else pure codeLens)
804+
for codeLenses $ \codeLens -> if isJust (codeLens ^. L.data_) then resolveCodeLens codeLens else pure codeLens
806805

807806
-- |Resolves the provided code lens.
808807
resolveCodeLens :: CodeLens -> Session CodeLens

0 commit comments

Comments
 (0)