1{-# OPTIONS_GHC -Wall #-}
2module Reporting.Error.Pattern where
4import qualified Nitpick.Pattern as Pattern
5import qualified Reporting.PrettyPrint as P
6import qualified Reporting.Report as Report
10 = Incomplete [Pattern.Pattern]
16toReport :: P.Dealiaser -> Error -> Report.Report
17toReport dealiaser err =
19 Incomplete unhandled ->
22 "The following `case` does not handle all possible inputs."
23 ( "The following patterns are not being handled:\n"
24 ++ viewPatternList unhandled
26 ++ incompleteExplanation
32 "The following pattern is redundant."
33 "Any value with this shape will be handled by a previous pattern."
36viewPatternList :: [Pattern.Pattern] -> String
37viewPatternList unhandledPatterns =
39 (showPatterns, rest) =
40 splitAt 4 unhandledPatterns
42 concatMap ((++) "\n ") $
43 map (Pattern.toString False) showPatterns
44 ++ if null rest then [] else ["..."]
47incompleteExplanation :: String
48incompleteExplanation =
50 [ "Did you add a new tag to a union type? Add how it should be handled here and"
51 , "you will be all set!"
53 , "If you want to go quick and implement this later, you can end the pattern with:"
56 , " Debug.crash \"TODO\""
58 , "When I see cases that end with this pattern, I augment the runtime error with"
59 , "the module name, the relevant line numbers, and the value led down that branch."
61 , "That said, you almost never want this in production code. If you think there"
62 , "are certain cases that are impossible in practice, consider refining how you"
63 , "model the data. If it can never happen in practice, you can probably define a"
64 , "union type such that the \"impossible\" cannot even be constructed in the"
65 , "first place. That is how you make something \"impossible\" truly impossible."
67 , "I won't say \"I told you so\" in the runtime error, but I'll be thinking it ;)"
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