Make error format a bit nicer for incomplete patterns
commit2a9c8d7dace20692583a5bbea2d45ae2b2b26a91
authorEvan Czaplicki <evancz@users.noreply.github.com>
dateThu 24 Nov 2016, 03:06 (10 years ago)
parent626b319
src/Nitpick/Pattern.hs+2−1
@@ -67,7 +67,8 @@ toString needsParens pattern =
6767
6868 Ctor tag args ->
6969 if Var.isTuple tag then
70− "(" ++ List.intercalate ", " (map (toString False) args) ++ ")"
70+ if null args then "()" else
71+ "( " ++ List.intercalate ", " (map (toString False) args) ++ " )"
7172
7273 else
7374 addParensIf (needsParens && not (null args)) $
src/Reporting/Error/Pattern.hs+4−1
@@ -67,8 +67,11 @@ unhandledError unhandledPatterns relevantMessage =
6767 patternList =
6868 map (Pattern.toString False) visiblePatterns
6969 ++ if null rest then [] else ["..."]
70+
71+ noun =
72+ if length unhandledPatterns == 1 then "pattern" else "patterns"
7073 in
71− "You need to account for the following values:\n"
74+ "You need to account for the following " ++ noun ++ ":\n"
7275 ++ concatMap ("\n " ++) patternList ++ "\n"
7376 ++ "\n"
7477 ++ relevantMessage ++ "\n"