on master help sign in
Make separate structure for PCtor args
a794af5Evan Czaplicki
src/AST/Expression/Canonical.hs+10−1
@@ -7,6 +7,7 @@ module AST.Expression.Canonical
7 , Args(..), Arg(..)
7 , Args(..), Arg(..)
8 , Match(..)
8 , Match(..)
9 , Pattern, Pattern_(..)
9 , Pattern, Pattern_(..)
10+ , PatternCtorArg(..)
10 , Destructors
11 , Destructors
11 , Destructor(..)
12 , Destructor(..)
12 -- decls
13 -- decls
@@ -122,10 +123,18 @@ data Pattern_
122 , _p_type :: N.Name
123 , _p_type :: N.Name
123 , _p_vars :: [N.Name]
124 , _p_vars :: [N.Name]
124 , _p_name :: N.Name
125 , _p_name :: N.Name
125− , _p_args :: [(Index.ZeroBased, Type.Canonical, Pattern)]
126+ , _p_args :: [PatternCtorArg]
126 }
127 }
127
128
128
129
130+data PatternCtorArg =
131+ PatternCtorArg
132+ { _index :: Index.ZeroBased
133+ , _type :: Type.Canonical
134+ , _arg :: Pattern
135+ }
136+
137+
129type Destructors = Map.Map N.Name (A.Located Destructor)
138type Destructors = Map.Map N.Name (A.Located Destructor)
130
139
131data Destructor
140data Destructor
src/Canonicalize/Pattern.hs+2−1
@@ -172,7 +172,8 @@ canonicalize env destructor (A.A region pattern) =
172 Src.PCtor nameRegion maybePrefix name patterns ->
172 Src.PCtor nameRegion maybePrefix name patterns ->
173 let
173 let
174 toCanonicalArg index ptrn tipe =
174 toCanonicalArg index ptrn tipe =
175+ Can.PatternCtorArg index tipe
175− (,,) index tipe <$> canonicalize env (Can.DIndex index destructor) ptrn
176+ <$> canonicalize env (Can.DIndex index destructor) ptrn
176 in
177 in
177 do (Env.Pattern home tipe vars args) <- Env.findPattern nameRegion env maybePrefix name
178 do (Env.Pattern home tipe vars args) <- Env.findPattern nameRegion env maybePrefix name
178 verifiedList <- Index.indexedZipWithA toCanonicalArg patterns args
179 verifiedList <- Index.indexedZipWithA toCanonicalArg patterns args