File tree 2 files changed +13
-1
lines changed
src/Development/IDE/Plugin
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -739,7 +739,7 @@ suggestConstraint df parsedModule diag@Diagnostic {..}
739
739
where
740
740
findMissingConstraint :: T. Text -> Maybe T. Text
741
741
findMissingConstraint t =
742
- let regex = " (No instance for|Could not deduce) \\ ((.+)\\ ) arising from a use of"
742
+ let regex = " (No instance for|Could not deduce) \\ ((.+)\\ ) arising from" -- a use of / a do statement
743
743
in matchRegexUnifySpaces t regex <&> last
744
744
745
745
-- | Suggests a constraint for an instance declaration for which a constraint is missing.
Original file line number Diff line number Diff line change @@ -2043,6 +2043,13 @@ addFunctionConstraintTests = let
2043
2043
, " eq (Pair x y) (Pair x' y') = x == x' && y == y'"
2044
2044
]
2045
2045
2046
+ missingMonadConstraint constraint = T. unlines
2047
+ [ " module Testing where"
2048
+ , " f :: " <> constraint <> " m ()"
2049
+ , " f = do "
2050
+ , " return ()"
2051
+ ]
2052
+
2046
2053
check :: String -> T. Text -> T. Text -> T. Text -> TestTree
2047
2054
check testName actionTitle originalCode expectedCode = testSession testName $ do
2048
2055
doc <- createDoc " Testing.hs" " haskell" originalCode
@@ -2089,6 +2096,11 @@ addFunctionConstraintTests = let
2089
2096
" Add `Eq b` to the context of the type signature for `eq`"
2090
2097
(incompleteConstraintSourceCodeWithNewlinesInTypeSignature " Eq a" )
2091
2098
(incompleteConstraintSourceCodeWithNewlinesInTypeSignature " Eq a, Eq b" )
2099
+ , check
2100
+ " missing Monad constraint"
2101
+ " Add `Monad m` to the context of the type signature for `f`"
2102
+ (missingMonadConstraint " " )
2103
+ (missingMonadConstraint " Monad m => " )
2092
2104
]
2093
2105
2094
2106
removeRedundantConstraintsTests :: TestTree
You can’t perform that action at this time.
0 commit comments