@@ -26,13 +26,10 @@ import Type.Type
2626-- CONSTRAIN PATTERN
2727
2828
29−type Env = ()
30−
31−
32−constrain :: Env -> Can.Pattern -> Type -> IO (Map.Map N.Name (A.Located Type), [Variable], Constraint)
33−constrain env pattern tipe =
29+constrain :: Can.Pattern -> Type -> IO (Map.Map N.Name (A.Located Type), [Variable], Constraint)
30+constrain pattern tipe =
3431 do (Info headers vars cons) <-
35− addConstraints env Error.PatternUnknown pattern tipe $
32+ addConstraints Error.PatternUnknown pattern tipe $
3633 Info Map.empty Bag.empty []
3734
3835 return ( headers, Bag.toList vars, CAnd (reverse cons) )
@@ -50,8 +47,8 @@ data Info =
5047 }
5148
5249
53−addConstraints :: Env -> Error.PatternContext -> Can.Pattern -> Type -> Info -> IO Info
54−addConstraints env context (A.A region pattern) tipe info =
50+addConstraints :: Error.PatternContext -> Can.Pattern -> Type -> Info -> IO Info
51+addConstraints context (A.A region pattern) tipe info =
5552 case pattern of
5653 Can.PAnything ->
5754 return info
@@ -68,7 +65,7 @@ addConstraints env context (A.A region pattern) tipe info =
6865
6966 Can.PAlias realPattern name ->
7067 do let (Info headers vars revCons) = info
71− addConstraints env context realPattern tipe $
68+ addConstraints context realPattern tipe $
7269 Info (Map.insert name (A.A region tipe) headers) vars revCons
7370
7471 Can.PUnit ->
@@ -77,13 +74,13 @@ addConstraints env context (A.A region pattern) tipe info =
7774 return $ Info headers vars (unitCon:revCons)
7875
7976 Can.PTuple a b maybeC ->
80− addTupleConstraint env context region a b maybeC tipe info
77+ addTupleConstraint context region a b maybeC tipe info
8178
8279 Can.PCtor home typeName vs ctorName args ->
8380 do (Instantiate.Ctor tvars targs ttype) <- Instantiate.pattern home typeName vs args
8481
8582 (Info headers vars revCons) <-
86− foldM (addCtorConstraint env ctorName) info targs
83+ foldM (addCtorConstraint ctorName) info targs
8784
8885 return $
8986 Info
@@ -101,7 +98,7 @@ addConstraints env context (A.A region pattern) tipe info =
10198
10299 (Info headers vars revCons) <-
103100 foldM
104− (addListConstraint env entryVarN)
101+ (addListConstraint entryVarN)
105102 info
106103 (zip patterns [ 1 .. length patterns ])
107104
@@ -116,8 +113,8 @@ addConstraints env context (A.A region pattern) tipe info =
116113 let tailType = AppN ModuleName.list N.list [tailVarN]
117114
118115 (Info headers vars revCons) <-
119− addConstraints env Error.PatternTail tailPattern tailType =<<
120− addConstraints env Error.PatternUnknown headPattern headVarN info
116+ addConstraints Error.PatternTail tailPattern tailType =<<
117+ addConstraints Error.PatternUnknown headPattern headVarN info
121118
122119 return $
123120 Info
@@ -154,18 +151,18 @@ addConstraints env context (A.A region pattern) tipe info =
154151-- CONSTRAIN CONSTRUCTORS
155152
156153
157−addCtorConstraint :: Env -> N.Name -> Info -> (Int, Type, Can.Pattern) -> IO Info
158−addCtorConstraint env name info (index, argType, argPattern) =
159− addConstraints env (Error.PatternArg name index) argPattern argType info
154+addCtorConstraint :: N.Name -> Info -> (Int, Type, Can.Pattern) -> IO Info
155+addCtorConstraint name info (index, argType, argPattern) =
156+ addConstraints (Error.PatternArg name index) argPattern argType info
160157
161158
162159
163160-- CONSTRAIN LIST
164161
165162
166−addListConstraint :: Env -> Type -> Info -> (Can.Pattern, Int) -> IO Info
167−addListConstraint env tipe info (pattern, index) =
168− addConstraints env (Error.PatternList index) pattern tipe info
163+addListConstraint :: Type -> Info -> (Can.Pattern, Int) -> IO Info
164+addListConstraint tipe info (pattern, index) =
165+ addConstraints (Error.PatternList index) pattern tipe info
169166
170167
171168
@@ -173,8 +170,7 @@ addListConstraint env tipe info (pattern, index) =
173170
174171
175172addTupleConstraint
176− :: Env
177− -> Error.PatternContext
173+ :: Error.PatternContext
178174 -> R.Region
179175 -> Can.Pattern
180176 -> Can.Pattern
@@ -182,9 +178,9 @@ addTupleConstraint
182178 -> Type
183179 -> Info
184180 -> IO Info
185−addTupleConstraint env context region a b maybeC tipe (Info headers vars revCons) =
181+addTupleConstraint context region a b maybeC tipe (Info headers vars revCons) =
186182 do let equal = CEqual (Error.Pattern context Error.PTuple) region
187− let addCon = addConstraints env Error.PatternUnknown
183+ let addCon = addConstraints Error.PatternUnknown
188184
189185 aVar <- mkFlexVar
190186 bVar <- mkFlexVar