@@ -20,8 +20,10 @@ import qualified Reporting.Region as R
2020import qualified Reporting.Result as Result
2121
2222
23+
2324-- VALIDATE DECLARATIONS
2425
26+
2527declarations
2628 :: Bool
2729 -> [D.SourceDecl]
@@ -78,8 +80,10 @@ validateDeclsHelp comment (A.A region decl) decls =
7880 portHelp comment region port decls
7981
8082
83+
8184-- VALIDATE DEFINITIONS IN DECLARATIONS
8285
86+
8387defHelp
8488 :: Maybe String
8589 -> Source.Def
@@ -111,8 +115,10 @@ defHelp comment (A.A region def) decls =
111115 Result.throw region (Error.TypeWithoutDefinition name)
112116
113117
118+
114119-- VALIDATE PORTS IN DECLARATIONS
115120
121+
116122portHelp
117123 :: Maybe String
118124 -> R.Region
@@ -140,8 +146,10 @@ portHelp comment region port decls =
140146 addRest (D.In name tipe) decls
141147
142148
149+
143150-- VALIDATE DEFINITIONS
144151
152+
145153definitions :: [Source.Def] -> Result.Result wrn Error.Error [Valid.Def]
146154definitions sourceDefs =
147155 do validDefs <- definitionsHelp sourceDefs
@@ -194,8 +202,10 @@ checkDefinition (Valid.Definition pattern body _) =
194202 Result.throw (R.merge start end) (Error.BadFunctionName (length args))
195203
196204
205+
197206-- VALIDATE EXPRESSIONS
198207
208+
199209expression :: Source.Expr -> Result.Result wrn Error.Error Valid.Expr
200210expression (A.A ann sourceExpression) =
201211 A.A ann <$>
@@ -300,16 +310,20 @@ both (expr1, expr2) =
300310 (,) <$> expression expr1 <*> expression expr2
301311
302312
313+
303314-- VALIDATE PATTERNS
304315
316+
305317validatePattern :: Pattern.RawPattern -> Result.Result wrn Error.Error Pattern.RawPattern
306318validatePattern pattern =
307319 do detectDuplicates Error.BadPattern (Pattern.boundVars pattern)
308320 return pattern
309321
310322
323+
311324-- DETECT DUPLICATES
312325
326+
313327detectDuplicates
314328 :: (String -> Error.Error)
315329 -> [A.Located String]
@@ -383,8 +397,10 @@ extractValues (A.A (region, _) decl) =
383397 )
384398
385399
400+
386401-- UNBOUND TYPE VARIABLES
387402
403+
388404checkDecl :: Bool -> D.ValidDecl -> Result.Result wrn Error.Error ()
389405checkDecl isRoot (A.A (region,_) decl) =
390406 case decl of