1{-# OPTIONS_GHC -Wall #-}
2module Reporting.Error.Pattern where
4import qualified Data.Char as Char
5import Text.PrettyPrint ((<+>))
6import qualified Text.PrettyPrint as P
8import qualified AST.Helpers as Help
9import qualified AST.Type as Type
10import qualified AST.Variable as Var
11import qualified Nitpick.Pattern as Pattern
12import qualified Reporting.PrettyPrint as P
13import qualified Reporting.Region as Region
14import qualified Reporting.Report as Report
18 = Incomplete [Pattern.Pattern]
24toReport :: P.Dealiaser -> Error -> Report.Report
25toReport dealiaser err =
27 Incomplete unhandled ->
30 "The following `case` does not handle all possible inputs."
31 ( "The following patterns are not being handled:\n"
32 ++ viewPatternList unhandled
34 ++ "Did you add a new tag to a union type? Add how it should be handled here and"
35 ++ "you will be all set!"
37 ++ "If you want to go quick and implement this later, you can end the pattern with:"
40 ++ " Debug.crash \"TODO\""
42 ++ "When I see cases that end with this pattern, I augment the runtime error with"
43 ++ "the module name, the relevant line numbers, and the value led down that branch."
45 ++ "That said, you almost never want this in production code. If you think there"
46 ++ "are certain cases that are impossible in practice, consider refining how you"
47 ++ "model the data. If it can never happen in practice, you can probably define a"
48 ++ "union type such that the \"impossible\" cannot even be constructed in the"
49 ++ "first place. That is how you make something \"impossible\" truly impossible."
51 ++ "I won't say \"I told you so\" in the runtime error, but I'll be thinking it ;)"
57 "The following pattern is redundant."
58 "Any value with this shape will be handled by a previous pattern."
61viewPatternList :: [Pattern.Pattern] -> String
62viewPatternList unhandledPatterns =
64 (showPatterns, rest) =
65 splitAt 4 unhandledPatterns
67 concatMap ((++) "\n ") $
68 map Pattern.toString showPatterns
69 ++ if null rest then [] else ["..."]
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list