@@ -9,6 +9,7 @@ import qualified Data.Set as Set
99
1010import qualified AST.Expression.General as E
1111import qualified AST.Expression.Canonical as Canonical
12+import qualified AST.Helpers as Help
1213import qualified AST.Literal as L
1314import qualified AST.Module as Module
1415import qualified AST.Pattern as P
@@ -22,10 +23,16 @@ import qualified Reporting.Warning as Warning
2223
2324patternMatches
2425 :: Module.Interfaces
25− -> Module.Body Canonical.Expr
26+ -> Module.CanonicalModule
2627 -> Result.Result Warning.Warning e ()
27−patternMatches interfaces body =
28− checkExpression (toTagDict interfaces) (Module.program body)
28+patternMatches interfaces modul =
29+ let
30+ name = Module.names modul
31+ body = Module.body modul
32+ in
33+ checkExpression
34+ (toTagDict interfaces name (Module.datatypes body))
35+ (Module.program body)
2936
3037
3138-- PATTERN MATCH DATA STRUCTURE
@@ -73,8 +80,8 @@ type TagDict =
7380type Tag = String
7481
7582
76−toTagDict :: Module.Interfaces -> TagDict
77−toTagDict interfaces =
83+toTagDict :: Module.Interfaces -> Module.Name -> Module.ADTs -> TagDict
84+toTagDict interfaces localName localAdts =
7885 let
7986 listTags =
8087 [ ("::", 2), ("[]", 0) ]
@@ -90,6 +97,7 @@ toTagDict interfaces =
9097 interfaces
9198 |> Map.map (toTagMapping . Module.iAdts)
9299 |> Map.mapKeysMonotonic Var.Module
100+ |> Map.insert (Var.Module localName) (toTagMapping localAdts)
93101 in
94102 Map.union builtinDict interfaceDict
95103
@@ -115,6 +123,9 @@ lookupOtherCtors (Var.Canonical home name) tagDict =
115123 otherTags
116124
117125 Nothing ->
126+ if Help.isTuple name then
127+ [(name, read (drop 6 name))]
128+ else
118129 error
119130 "Since the Nitpick phase happens after canonicalization and type \
120131 \inference, it is impossible that a pattern in a case cannot be \