on master help sign in
Update validation for new Reporting.Annotation
1aa236aEvan Czaplicki
src/Validate.hs+18−18
@@ -62,7 +62,7 @@ vsdHelp decls stuff =
62 [] ->
62 [] ->
63 Result.ok stuff
63 Result.ok stuff
64
64
65− A.A region decl : otherDecls ->
65+ A.At region decl : otherDecls ->
66 case decl of
66 case decl of
67 Src.Union name tvars ctors ->
67 Src.Union name tvars ctors ->
68 do let union = Valid.Union name tvars ctors
68 do let union = Valid.Union name tvars ctors
@@ -83,12 +83,12 @@ vsdHelp decls stuff =
83 Src.Docs docs ->
83 Src.Docs docs ->
84 validateDocs docs otherDecls stuff
84 validateDocs docs otherDecls stuff
85
85
86− Src.Annotation (A.A _ name) tipe ->
86+ Src.Annotation (A.At _ name) tipe ->
87 validateAnnotation region name tipe otherDecls stuff
87 validateAnnotation region name tipe otherDecls stuff
88
88
89 Src.Definition name args body ->
89 Src.Definition name args body ->
90 do validBody <- expression body
90 do validBody <- expression body
91− let validDecl = A.A region (Valid.Decl name args validBody Nothing)
91+ let validDecl = A.At region (Valid.Decl name args validBody Nothing)
92 vsdHelp otherDecls $ stuff { _decls = validDecl : _decls stuff }
92 vsdHelp otherDecls $ stuff { _decls = validDecl : _decls stuff }
93
93
94
94
@@ -102,7 +102,7 @@ validateDocs docs decls stuff =
102 [] ->
102 [] ->
103 error "TODO no docs on nothing"
103 error "TODO no docs on nothing"
104
104
105− A.A _ decl : _ ->
105+ A.At _ decl : _ ->
106 do name <- getNameForDocs decl
106 do name <- getNameForDocs decl
107 vsdHelp decls $ stuff { _docs = Map.insert name docs (_docs stuff) }
107 vsdHelp decls $ stuff { _docs = Map.insert name docs (_docs stuff) }
108
108
@@ -110,10 +110,10 @@ validateDocs docs decls stuff =
110getNameForDocs :: Src.Decl_ -> Result w N.Name
110getNameForDocs :: Src.Decl_ -> Result w N.Name
111getNameForDocs decl =
111getNameForDocs decl =
112 case decl of
112 case decl of
113− Src.Union (A.A _ name) _ _ ->
113+ Src.Union (A.At _ name) _ _ ->
114 return name
114 return name
115
115
116− Src.Alias (A.A _ name) _ _ ->
116+ Src.Alias (A.At _ name) _ _ ->
117 return name
117 return name
118
118
119 Src.Binop _ _ _ _ ->
119 Src.Binop _ _ _ _ ->
@@ -125,10 +125,10 @@ getNameForDocs decl =
125 Src.Docs _ ->
125 Src.Docs _ ->
126 error "TODO no docs on docs"
126 error "TODO no docs on docs"
127
127
128− Src.Annotation (A.A _ name) _ ->
128+ Src.Annotation (A.At _ name) _ ->
129 return name
129 return name
130
130
131− Src.Definition (A.A _ name) _ _ ->
131+ Src.Definition (A.At _ name) _ _ ->
132 return name
132 return name
133
133
134
134
@@ -142,13 +142,13 @@ validateAnnotation annRegion annotationName tipe decls stuff =
142 [] ->
142 [] ->
143 error "TODO no attotations on nothing"
143 error "TODO no attotations on nothing"
144
144
145− A.A defRegion decl : otherDecls ->
145+ A.At defRegion decl : otherDecls ->
146 case decl of
146 case decl of
147− Src.Definition name@(A.A _ definitionName) args body ->
147+ Src.Definition name@(A.At _ definitionName) args body ->
148 if annotationName == definitionName then
148 if annotationName == definitionName then
149 do validBody <- expression body
149 do validBody <- expression body
150 let region = R.merge annRegion defRegion
150 let region = R.merge annRegion defRegion
151− let validDecl = A.A region (Valid.Decl name args validBody (Just tipe))
151+ let validDecl = A.At region (Valid.Decl name args validBody (Just tipe))
152 vsdHelp otherDecls $ stuff { _decls = validDecl : _decls stuff }
152 vsdHelp otherDecls $ stuff { _decls = validDecl : _decls stuff }
153
153
154 else
154 else
@@ -163,8 +163,8 @@ validateAnnotation annRegion annotationName tipe decls stuff =
163
163
164
164
165expression :: Src.Expr -> Result w Valid.Expr
165expression :: Src.Expr -> Result w Valid.Expr
166−expression (A.A region sourceExpression) =
166+expression (A.At region sourceExpression) =
167− A.A region <$>
167+ A.At region <$>
168 case sourceExpression of
168 case sourceExpression of
169 Src.Var prefix name ->
169 Src.Var prefix name ->
170 pure (Valid.Var prefix name)
170 pure (Valid.Var prefix name)
@@ -260,19 +260,19 @@ definitions sourceDefs =
260 [] ->
260 [] ->
261 return []
261 return []
262
262
263− A.A region (Src.Destruct pattern expr) : otherDefs ->
263+ A.At region (Src.Destruct pattern expr) : otherDefs ->
264 (:)
264 (:)
265 <$> validateDestruct region pattern expr
265 <$> validateDestruct region pattern expr
266 <*> definitions otherDefs
266 <*> definitions otherDefs
267
267
268− A.A region (Src.Define name args expr) : otherDefs ->
268+ A.At region (Src.Define name args expr) : otherDefs ->
269 (:)
269 (:)
270 <$> validateDefinition region name args expr Nothing
270 <$> validateDefinition region name args expr Nothing
271 <*> definitions otherDefs
271 <*> definitions otherDefs
272
272
273− A.A annRegion (Src.Annotate annotationName tipe) : otherDefs ->
273+ A.At annRegion (Src.Annotate annotationName tipe) : otherDefs ->
274 case otherDefs of
274 case otherDefs of
275− A.A defRegion (Src.Define name@(A.A _ definitionName) args expr) : otherOtherDefs
275+ A.At defRegion (Src.Define name@(A.At _ definitionName) args expr) : otherOtherDefs
276 | definitionName == annotationName ->
276 | definitionName == annotationName ->
277 (:)
277 (:)
278 <$> validateDefinition (R.merge annRegion defRegion) name args expr (Just tipe)
278 <$> validateDefinition (R.merge annRegion defRegion) name args expr (Just tipe)
@@ -323,5 +323,5 @@ validateEffects effects ports =
323
323
324noPorts :: [Valid.Port] -> Result w ()
324noPorts :: [Valid.Port] -> Result w ()
325noPorts ports =
325noPorts ports =
326− forM_ ports $ \(Valid.Port (A.A region name) _) ->
326+ forM_ ports $ \(Valid.Port (A.At region name) _) ->
327 Result.throw region (Error.UnexpectedPort name)
327 Result.throw region (Error.UnexpectedPort name)