on master help sign in
Make error format a bit nicer for incomplete patterns
2a9c8d7Evan Czaplicki
src/Nitpick/Pattern.hs+2−1
@@ -67,7 +67,8 @@ toString needsParens pattern =
67
67
68 Ctor tag args ->
68 Ctor tag args ->
69 if Var.isTuple tag then
69 if Var.isTuple tag then
70+ if null args then "()" else
70− "(" ++ List.intercalate ", " (map (toString False) args) ++ ")"
71+ "( " ++ List.intercalate ", " (map (toString False) args) ++ " )"
71
72
72 else
73 else
73 addParensIf (needsParens && not (null args)) $
74 addParensIf (needsParens && not (null args)) $
src/Reporting/Error/Pattern.hs+4−1
@@ -67,8 +67,11 @@ unhandledError unhandledPatterns relevantMessage =
67 patternList =
67 patternList =
68 map (Pattern.toString False) visiblePatterns
68 map (Pattern.toString False) visiblePatterns
69 ++ if null rest then [] else ["..."]
69 ++ if null rest then [] else ["..."]
70+
71+ noun =
72+ if length unhandledPatterns == 1 then "pattern" else "patterns"
70 in
73 in
71− "You need to account for the following values:\n"
74+ "You need to account for the following " ++ noun ++ ":\n"
72 ++ concatMap ("\n " ++) patternList ++ "\n"
75 ++ concatMap ("\n " ++) patternList ++ "\n"
73 ++ "\n"
76 ++ "\n"
74 ++ relevantMessage ++ "\n"
77 ++ relevantMessage ++ "\n"