on master help sign in
added Report/Error and Report/Warning
commit2aa7dcdd2eb9236baf0a992e843ae8fab68c7be5 authorIzaak Meckler <ihmeckler@gmail.com> dateMon 4 May 2015, 18:21 (12 years ago) parente1517f2
2 files changed+52
src/Reporting/Error/CheckMatch.hs+24 src/Reporting/Warning/CheckMatch.hs+28
src/Reporting/Error/CheckMatch.hsnew file+24
@@ -0,0 +1,24 @@
1+module Reporting.Error.CheckMatch where
2+
3+import qualified Data.Aeson as Json
4+
5+import qualified AST.Variable as Var
6+import qualified Reporting.Region as R
7+
8+data Error = ConstructorTypeNotFound Var.Canonical
9+
10+-- TO STRING
11+
12+toString :: R.Region -> Error -> String
13+toString region err =
14+ case err of
15+ _ -> error "CheckMatch.toString" region
16+
17+
18+-- TO JSON
19+
20+toJson :: Error -> Json.Value
21+toJson err =
22+ case err of
23+ _ -> error "CheckMatch.toJson"
24+
src/Reporting/Warning/CheckMatch.hsnew file+28
@@ -0,0 +1,28 @@
1+module Reporting.Warning.CheckMatch where
2+
3+import qualified AST.Pattern as Pattern
4+import qualified AST.Literal as Literal
5+import qualified Data.Set as Set
6+import qualified AST.Variable as Var
7+
8+data Pat var
9+ = Data var [Pat var]
10+ | Record [String]
11+ | Alias String (Pat var)
12+ | Var String
13+ | Anything
14+ | Literal Literal.Literal
15+ -- It's a shame that I had to replicate the entire pattern type, but it's
16+ -- essential to have this constructor.
17+ | AnythingBut (Set.Set Literal.Literal)
18+ deriving (Show, Eq)
19+
20+type CanonicalPat =
21+ Pat Var.Canonical
22+
23+data Warning
24+ = Redundant Pattern.CanonicalPattern
25+ -- The argument is the list of patterns that would have to
26+ -- be added for the case expression to be exhaustive.
27+ | Inexhaustive [CanonicalPat]
28+