@@ -52,6 +52,9 @@ constrain rtv (A.At region expression) expected =
5252 Can.VarForeign _ name annotation ->
5353 return $ CInstance region (FuncName name) annotation expected
5454
55+ Can.VarDebug _ name annotation ->
56+ return $ CInstance region (FuncName name) annotation expected
57+
5558 Can.VarOperator op _ _ annotation ->
5659 return $ CInstance region (OpName op) annotation expected
5760
@@ -81,7 +84,7 @@ constrain rtv (A.At region expression) expected =
8184 Can.Binop op _ _ annotation leftExpr rightExpr ->
8285 constrainBinop rtv region op annotation leftExpr rightExpr expected
8386
84− Can.Lambda args _ body ->
87+ Can.Lambda args body ->
8588 constrainLambda rtv region args body expected
8689
8790 Can.Call func args ->
@@ -101,7 +104,7 @@ constrain rtv (A.At region expression) expected =
101104 constrainRecursiveDefs rtv defs
102105 =<< constrain rtv body expected
103106
104− Can.LetDestruct pattern _ expr body ->
107+ Can.LetDestruct pattern expr body ->
105108 constrainDestruct rtv region pattern expr
106109 =<< constrain rtv body expected
107110
@@ -150,7 +153,7 @@ constrain rtv (A.At region expression) expected =
150153-- CONSTRAIN LAMBDA
151154
152155
153−constrainLambda :: RTV -> R.Region -> [Can.Arg] -> Can.Expr -> Expected Type -> IO Constraint
156+constrainLambda :: RTV -> R.Region -> [Can.Pattern] -> Can.Expr -> Expected Type -> IO Constraint
154157constrainLambda rtv region args body expected =
155158 do (Args vars tipe resultType (Pattern.State headers pvars revCons)) <-
156159 constrainArgs args
@@ -375,7 +378,7 @@ constrainCase rtv region expr branches expected =
375378
376379
377380constrainCaseBranch :: RTV -> Can.CaseBranch -> PExpected Type -> Expected Type -> IO Constraint
378−constrainCaseBranch rtv (Can.CaseBranch pattern _ expr) pExpect bExpect =
381+constrainCaseBranch rtv (Can.CaseBranch pattern expr) pExpect bExpect =
379382 do (Pattern.State headers pvars revCons) <-
380383 Pattern.add pattern pExpect Pattern.emptyState
381384
@@ -534,7 +537,7 @@ constrainDestruct rtv region pattern expr bodyCon =
534537constrainDef :: RTV -> Can.Def -> Constraint -> IO Constraint
535538constrainDef rtv def bodyCon =
536539 case def of
537− Can.Def (A.At region name) args _ expr ->
540+ Can.Def (A.At region name) args expr ->
538541 do (Args vars tipe resultType (Pattern.State headers pvars revCons)) <-
539542 constrainArgs args
540543
@@ -557,7 +560,7 @@ constrainDef rtv def bodyCon =
557560 , _bodyCon = bodyCon
558561 }
559562
560− Can.TypedDef (A.At region name) freeVars typedArgs _ expr srcResultType ->
563+ Can.TypedDef (A.At region name) freeVars typedArgs expr srcResultType ->
561564 do let newNames = Map.difference freeVars rtv
562565 newRigids <- Map.traverseWithKey (\n _ -> nameToRigid n) newNames
563566 let newRtv = Map.union rtv (Map.map VarN newRigids)
@@ -622,7 +625,7 @@ recDefsHelp rtv defs bodyCon rigidInfo flexInfo =
622625
623626 def : otherDefs ->
624627 case def of
625− Can.Def (A.At region name) args _ expr ->
628+ Can.Def (A.At region name) args expr ->
626629 do let (Info flexVars flexCons flexHeaders) = flexInfo
627630
628631 (Args newFlexVars tipe resultType (Pattern.State headers pvars revCons)) <-
@@ -647,7 +650,7 @@ recDefsHelp rtv defs bodyCon rigidInfo flexInfo =
647650 , _headers = Map.insert name (A.At region tipe) flexHeaders
648651 }
649652
650− Can.TypedDef (A.At region name) freeVars typedArgs _ expr srcResultType ->
653+ Can.TypedDef (A.At region name) freeVars typedArgs expr srcResultType ->
651654 do let newNames = Map.difference freeVars rtv
652655 newRigids <- Map.traverseWithKey (\n _ -> nameToRigid n) newNames
653656 let newRtv = Map.union rtv (Map.map VarN newRigids)
@@ -692,12 +695,12 @@ data Args =
692695 }
693696
694697
695−constrainArgs :: [Can.Arg] -> IO Args
698+constrainArgs :: [Can.Pattern] -> IO Args
696699constrainArgs args =
697700 argsHelp args Pattern.emptyState
698701
699702
700−argsHelp :: [Can.Arg] -> Pattern.State -> IO Args
703+argsHelp :: [Can.Pattern] -> Pattern.State -> IO Args
701704argsHelp args state =
702705 case args of
703706 [] ->
@@ -705,7 +708,7 @@ argsHelp args state =
705708 let resultType = VarN resultVar
706709 return $ Args [resultVar] resultType resultType state
707710
708− (Can.Arg _ pattern) : otherArgs ->
711+ pattern : otherArgs ->
709712 do argVar <- mkFlexVar
710713 let argType = VarN argVar
711714
@@ -728,24 +731,24 @@ data TypedArgs =
728731 }
729732
730733
731−constrainTypedArgs :: Map.Map N.Name Type -> N.Name -> [Can.TypedArg] -> Can.Type -> IO TypedArgs
734+constrainTypedArgs :: Map.Map N.Name Type -> N.Name -> [(Can.Pattern, Can.Type)] -> Can.Type -> IO TypedArgs
732735constrainTypedArgs rtv name args srcResultType =
733736 do resultType <- Instantiate.fromSrcType rtv srcResultType
734− typedArgsHelp rtv name args resultType Pattern.emptyState
737+ typedArgsHelp rtv name Index.first args resultType Pattern.emptyState
735738
736739
737−typedArgsHelp :: Map.Map N.Name Type -> N.Name -> [Can.TypedArg] -> Type -> Pattern.State -> IO TypedArgs
738−typedArgsHelp rtv name args resultType state =
740+typedArgsHelp :: Map.Map N.Name Type -> N.Name -> Index.ZeroBased -> [(Can.Pattern, Can.Type)] -> Type -> Pattern.State -> IO TypedArgs
741+typedArgsHelp rtv name index args resultType state =
739742 case args of
740743 [] ->
741744 return $ TypedArgs resultType resultType state
742745
743− (Can.TypedArg index srcType pattern@(A.At region _)) : otherArgs ->
746+ (pattern@(A.At region _), srcType) : otherArgs ->
744747 do argType <- Instantiate.fromSrcType rtv srcType
745748 let expected = PFromContext region (PTypedArg name index) argType
746749
747750 (TypedArgs tipe result newState) <-
748− typedArgsHelp rtv name otherArgs resultType =<<
751+ typedArgsHelp rtv name (Index.next index) otherArgs resultType =<<
749752 Pattern.add pattern expected state
750753
751754 return (TypedArgs (FunN argType tipe) result newState)