@@ -52,6 +52,9 @@ constrain rtv (A.At region expression) expected =
52 Can.VarForeign _ name annotation ->
52 Can.VarForeign _ name annotation ->
53 return $ CInstance region (FuncName name) annotation expected
53 return $ CInstance region (FuncName name) annotation expected
55+ Can.VarDebug _ name annotation ->
56+ return $ CInstance region (FuncName name) annotation expected
55 Can.VarOperator op _ _ annotation ->
58 Can.VarOperator op _ _ annotation ->
56 return $ CInstance region (OpName op) annotation expected
59 return $ CInstance region (OpName op) annotation expected
@@ -81,7 +84,7 @@ constrain rtv (A.At region expression) expected =
81 Can.Binop op _ _ annotation leftExpr rightExpr ->
84 Can.Binop op _ _ annotation leftExpr rightExpr ->
82 constrainBinop rtv region op annotation leftExpr rightExpr expected
85 constrainBinop rtv region op annotation leftExpr rightExpr expected
84− Can.Lambda args _ body ->
87+ Can.Lambda args body ->
85 constrainLambda rtv region args body expected
88 constrainLambda rtv region args body expected
87 Can.Call func args ->
90 Can.Call func args ->
@@ -101,7 +104,7 @@ constrain rtv (A.At region expression) expected =
101 constrainRecursiveDefs rtv defs
104 constrainRecursiveDefs rtv defs
102 =<< constrain rtv body expected
105 =<< constrain rtv body expected
104− Can.LetDestruct pattern _ expr body ->
107+ Can.LetDestruct pattern expr body ->
105 constrainDestruct rtv region pattern expr
108 constrainDestruct rtv region pattern expr
106 =<< constrain rtv body expected
109 =<< constrain rtv body expected
@@ -150,7 +153,7 @@ constrain rtv (A.At region expression) expected =
150-- CONSTRAIN LAMBDA
153-- CONSTRAIN LAMBDA
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
154constrainLambda rtv region args body expected =
157constrainLambda rtv region args body expected =
155 do (Args vars tipe resultType (Pattern.State headers pvars revCons)) <-
158 do (Args vars tipe resultType (Pattern.State headers pvars revCons)) <-
156 constrainArgs args
159 constrainArgs args
@@ -375,7 +378,7 @@ constrainCase rtv region expr branches expected =
377constrainCaseBranch :: RTV -> Can.CaseBranch -> PExpected Type -> Expected Type -> IO Constraint
380constrainCaseBranch :: 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 =
379 do (Pattern.State headers pvars revCons) <-
382 do (Pattern.State headers pvars revCons) <-
380 Pattern.add pattern pExpect Pattern.emptyState
383 Pattern.add pattern pExpect Pattern.emptyState
@@ -534,7 +537,7 @@ constrainDestruct rtv region pattern expr bodyCon =
534constrainDef :: RTV -> Can.Def -> Constraint -> IO Constraint
537constrainDef :: RTV -> Can.Def -> Constraint -> IO Constraint
535constrainDef rtv def bodyCon =
538constrainDef rtv def bodyCon =
536 case def of
539 case def of
537− Can.Def (A.At region name) args _ expr ->
540+ Can.Def (A.At region name) args expr ->
538 do (Args vars tipe resultType (Pattern.State headers pvars revCons)) <-
541 do (Args vars tipe resultType (Pattern.State headers pvars revCons)) <-
539 constrainArgs args
542 constrainArgs args
@@ -557,7 +560,7 @@ constrainDef rtv def bodyCon =
557 , _bodyCon = bodyCon
560 , _bodyCon = bodyCon
560− Can.TypedDef (A.At region name) freeVars typedArgs _ expr srcResultType ->
563+ Can.TypedDef (A.At region name) freeVars typedArgs expr srcResultType ->
561 do let newNames = Map.difference freeVars rtv
564 do let newNames = Map.difference freeVars rtv
562 newRigids <- Map.traverseWithKey (\n _ -> nameToRigid n) newNames
565 newRigids <- Map.traverseWithKey (\n _ -> nameToRigid n) newNames
563 let newRtv = Map.union rtv (Map.map VarN newRigids)
566 let newRtv = Map.union rtv (Map.map VarN newRigids)
@@ -622,7 +625,7 @@ recDefsHelp rtv defs bodyCon rigidInfo flexInfo =
623 def : otherDefs ->
626 def : otherDefs ->
624 case def of
627 case def of
625− Can.Def (A.At region name) args _ expr ->
628+ Can.Def (A.At region name) args expr ->
626 do let (Info flexVars flexCons flexHeaders) = flexInfo
629 do let (Info flexVars flexCons flexHeaders) = flexInfo
628 (Args newFlexVars tipe resultType (Pattern.State headers pvars revCons)) <-
631 (Args newFlexVars tipe resultType (Pattern.State headers pvars revCons)) <-
@@ -647,7 +650,7 @@ recDefsHelp rtv defs bodyCon rigidInfo flexInfo =
647 , _headers = Map.insert name (A.At region tipe) flexHeaders
650 , _headers = Map.insert name (A.At region tipe) flexHeaders
650− Can.TypedDef (A.At region name) freeVars typedArgs _ expr srcResultType ->
653+ Can.TypedDef (A.At region name) freeVars typedArgs expr srcResultType ->
651 do let newNames = Map.difference freeVars rtv
654 do let newNames = Map.difference freeVars rtv
652 newRigids <- Map.traverseWithKey (\n _ -> nameToRigid n) newNames
655 newRigids <- Map.traverseWithKey (\n _ -> nameToRigid n) newNames
653 let newRtv = Map.union rtv (Map.map VarN newRigids)
656 let newRtv = Map.union rtv (Map.map VarN newRigids)
@@ -692,12 +695,12 @@ data Args =
695−constrainArgs :: [Can.Arg] -> IO Args
698+constrainArgs :: [Can.Pattern] -> IO Args
696constrainArgs args =
699constrainArgs args =
697 argsHelp args Pattern.emptyState
700 argsHelp args Pattern.emptyState
700−argsHelp :: [Can.Arg] -> Pattern.State -> IO Args
703+argsHelp :: [Can.Pattern] -> Pattern.State -> IO Args
701argsHelp args state =
704argsHelp args state =
702 case args of
705 case args of
@@ -705,7 +708,7 @@ argsHelp args state =
705 let resultType = VarN resultVar
708 let resultType = VarN resultVar
706 return $ Args [resultVar] resultType resultType state
709 return $ Args [resultVar] resultType resultType state
708− (Can.Arg _ pattern) : otherArgs ->
711+ pattern : otherArgs ->
709 do argVar <- mkFlexVar
712 do argVar <- mkFlexVar
710 let argType = VarN argVar
713 let argType = VarN argVar
@@ -728,24 +731,24 @@ data TypedArgs =
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
732constrainTypedArgs rtv name args srcResultType =
735constrainTypedArgs rtv name args srcResultType =
733 do resultType <- Instantiate.fromSrcType rtv srcResultType
736 do resultType <- Instantiate.fromSrcType rtv srcResultType
734− typedArgsHelp rtv name args resultType Pattern.emptyState
737+ typedArgsHelp rtv name Index.first args resultType Pattern.emptyState
737−typedArgsHelp :: Map.Map N.Name Type -> N.Name -> [Can.TypedArg] -> Type -> Pattern.State -> IO TypedArgs
740+typedArgsHelp :: Map.Map N.Name Type -> N.Name -> Index.ZeroBased -> [(Can.Pattern, Can.Type)] -> Type -> Pattern.State -> IO TypedArgs
738−typedArgsHelp rtv name args resultType state =
741+typedArgsHelp rtv name index args resultType state =
739 case args of
742 case args of
741 return $ TypedArgs resultType resultType state
744 return $ TypedArgs resultType resultType state
743− (Can.TypedArg index srcType pattern@(A.At region _)) : otherArgs ->
746+ (pattern@(A.At region _), srcType) : otherArgs ->
744 do argType <- Instantiate.fromSrcType rtv srcType
747 do argType <- Instantiate.fromSrcType rtv srcType
745 let expected = PFromContext region (PTypedArg name index) argType
748 let expected = PFromContext region (PTypedArg name index) argType
747 (TypedArgs tipe result newState) <-
750 (TypedArgs tipe result newState) <-
748− typedArgsHelp rtv name otherArgs resultType =<<
751+ typedArgsHelp rtv name (Index.next index) otherArgs resultType =<<
749 Pattern.add pattern expected state
752 Pattern.add pattern expected state
751 return (TypedArgs (FunN argType tipe) result newState)
754 return (TypedArgs (FunN argType tipe) result newState)