@@ -20,6 +20,7 @@ import Control.Concurrent.Extra (readVar)
20
20
import Control.Exception.Safe (Exception (.. ), SomeException ,
21
21
catch , throwIO , try )
22
22
import Control.Monad (forM , unless )
23
+ import Control.Monad.Extra (maybeM )
23
24
import Control.Monad.IO.Class (MonadIO (liftIO ))
24
25
import Control.Monad.Trans.Class (MonadTrans (lift ))
25
26
import Control.Monad.Trans.Except (ExceptT (.. ), runExceptT ,
@@ -146,14 +147,14 @@ extractImports ModSummary{ms_mod} topLevelBinds (Unfold thing)
146
147
, names <- listify p fun_matches
147
148
=
148
149
[ AddImport {.. }
149
- | name <- names,
150
- Just ideclNameString <-
151
- [moduleNameString . GHC. moduleName <$> nameModule_maybe name],
152
- let ideclSource = False ,
150
+ | let ideclSource = False ,
151
+ name <- names,
153
152
let r = nameRdrName name,
154
153
let ideclQualifiedBool = isQual r,
155
154
let ideclAsString = moduleNameString . fst <$> isQual_maybe r,
156
- let ideclThing = Just (IEVar $ occNameString $ rdrNameOcc r)
155
+ let ideclThing = Just (IEVar $ occNameString $ rdrNameOcc r),
156
+ Just ideclNameString <-
157
+ [moduleNameString . GHC. moduleName <$> nameModule_maybe name]
157
158
]
158
159
where
159
160
p name = nameModule_maybe name /= Just ms_mod
@@ -178,8 +179,8 @@ provider state plId (CodeActionParams _ _ (TextDocumentIdentifier uri) range ca)
178
179
++ [ r
179
180
| TyClGroup {group_tyclds} <- hs_tyclds,
180
181
L l g <- group_tyclds,
181
- r <- suggestTypeRewrites uri ms_mod g ,
182
- pos `isInsideSrcSpan` l
182
+ pos `isInsideSrcSpan` l ,
183
+ r <- suggestTypeRewrites uri ms_mod g
183
184
184
185
]
185
186
@@ -235,7 +236,6 @@ suggestBindRewrites originatingFile pos ms_mod FunBind {fun_id = L l' rdrName}
235
236
description = " Fold " <> pprNameText <> describeRestriction restrictToOriginatingFile
236
237
in (description, CodeActionRefactorExtract , RunRetrieParams {.. })
237
238
in [unfoldRewrite False , unfoldRewrite True , foldRewrite False , foldRewrite True ]
238
- where
239
239
suggestBindRewrites _ _ _ _ = []
240
240
241
241
describeRestriction :: IsString p => Bool -> p
@@ -409,9 +409,7 @@ callRetrie state session rewrites origin restrictToOriginatingFile = do
409
409
-- TODO add the imports to the resulting edits
410
410
(_user, ast, change@ (Change _replacements _imports)) <-
411
411
lift $ runRetrie fixityEnv retrie cpp
412
- case ast of
413
- _ ->
414
- return $ asTextEdits change
412
+ return $ asTextEdits change
415
413
416
414
let (errors :: [CallRetrieError ], replacements ) = partitionEithers results
417
415
editParams :: WorkspaceEdit
@@ -485,7 +483,7 @@ handleMaybe :: Monad m => e -> Maybe b -> ExceptT e m b
485
483
handleMaybe msg = maybe (throwE msg) return
486
484
487
485
handleMaybeM :: Monad m => e -> m (Maybe b ) -> ExceptT e m b
488
- handleMaybeM msg act = maybe (throwE msg) return =<< lift act
486
+ handleMaybeM msg act = maybeM (throwE msg) return $ lift act
489
487
490
488
response :: Monad m => ExceptT String m a -> m (Either ResponseError a )
491
489
response =
0 commit comments