@@ -7,7 +7,6 @@ import Data.Map qualified as Map
77import Data.Name qualified as N
88import Data.NonEmptyList qualified as NE
99import Data.Utf8 qualified as Utf8
10- import Data.Word (Word16 )
1110import Gren.ModuleName qualified as ModuleName
1211import Gren.Package qualified as Pkg
1312import Reporting.Annotation qualified as A
@@ -16,18 +15,6 @@ import Nitpick.PatternMatches (check, Error (..))
1615
1716import Test.Hspec (Spec , describe , it )
1817
19- -- Create a Located
20- at :: A. Region -> a -> A. Located a
21- at = A. At
22-
23- -- Create a Region
24- region :: A. Position -> A. Position -> A. Region
25- region = A. Region
26-
27- -- Creat a Position
28- pos :: Word16 -> Word16 -> A. Position
29- pos = A. Position
30-
3118-- Create a Can.Union for Bool
3219boolUnion :: Can. Union
3320boolUnion =
@@ -65,14 +52,14 @@ moduleNameCanonical pkgName authorName modName =
6552 }
6653
6754-- Create a Module from Decls
55+ -- We use A.zero to give an empty Region for exports and docs, as we don't
56+ -- care about their values
6857makeModule :: Can. Decls -> Can. Module
6958makeModule decls =
7059 Can. Module
7160 { Can. _name = moduleNameCanonical " TestPkg" " gren-devs" " TestModule"
72- -- The region here is made up and has no pertinent meaning
73- , Can. _exports = Can. ExportEverything (region (pos 1 1 ) (pos 3 3 ))
74- -- The region here is made up and has no pertinent meaning
75- , Can. _docs = Src. NoDocs (region (pos 1 1 ) (pos 3 3 ))
61+ , Can. _exports = Can. ExportEverything A. zero
62+ , Can. _docs = Src. NoDocs A. zero
7663 , Can. _decls = decls
7764 , Can. _unions = emptyUnions
7865 , Can. _aliases = emptyAliases
@@ -84,8 +71,7 @@ makeModule decls =
8471-- the compiler. Use this Region when doing so.
8572failedRegion :: A. Region
8673failedRegion =
87- region (pos 99 99 ) (pos 99 99 )
88-
74+ A. Region (A. Position 99 99 ) (A. Position 99 99 )
8975
9076
9177-- Incomplete Bool Records
@@ -99,31 +85,34 @@ fn r =
9985-- Debug.Trace trace was used to show the decls during "check",
10086-- and this function was entered into "gren repl".
10187-- The result was used to create this AST
88+ --
89+ -- Since we don't care about the true column/row range of each token
90+ -- in the source code, we use A.zero for each Region.
10291incompleteBoolRecordsDecls :: Can. Decls
10392incompleteBoolRecordsDecls =
10493 Can. Declare
105- (Can. Def (at (region (pos 2 1 ) (pos 2 6 )) ( N. fromChars " fn" ))
106- [ at (region (pos 2 7 ) (pos 2 8 )) (Can. PVar (N. fromChars " r" )) ]
107- (at (region (pos 3 5 ) (pos 5 37 ))
108- (Can. Case (at (region (pos 3 10 ) (pos 3 11 )) ( Can. VarLocal (N. fromChars " r" )))
94+ (Can. Def (A. At A. zero ( N. fromChars " fn" ))
95+ [ A. At A. zero (Can. PVar (N. fromChars " r" )) ]
96+ (A. At A. zero
97+ (Can. Case (A. At A. zero ( Can. VarLocal (N. fromChars " r" )))
10998 [ Can. CaseBranch
110- (at (region (pos 4 9 ) (pos 4 32 ))
99+ (A. At A. zero
111100 (Can. PRecord
112- [ at (region (pos 4 11 ) (pos 4 20 )) ( Can. PRFieldPattern (N. fromChars " a" ) (at (region (pos 4 15 ) (pos 4 20 )) (Can. PBool boolUnion False )))
113- , at (region (pos 4 22 ) (pos 4 30 )) ( Can. PRFieldPattern (N. fromChars " b" ) (at (region (pos 4 26 ) (pos 4 30 )) (Can. PBool boolUnion True )))
101+ [ A. At A. zero ( Can. PRFieldPattern (N. fromChars " a" ) (A. At A. zero (Can. PBool boolUnion False )))
102+ , A. At A. zero ( Can. PRFieldPattern (N. fromChars " b" ) (A. At A. zero (Can. PBool boolUnion True )))
114103 ]
115104 )
116105 )
117- (at (region (pos 4 36 ) (pos 4 37 )) (Can. Int 1 ))
106+ (A. At A. zero (Can. Int 1 ))
118107 , Can. CaseBranch
119- (at (region (pos 5 9 ) (pos 5 32 ))
108+ (A. At A. zero
120109 (Can. PRecord
121- [ at (region (pos 5 11 ) (pos 5 19 )) ( Can. PRFieldPattern (N. fromChars " a" ) (at (region (pos 5 15 ) (pos 5 19 )) (Can. PBool boolUnion True )))
122- , at (region (pos 5 21 ) (pos 5 30 )) ( Can. PRFieldPattern (N. fromChars " b" ) (at (region (pos 5 25 ) (pos 5 30 )) (Can. PBool boolUnion False )))
110+ [ A. At A. zero ( Can. PRFieldPattern (N. fromChars " a" ) (A. At A. zero (Can. PBool boolUnion True )))
111+ , A. At A. zero ( Can. PRFieldPattern (N. fromChars " b" ) (A. At A. zero (Can. PBool boolUnion False )))
123112 ]
124113 )
125114 )
126- (at (region (pos 5 36 ) (pos 5 37 )) (Can. Int 2 ))
115+ (A. At A. zero (Can. Int 2 ))
127116 ]
128117 )
129118 )
0 commit comments