on master help sign in
Switch Type/ over to Data.Name
0f9b048Evan Czaplicki
compiler/src/Type/Constrain/Expression.hs+13−13
@@ -8,12 +8,12 @@ module Type.Constrain.Expression
8
8
9
9
10import qualified Data.Map.Strict as Map
10import qualified Data.Map.Strict as Map
11+import qualified Data.Name as Name
11
12
12import qualified AST.Canonical as Can
13import qualified AST.Canonical as Can
13import qualified AST.Module.Name as ModuleName
14import qualified AST.Module.Name as ModuleName
14import qualified AST.Utils.Shader as Shader
15import qualified AST.Utils.Shader as Shader
15import qualified Data.Index as Index
16import qualified Data.Index as Index
16−import qualified Elm.Name as N
17import qualified Reporting.Annotation as A
17import qualified Reporting.Annotation as A
18import qualified Reporting.Error.Type as E
18import qualified Reporting.Error.Type as E
19import Reporting.Error.Type (Expected(..), Context(..), SubContext(..), MaybeName(..), Category(..), PExpected(..), PContext(..))
19import Reporting.Error.Type (Expected(..), Context(..), SubContext(..), MaybeName(..), Category(..), PExpected(..), PContext(..))
@@ -35,7 +35,7 @@ import Type.Type as Type hiding (Descriptor(..))
35-- dictionary will hold variables for `a` and `b`
35-- dictionary will hold variables for `a` and `b`
36--
36--
37type RTV =
37type RTV =
38− Map.Map N.Name Type
38+ Map.Map Name.Name Type
39
39
40
40
41constrain :: RTV -> Can.Expr -> Expected Type -> IO Constraint
41constrain :: RTV -> Can.Expr -> Expected Type -> IO Constraint
@@ -228,7 +228,7 @@ getName (A.At _ expr) =
228 _ -> NoName
228 _ -> NoName
229
229
230
230
231−getAccessName :: Can.Expr -> Maybe N.Name
231+getAccessName :: Can.Expr -> Maybe Name.Name
232getAccessName (A.At _ expr) =
232getAccessName (A.At _ expr) =
233 case expr of
233 case expr of
234 Can.VarLocal name -> Just name
234 Can.VarLocal name -> Just name
@@ -241,7 +241,7 @@ getAccessName (A.At _ expr) =
241-- CONSTRAIN BINOP
241-- CONSTRAIN BINOP
242
242
243
243
244−constrainBinop :: RTV -> R.Region -> N.Name -> Can.Annotation -> Can.Expr -> Can.Expr -> Expected Type -> IO Constraint
244+constrainBinop :: RTV -> R.Region -> Name.Name -> Can.Annotation -> Can.Expr -> Can.Expr -> Expected Type -> IO Constraint
245constrainBinop rtv region op annotation leftExpr rightExpr expected =
245constrainBinop rtv region op annotation leftExpr rightExpr expected =
246 do leftVar <- mkFlexVar
246 do leftVar <- mkFlexVar
247 rightVar <- mkFlexVar
247 rightVar <- mkFlexVar
@@ -273,7 +273,7 @@ constrainList :: RTV -> R.Region -> [Can.Expr] -> Expected Type -> IO Constraint
273constrainList rtv region entries expected =
273constrainList rtv region entries expected =
274 do entryVar <- mkFlexVar
274 do entryVar <- mkFlexVar
275 let entryType = VarN entryVar
275 let entryType = VarN entryVar
276− let listType = AppN ModuleName.list N.list [entryType]
276+ let listType = AppN ModuleName.list Name.list [entryType]
277
277
278 entryCons <-
278 entryCons <-
279 Index.indexedTraverse (constrainListEntry rtv region entryType) entries
279 Index.indexedTraverse (constrainListEntry rtv region entryType) entries
@@ -376,7 +376,7 @@ constrainCaseBranch rtv (Can.CaseBranch pattern expr) pExpect bExpect =
376-- CONSTRAIN RECORD
376-- CONSTRAIN RECORD
377
377
378
378
379−constrainRecord :: RTV -> R.Region -> Map.Map N.Name Can.Expr -> Expected Type -> IO Constraint
379+constrainRecord :: RTV -> R.Region -> Map.Map Name.Name Can.Expr -> Expected Type -> IO Constraint
380constrainRecord rtv region fields expected =
380constrainRecord rtv region fields expected =
381 do dict <- traverse (constrainField rtv) fields
381 do dict <- traverse (constrainField rtv) fields
382
382
@@ -402,7 +402,7 @@ constrainField rtv expr =
402-- CONSTRAIN RECORD UPDATE
402-- CONSTRAIN RECORD UPDATE
403
403
404
404
405−constrainUpdate :: RTV -> R.Region -> N.Name -> Can.Expr -> Map.Map N.Name Can.FieldUpdate -> Expected Type -> IO Constraint
405+constrainUpdate :: RTV -> R.Region -> Name.Name -> Can.Expr -> Map.Map Name.Name Can.FieldUpdate -> Expected Type -> IO Constraint
406constrainUpdate rtv region name expr fields expected =
406constrainUpdate rtv region name expr fields expected =
407 do extVar <- mkFlexVar
407 do extVar <- mkFlexVar
408 fieldDict <- Map.traverseWithKey (constrainUpdateField rtv region) fields
408 fieldDict <- Map.traverseWithKey (constrainUpdateField rtv region) fields
@@ -423,7 +423,7 @@ constrainUpdate rtv region name expr fields expected =
423 return $ exists vars $ CAnd (fieldsCon:con:cons)
423 return $ exists vars $ CAnd (fieldsCon:con:cons)
424
424
425
425
426−constrainUpdateField :: RTV -> R.Region -> N.Name -> Can.FieldUpdate -> IO (Variable, Type, Constraint)
426+constrainUpdateField :: RTV -> R.Region -> Name.Name -> Can.FieldUpdate -> IO (Variable, Type, Constraint)
427constrainUpdateField rtv region field (Can.FieldUpdate _ expr) =
427constrainUpdateField rtv region field (Can.FieldUpdate _ expr) =
428 do var <- mkFlexVar
428 do var <- mkFlexVar
429 let tipe = VarN var
429 let tipe = VarN var
@@ -475,7 +475,7 @@ constrainShader region (Shader.Shader attributes uniforms varyings) expected =
475 let unifType = VarN unifVar
475 let unifType = VarN unifVar
476
476
477 let shaderType =
477 let shaderType =
478− AppN ModuleName.webgl N.shader
478+ AppN ModuleName.webgl Name.shader
479 [ toShaderRecord attributes attrType
479 [ toShaderRecord attributes attrType
480 , toShaderRecord uniforms unifType
480 , toShaderRecord uniforms unifType
481 , toShaderRecord varyings EmptyRecordN
481 , toShaderRecord varyings EmptyRecordN
@@ -485,7 +485,7 @@ constrainShader region (Shader.Shader attributes uniforms varyings) expected =
485 CEqual region Shader shaderType expected
485 CEqual region Shader shaderType expected
486
486
487
487
488−toShaderRecord :: Map.Map N.Name Shader.Type -> Type -> Type
488+toShaderRecord :: Map.Map Name.Name Shader.Type -> Type -> Type
489toShaderRecord types baseRecType =
489toShaderRecord types baseRecType =
490 if Map.null types then
490 if Map.null types then
491 baseRecType
491 baseRecType
@@ -590,7 +590,7 @@ data Info =
590 Info
590 Info
591 { _vars :: [Variable]
591 { _vars :: [Variable]
592 , _cons :: [Constraint]
592 , _cons :: [Constraint]
593− , _headers :: Map.Map N.Name (A.Located Type)
593+ , _headers :: Map.Map Name.Name (A.Located Type)
594 }
594 }
595
595
596
596
@@ -724,12 +724,12 @@ data TypedArgs =
724 }
724 }
725
725
726
726
727−constrainTypedArgs :: Map.Map N.Name Type -> N.Name -> [(Can.Pattern, Can.Type)] -> Can.Type -> IO TypedArgs
727+constrainTypedArgs :: Map.Map Name.Name Type -> Name.Name -> [(Can.Pattern, Can.Type)] -> Can.Type -> IO TypedArgs
728constrainTypedArgs rtv name args srcResultType =
728constrainTypedArgs rtv name args srcResultType =
729 typedArgsHelp rtv name Index.first args srcResultType Pattern.emptyState
729 typedArgsHelp rtv name Index.first args srcResultType Pattern.emptyState
730
730
731
731
732−typedArgsHelp :: Map.Map N.Name Type -> N.Name -> Index.ZeroBased -> [(Can.Pattern, Can.Type)] -> Can.Type -> Pattern.State -> IO TypedArgs
732+typedArgsHelp :: Map.Map Name.Name Type -> Name.Name -> Index.ZeroBased -> [(Can.Pattern, Can.Type)] -> Can.Type -> Pattern.State -> IO TypedArgs
733typedArgsHelp rtv name index args srcResultType state =
733typedArgsHelp rtv name index args srcResultType state =
734 case args of
734 case args of
735 [] ->
735 [] ->
compiler/src/Type/Constrain/Module.hs+12−12
@@ -7,10 +7,10 @@ module Type.Constrain.Module
7
7
8
8
9import qualified Data.Map.Strict as Map
9import qualified Data.Map.Strict as Map
10+import qualified Data.Name as Name
10
11
11import qualified AST.Canonical as Can
12import qualified AST.Canonical as Can
12import qualified AST.Module.Name as ModuleName
13import qualified AST.Module.Name as ModuleName
13−import qualified Elm.Name as N
14import qualified Reporting.Annotation as A
14import qualified Reporting.Annotation as A
15import qualified Reporting.Error.Type as E
15import qualified Reporting.Error.Type as E
16import qualified Reporting.Region as R
16import qualified Reporting.Region as R
@@ -69,7 +69,7 @@ constrainDecls decls finalConstraint =
69-- PORT HELPERS
69-- PORT HELPERS
70
70
71
71
72−letPort :: N.Name -> Can.Port -> IO Constraint -> IO Constraint
72+letPort :: Name.Name -> Can.Port -> IO Constraint -> IO Constraint
73letPort name port_ makeConstraint =
73letPort name port_ makeConstraint =
74 case port_ of
74 case port_ of
75 Can.Incoming freeVars _ srcType ->
75 Can.Incoming freeVars _ srcType ->
@@ -89,20 +89,20 @@ letPort name port_ makeConstraint =
89-- EFFECT MANAGER HELPERS
89-- EFFECT MANAGER HELPERS
90
90
91
91
92−letCmd :: ModuleName.Canonical -> N.Name -> Constraint -> IO Constraint
92+letCmd :: ModuleName.Canonical -> Name.Name -> Constraint -> IO Constraint
93letCmd home tipe constraint =
93letCmd home tipe constraint =
94 do msgVar <- mkFlexVar
94 do msgVar <- mkFlexVar
95 let msg = VarN msgVar
95 let msg = VarN msgVar
96− let cmdType = FunN (AppN home tipe [msg]) (AppN ModuleName.cmd N.cmd [msg])
96+ let cmdType = FunN (AppN home tipe [msg]) (AppN ModuleName.cmd Name.cmd [msg])
97 let header = Map.singleton "command" (A.At R.zero cmdType)
97 let header = Map.singleton "command" (A.At R.zero cmdType)
98 return $ CLet [msgVar] [] header CTrue constraint
98 return $ CLet [msgVar] [] header CTrue constraint
99
99
100
100
101−letSub :: ModuleName.Canonical -> N.Name -> Constraint -> IO Constraint
101+letSub :: ModuleName.Canonical -> Name.Name -> Constraint -> IO Constraint
102letSub home tipe constraint =
102letSub home tipe constraint =
103 do msgVar <- mkFlexVar
103 do msgVar <- mkFlexVar
104 let msg = VarN msgVar
104 let msg = VarN msgVar
105− let subType = FunN (AppN home tipe [msg]) (AppN ModuleName.sub N.sub [msg])
105+ let subType = FunN (AppN home tipe [msg]) (AppN ModuleName.sub Name.sub [msg])
106 let header = Map.singleton "subscription" (A.At R.zero subType)
106 let header = Map.singleton "subscription" (A.At R.zero subType)
107 return $ CLet [msgVar] [] header CTrue constraint
107 return $ CLet [msgVar] [] header CTrue constraint
108
108
@@ -155,22 +155,22 @@ constrainEffects home r0 r1 r2 manager =
155 checkMap "subMap" home sub CSaveTheEnvironment
155 checkMap "subMap" home sub CSaveTheEnvironment
156
156
157
157
158−effectList :: ModuleName.Canonical -> N.Name -> Type -> Type
158+effectList :: ModuleName.Canonical -> Name.Name -> Type -> Type
159effectList home name msg =
159effectList home name msg =
160− AppN ModuleName.list N.list [AppN home name [msg]]
160+ AppN ModuleName.list Name.list [AppN home name [msg]]
161
161
162
162
163task :: Type -> Type
163task :: Type -> Type
164task answer =
164task answer =
165− AppN ModuleName.platform N.task [ never, answer ]
165+ AppN ModuleName.platform Name.task [ never, answer ]
166
166
167
167
168router :: Type -> Type -> Type
168router :: Type -> Type -> Type
169router msg self =
169router msg self =
170− AppN ModuleName.platform N.router [ msg, self ]
170+ AppN ModuleName.platform Name.router [ msg, self ]
171
171
172
172
173−checkMap :: N.Name -> ModuleName.Canonical -> N.Name -> Constraint -> IO Constraint
173+checkMap :: Name.Name -> ModuleName.Canonical -> Name.Name -> Constraint -> IO Constraint
174checkMap name home tipe constraint =
174checkMap name home tipe constraint =
175 do a <- mkFlexVar
175 do a <- mkFlexVar
176 b <- mkFlexVar
176 b <- mkFlexVar
@@ -179,6 +179,6 @@ checkMap name home tipe constraint =
179 return $ CLet [a,b] [] Map.empty mapCon constraint
179 return $ CLet [a,b] [] Map.empty mapCon constraint
180
180
181
181
182−toMapType :: ModuleName.Canonical -> N.Name -> Type -> Type -> Type
182+toMapType :: ModuleName.Canonical -> Name.Name -> Type -> Type -> Type
183toMapType home tipe a b =
183toMapType home tipe a b =
184 (a ==> b) ==> AppN home tipe [a] ==> AppN home tipe [b]
184 (a ==> b) ==> AppN home tipe [a] ==> AppN home tipe [b]
compiler/src/Type/Constrain/Pattern.hs+7−7
@@ -10,11 +10,11 @@ module Type.Constrain.Pattern
10import Control.Arrow (second)
10import Control.Arrow (second)
11import Control.Monad (foldM)
11import Control.Monad (foldM)
12import qualified Data.Map.Strict as Map
12import qualified Data.Map.Strict as Map
13+import qualified Data.Name as Name
13
14
14import qualified AST.Canonical as Can
15import qualified AST.Canonical as Can
15import qualified AST.Module.Name as ModuleName
16import qualified AST.Module.Name as ModuleName
16import qualified Data.Index as Index
17import qualified Data.Index as Index
17−import qualified Elm.Name as N
18import qualified Reporting.Annotation as A
18import qualified Reporting.Annotation as A
19import qualified Reporting.Error.Type as E
19import qualified Reporting.Error.Type as E
20import qualified Reporting.Region as R
20import qualified Reporting.Region as R
@@ -37,7 +37,7 @@ data State =
37 }
37 }
38
38
39
39
40−type Header = Map.Map N.Name (A.Located Type)
40+type Header = Map.Map Name.Name (A.Located Type)
41
41
42
42
43add :: Can.Pattern -> E.PExpected Type -> State -> IO State
43add :: Can.Pattern -> E.PExpected Type -> State -> IO State
@@ -67,7 +67,7 @@ add (A.At region pattern) expectation state =
67 Can.PList patterns ->
67 Can.PList patterns ->
68 do entryVar <- mkFlexVar
68 do entryVar <- mkFlexVar
69 let entryType = VarN entryVar
69 let entryType = VarN entryVar
70− let listType = AppN ModuleName.list N.list [entryType]
70+ let listType = AppN ModuleName.list Name.list [entryType]
71
71
72 (State headers vars revCons) <-
72 (State headers vars revCons) <-
73 foldM (addEntry region entryType) state (Index.indexedMap (,) patterns)
73 foldM (addEntry region entryType) state (Index.indexedMap (,) patterns)
@@ -78,7 +78,7 @@ add (A.At region pattern) expectation state =
78 Can.PCons headPattern tailPattern ->
78 Can.PCons headPattern tailPattern ->
79 do entryVar <- mkFlexVar
79 do entryVar <- mkFlexVar
80 let entryType = VarN entryVar
80 let entryType = VarN entryVar
81− let listType = AppN ModuleName.list N.list [entryType]
81+ let listType = AppN ModuleName.list Name.list [entryType]
82
82
83 let headExpectation = E.PNoExpectation entryType
83 let headExpectation = E.PNoExpectation entryType
84 let tailExpectation = E.PFromContext region E.PTail listType
84 let tailExpectation = E.PFromContext region E.PTail listType
@@ -138,7 +138,7 @@ emptyState =
138 State Map.empty [] []
138 State Map.empty [] []
139
139
140
140
141−addToHeaders :: R.Region -> N.Name -> E.PExpected Type -> State -> State
141+addToHeaders :: R.Region -> Name.Name -> E.PExpected Type -> State -> State
142addToHeaders region name expectation (State headers vars revCons) =
142addToHeaders region name expectation (State headers vars revCons) =
143 let
143 let
144 tipe = getType expectation
144 tipe = getType expectation
@@ -211,7 +211,7 @@ simpleAdd pattern patternType state =
211-- CONSTRAIN CONSTRUCTORS
211-- CONSTRAIN CONSTRUCTORS
212
212
213
213
214−addCtor :: R.Region -> ModuleName.Canonical -> N.Name -> [N.Name] -> N.Name -> [Can.PatternCtorArg] -> E.PExpected Type -> State -> IO State
214+addCtor :: R.Region -> ModuleName.Canonical -> Name.Name -> [Name.Name] -> Name.Name -> [Can.PatternCtorArg] -> E.PExpected Type -> State -> IO State
215addCtor region home typeName typeVarNames ctorName args expectation state =
215addCtor region home typeName typeVarNames ctorName args expectation state =
216 do varPairs <- traverse (\var -> (,) var <$> nameToFlex var) typeVarNames
216 do varPairs <- traverse (\var -> (,) var <$> nameToFlex var) typeVarNames
217 let typePairs = map (second VarN) varPairs
217 let typePairs = map (second VarN) varPairs
@@ -231,7 +231,7 @@ addCtor region home typeName typeVarNames ctorName args expectation state =
231 }
231 }
232
232
233
233
234−addCtorArg :: R.Region -> N.Name -> Map.Map N.Name Type -> State -> Can.PatternCtorArg -> IO State
234+addCtorArg :: R.Region -> Name.Name -> Map.Map Name.Name Type -> State -> Can.PatternCtorArg -> IO State
235addCtorArg region ctorName freeVarDict state (Can.PatternCtorArg index srcType pattern) =
235addCtorArg region ctorName freeVarDict state (Can.PatternCtorArg index srcType pattern) =
236 do tipe <- Instantiate.fromSrcType freeVarDict srcType
236 do tipe <- Instantiate.fromSrcType freeVarDict srcType
237 let expectation = E.PFromContext region (E.PCtorArg ctorName index) tipe
237 let expectation = E.PFromContext region (E.PCtorArg ctorName index) tipe
compiler/src/Type/Error.hs+34−34
@@ -21,10 +21,10 @@ module Type.Error
21import qualified Data.Map as Map
21import qualified Data.Map as Map
22import qualified Data.Maybe as Maybe
22import qualified Data.Maybe as Maybe
23import Data.Monoid ((<>))
23import Data.Monoid ((<>))
24+import qualified Data.Name as Name
24
25
25import qualified AST.Module.Name as ModuleName
26import qualified AST.Module.Name as ModuleName
26import qualified Data.Bag as Bag
27import qualified Data.Bag as Bag
27−import qualified Elm.Name as N
28import qualified Reporting.Doc as D
28import qualified Reporting.Doc as D
29import qualified Reporting.Render.Type as RT
29import qualified Reporting.Render.Type as RT
30import qualified Reporting.Render.Type.Localizer as L
30import qualified Reporting.Render.Type.Localizer as L
@@ -38,15 +38,15 @@ data Type
38 = Lambda Type Type [Type]
38 = Lambda Type Type [Type]
39 | Infinite
39 | Infinite
40 | Error
40 | Error
41− | FlexVar N.Name
41+ | FlexVar Name.Name
42− | FlexSuper Super N.Name
42+ | FlexSuper Super Name.Name
43− | RigidVar N.Name
43+ | RigidVar Name.Name
44− | RigidSuper Super N.Name
44+ | RigidSuper Super Name.Name
45− | Type ModuleName.Canonical N.Name [Type]
45+ | Type ModuleName.Canonical Name.Name [Type]
46− | Record (Map.Map N.Name Type) Extension
46+ | Record (Map.Map Name.Name Type) Extension
47 | Unit
47 | Unit
48 | Tuple Type Type (Maybe Type)
48 | Tuple Type Type (Maybe Type)
49− | Alias ModuleName.Canonical N.Name [(N.Name, Type)] Type
49+ | Alias ModuleName.Canonical Name.Name [(Name.Name, Type)] Type
50
50
51
51
52data Super
52data Super
@@ -59,8 +59,8 @@ data Super
59
59
60data Extension
60data Extension
61 = Closed
61 = Closed
62− | FlexOpen N.Name
62+ | FlexOpen Name.Name
63− | RigidOpen N.Name
63+ | RigidOpen Name.Name
64
64
65
65
66iteratedDealias :: Type -> Type
66iteratedDealias :: Type -> Type
@@ -125,19 +125,19 @@ toDoc localizer ctx tipe =
125 aliasToDoc localizer ctx home name args
125 aliasToDoc localizer ctx home name args
126
126
127
127
128−aliasToDoc :: L.Localizer -> RT.Context -> ModuleName.Canonical -> N.Name -> [(N.Name, Type)] -> D.Doc
128+aliasToDoc :: L.Localizer -> RT.Context -> ModuleName.Canonical -> Name.Name -> [(Name.Name, Type)] -> D.Doc
129aliasToDoc localizer ctx home name args =
129aliasToDoc localizer ctx home name args =
130 RT.apply ctx
130 RT.apply ctx
131 (L.toDoc localizer home name)
131 (L.toDoc localizer home name)
132 (map (toDoc localizer RT.App . snd) args)
132 (map (toDoc localizer RT.App . snd) args)
133
133
134
134
135−fieldsToDocs :: L.Localizer -> Map.Map N.Name Type -> [(D.Doc, D.Doc)]
135+fieldsToDocs :: L.Localizer -> Map.Map Name.Name Type -> [(D.Doc, D.Doc)]
136fieldsToDocs localizer fields =
136fieldsToDocs localizer fields =
137 Map.foldrWithKey (addField localizer) [] fields
137 Map.foldrWithKey (addField localizer) [] fields
138
138
139
139
140−addField :: L.Localizer -> N.Name -> Type -> [(D.Doc, D.Doc)] -> [(D.Doc, D.Doc)]
140+addField :: L.Localizer -> Name.Name -> Type -> [(D.Doc, D.Doc)] -> [(D.Doc, D.Doc)]
141addField localizer fieldName fieldType docs =
141addField localizer fieldName fieldType docs =
142 let
142 let
143 f = D.fromName fieldName
143 f = D.fromName fieldName
@@ -178,11 +178,11 @@ data Problem
178 | AnythingToList
178 | AnythingToList
179 | MissingArgs Int
179 | MissingArgs Int
180 | ReturnMismatch
180 | ReturnMismatch
181− | BadFlexSuper Direction Super N.Name Type
181+ | BadFlexSuper Direction Super Name.Name Type
182− | BadRigidVar N.Name Type
182+ | BadRigidVar Name.Name Type
183− | BadRigidSuper Super N.Name Type
183+ | BadRigidSuper Super Name.Name Type
184− | FieldTypo N.Name [N.Name]
184+ | FieldTypo Name.Name [Name.Name]
185− | FieldsMissing [N.Name]
185+ | FieldsMissing [Name.Name]
186
186
187
187
188data Direction = Have | Need
188data Direction = Have | Need
@@ -398,39 +398,39 @@ isSimilar (Diff _ _ status) =
398-- IS TYPE?
398-- IS TYPE?
399
399
400
400
401−isBool :: ModuleName.Canonical -> N.Name -> Bool
401+isBool :: ModuleName.Canonical -> Name.Name -> Bool
402isBool home name =
402isBool home name =
403− home == ModuleName.basics && name == N.bool
403+ home == ModuleName.basics && name == Name.bool
404
404
405
405
406−isInt :: ModuleName.Canonical -> N.Name -> Bool
406+isInt :: ModuleName.Canonical -> Name.Name -> Bool
407isInt home name =
407isInt home name =
408− home == ModuleName.basics && name == N.int
408+ home == ModuleName.basics && name == Name.int
409
409
410
410
411−isFloat :: ModuleName.Canonical -> N.Name -> Bool
411+isFloat :: ModuleName.Canonical -> Name.Name -> Bool
412isFloat home name =
412isFloat home name =
413− home == ModuleName.basics && name == N.float
413+ home == ModuleName.basics && name == Name.float
414
414
415
415
416−isString :: ModuleName.Canonical -> N.Name -> Bool
416+isString :: ModuleName.Canonical -> Name.Name -> Bool
417isString home name =
417isString home name =
418− home == ModuleName.string && name == N.string
418+ home == ModuleName.string && name == Name.string
419
419
420
420
421−isChar :: ModuleName.Canonical -> N.Name -> Bool
421+isChar :: ModuleName.Canonical -> Name.Name -> Bool
422isChar home name =
422isChar home name =
423− home == ModuleName.char && name == N.char
423+ home == ModuleName.char && name == Name.char
424
424
425
425
426−isMaybe :: ModuleName.Canonical -> N.Name -> Bool
426+isMaybe :: ModuleName.Canonical -> Name.Name -> Bool
427isMaybe home name =
427isMaybe home name =
428− home == ModuleName.maybe && name == N.maybe
428+ home == ModuleName.maybe && name == Name.maybe
429
429
430
430
431−isList :: ModuleName.Canonical -> N.Name -> Bool
431+isList :: ModuleName.Canonical -> Name.Name -> Bool
432isList home name =
432isList home name =
433− home == ModuleName.list && name == N.list
433+ home == ModuleName.list && name == Name.list
434
434
435
435
436
436
@@ -455,7 +455,7 @@ isSuper super tipe =
455-- NAME CLASH
455-- NAME CLASH
456
456
457
457
458−nameClashToDoc :: RT.Context -> L.Localizer -> ModuleName.Canonical -> N.Name -> [Type] -> D.Doc
458+nameClashToDoc :: RT.Context -> L.Localizer -> ModuleName.Canonical -> Name.Name -> [Type] -> D.Doc
459nameClashToDoc ctx localizer (ModuleName.Canonical _ home) name args =
459nameClashToDoc ctx localizer (ModuleName.Canonical _ home) name args =
460 RT.apply ctx
460 RT.apply ctx
461 (D.yellow (D.fromName home) <> D.dullyellow ("." <> D.fromName name))
461 (D.yellow (D.fromName home) <> D.dullyellow ("." <> D.fromName name))
@@ -598,7 +598,7 @@ toGreedyMatchHelp localizer shorterArgs longerArgs match@(GreedyMatch shorterDoc
598-- RECORD DIFFS
598-- RECORD DIFFS
599
599
600
600
601−diffRecord :: L.Localizer -> Map.Map N.Name Type -> Extension -> Map.Map N.Name Type -> Extension -> Diff D.Doc
601+diffRecord :: L.Localizer -> Map.Map Name.Name Type -> Extension -> Map.Map Name.Name Type -> Extension -> Diff D.Doc
602diffRecord localizer fields1 ext1 fields2 ext2 =
602diffRecord localizer fields1 ext1 fields2 ext2 =
603 let
603 let
604 toUnknownDocs field tipe =
604 toUnknownDocs field tipe =
compiler/src/Type/Instantiate.hs+4−4
@@ -9,9 +9,9 @@ module Type.Instantiate
9
9
10import qualified Data.Map.Strict as Map
10import qualified Data.Map.Strict as Map
11import Data.Map.Strict ((!))
11import Data.Map.Strict ((!))
12+import qualified Data.Name as Name
12
13
13import qualified AST.Canonical as Can
14import qualified AST.Canonical as Can
14−import qualified Elm.Name as N
15import Type.Type
15import Type.Type
16
16
17
17
@@ -20,14 +20,14 @@ import Type.Type
20
20
21
21
22type FreeVars =
22type FreeVars =
23− Map.Map N.Name Type
23+ Map.Map Name.Name Type
24
24
25
25
26
26
27-- FROM SOURCE TYPE
27-- FROM SOURCE TYPE
28
28
29
29
30−fromSrcType :: Map.Map N.Name Type -> Can.Type -> IO Type
30+fromSrcType :: Map.Map Name.Name Type -> Can.Type -> IO Type
31fromSrcType freeVars sourceType =
31fromSrcType freeVars sourceType =
32 case sourceType of
32 case sourceType of
33 Can.TLambda arg result ->
33 Can.TLambda arg result ->
@@ -72,6 +72,6 @@ fromSrcType freeVars sourceType =
72 return (freeVars ! ext)
72 return (freeVars ! ext)
73
73
74
74
75−fromSrcFieldType :: Map.Map N.Name Type -> Can.FieldType -> IO Type
75+fromSrcFieldType :: Map.Map Name.Name Type -> Can.FieldType -> IO Type
76fromSrcFieldType freeVars (Can.FieldType _ tipe) =
76fromSrcFieldType freeVars (Can.FieldType _ tipe) =
77 fromSrcType freeVars tipe
77 fromSrcType freeVars tipe
compiler/src/Type/Solve.hs+13−13
@@ -9,11 +9,11 @@ module Type.Solve
9import Control.Monad
9import Control.Monad
10import qualified Data.Map.Strict as Map
10import qualified Data.Map.Strict as Map
11import Data.Map.Strict ((!))
11import Data.Map.Strict ((!))
12+import qualified Data.Name as Name
12import qualified Data.Vector as Vector
13import qualified Data.Vector as Vector
13import qualified Data.Vector.Mutable as MVector
14import qualified Data.Vector.Mutable as MVector
14
15
15import qualified AST.Canonical as Can
16import qualified AST.Canonical as Can
16−import qualified Elm.Name as N
17import qualified Reporting.Annotation as A
17import qualified Reporting.Annotation as A
18import qualified Reporting.Error.Type as Error
18import qualified Reporting.Error.Type as Error
19import qualified Reporting.Render.Type as RT
19import qualified Reporting.Render.Type as RT
@@ -29,7 +29,7 @@ import qualified Type.UnionFind as UF
29-- RUN SOLVER
29-- RUN SOLVER
30
30
31
31
32−run :: Constraint -> IO (Either [Error.Error] (Map.Map N.Name Can.Annotation))
32+run :: Constraint -> IO (Either [Error.Error] (Map.Map Name.Name Can.Annotation))
33run constraint =
33run constraint =
34 do pools <- MVector.replicate 8 []
34 do pools <- MVector.replicate 8 []
35
35
@@ -56,7 +56,7 @@ emptyState =
56
56
57
57
58type Env =
58type Env =
59− Map.Map N.Name Variable
59+ Map.Map Name.Name Variable
60
60
61
61
62type Pools =
62type Pools =
@@ -252,7 +252,7 @@ addError (State savedEnv rank errors) err =
252-- OCCURS CHECK
252-- OCCURS CHECK
253
253
254
254
255−occurs :: State -> (N.Name, A.Located Variable) -> IO State
255+occurs :: State -> (Name.Name, A.Located Variable) -> IO State
256occurs state (name, A.At region variable) =
256occurs state (name, A.At region variable) =
257 do hasOccurred <- Occurs.occurs variable
257 do hasOccurred <- Occurs.occurs variable
258 if hasOccurred
258 if hasOccurred
@@ -426,7 +426,7 @@ typeToVariable rank pools tipe =
426 typeToVar rank pools Map.empty tipe
426 typeToVar rank pools Map.empty tipe
427
427
428
428
429−typeToVar :: Int -> Pools -> Map.Map N.Name Variable -> Type -> IO Variable
429+typeToVar :: Int -> Pools -> Map.Map Name.Name Variable -> Type -> IO Variable
430typeToVar rank pools aliasDict tipe =
430typeToVar rank pools aliasDict tipe =
431 let go = typeToVar rank pools aliasDict in
431 let go = typeToVar rank pools aliasDict in
432 case tipe of
432 case tipe of
@@ -491,15 +491,15 @@ unit1 =
491-- SOURCE TYPE TO VARIABLE
491-- SOURCE TYPE TO VARIABLE
492
492
493
493
494−srcTypeToVariable :: Int -> Pools -> Map.Map N.Name () -> Can.Type -> IO Variable
494+srcTypeToVariable :: Int -> Pools -> Map.Map Name.Name () -> Can.Type -> IO Variable
495srcTypeToVariable rank pools freeVars srcType =
495srcTypeToVariable rank pools freeVars srcType =
496 let
496 let
497 nameToContent name
497 nameToContent name
498− | N.startsWith "number" name = FlexSuper Number (Just name)
498+ | Name.isNumberType name = FlexSuper Number (Just name)
499− | N.startsWith "comparable" name = FlexSuper Comparable (Just name)
499+ | Name.isComparableType name = FlexSuper Comparable (Just name)
500− | N.startsWith "appendable" name = FlexSuper Appendable (Just name)
500+ | Name.isAppendableType name = FlexSuper Appendable (Just name)
501− | N.startsWith "compappend" name = FlexSuper CompAppend (Just name)
501+ | Name.isCompappendType name = FlexSuper CompAppend (Just name)
502− | otherwise = FlexVar (Just name)
502+ | otherwise = FlexVar (Just name)
503
503
504 makeVar name _ =
504 makeVar name _ =
505 UF.fresh (Descriptor (nameToContent name) rank noMark Nothing)
505 UF.fresh (Descriptor (nameToContent name) rank noMark Nothing)
@@ -509,7 +509,7 @@ srcTypeToVariable rank pools freeVars srcType =
509 srcTypeToVar rank pools flexVars srcType
509 srcTypeToVar rank pools flexVars srcType
510
510
511
511
512−srcTypeToVar :: Int -> Pools -> Map.Map N.Name Variable -> Can.Type -> IO Variable
512+srcTypeToVar :: Int -> Pools -> Map.Map Name.Name Variable -> Can.Type -> IO Variable
513srcTypeToVar rank pools flexVars srcType =
513srcTypeToVar rank pools flexVars srcType =
514 let go = srcTypeToVar rank pools flexVars in
514 let go = srcTypeToVar rank pools flexVars in
515 case srcType of
515 case srcType of
@@ -555,7 +555,7 @@ srcTypeToVar rank pools flexVars srcType =
555 register rank pools (Alias home name argVars aliasVar)
555 register rank pools (Alias home name argVars aliasVar)
556
556
557
557
558−srcFieldTypeToVar :: Int -> Pools -> Map.Map N.Name Variable -> Can.FieldType -> IO Variable
558+srcFieldTypeToVar :: Int -> Pools -> Map.Map Name.Name Variable -> Can.FieldType -> IO Variable
559srcFieldTypeToVar rank pools flexVars (Can.FieldType _ srcTipe) =
559srcFieldTypeToVar rank pools flexVars (Can.FieldType _ srcTipe) =
560 srcTypeToVar rank pools flexVars srcTipe
560 srcTypeToVar rank pools flexVars srcTipe
561
561
compiler/src/Type/Type.hs+39−45
@@ -33,12 +33,12 @@ import Control.Monad.State.Strict (StateT, liftIO)
33import qualified Control.Monad.State.Strict as State
33import qualified Control.Monad.State.Strict as State
34import Data.Foldable (foldrM)
34import Data.Foldable (foldrM)
35import qualified Data.Map.Strict as Map
35import qualified Data.Map.Strict as Map
36+import qualified Data.Name as Name
36import Data.Word (Word32)
37import Data.Word (Word32)
37
38
38import qualified AST.Canonical as Can
39import qualified AST.Canonical as Can
39import qualified AST.Module.Name as ModuleName
40import qualified AST.Module.Name as ModuleName
40import qualified AST.Utils.Type as Type
41import qualified AST.Utils.Type as Type
41−import qualified Elm.Name as N
42import qualified Reporting.Annotation as A
42import qualified Reporting.Annotation as A
43import qualified Reporting.Error.Type as E
43import qualified Reporting.Error.Type as E
44import qualified Reporting.Region as R
44import qualified Reporting.Region as R
@@ -54,14 +54,14 @@ data Constraint
54 = CTrue
54 = CTrue
55 | CSaveTheEnvironment
55 | CSaveTheEnvironment
56 | CEqual R.Region E.Category Type (E.Expected Type)
56 | CEqual R.Region E.Category Type (E.Expected Type)
57− | CLocal R.Region N.Name (E.Expected Type)
57+ | CLocal R.Region Name.Name (E.Expected Type)
58− | CForeign R.Region N.Name Can.Annotation (E.Expected Type)
58+ | CForeign R.Region Name.Name Can.Annotation (E.Expected Type)
59 | CPattern R.Region E.PCategory Type (E.PExpected Type)
59 | CPattern R.Region E.PCategory Type (E.PExpected Type)
60 | CAnd [Constraint]
60 | CAnd [Constraint]
61 | CLet
61 | CLet
62 { _rigidVars :: [Variable]
62 { _rigidVars :: [Variable]
63 , _flexVars :: [Variable]
63 , _flexVars :: [Variable]
64− , _header :: Map.Map N.Name (A.Located Type)
64+ , _header :: Map.Map Name.Name (A.Located Type)
65 , _headerCon :: Constraint
65 , _headerCon :: Constraint
66 , _bodyCon :: Constraint
66 , _bodyCon :: Constraint
67 }
67 }
@@ -81,22 +81,22 @@ type Variable =
81
81
82
82
83data FlatType
83data FlatType
84− = App1 ModuleName.Canonical N.Name [Variable]
84+ = App1 ModuleName.Canonical Name.Name [Variable]
85 | Fun1 Variable Variable
85 | Fun1 Variable Variable
86 | EmptyRecord1
86 | EmptyRecord1
87− | Record1 (Map.Map N.Name Variable) Variable
87+ | Record1 (Map.Map Name.Name Variable) Variable
88 | Unit1
88 | Unit1
89 | Tuple1 Variable Variable (Maybe Variable)
89 | Tuple1 Variable Variable (Maybe Variable)
90
90
91
91
92data Type
92data Type
93− = PlaceHolder N.Name
93+ = PlaceHolder Name.Name
94− | AliasN ModuleName.Canonical N.Name [(N.Name, Type)] Type
94+ | AliasN ModuleName.Canonical Name.Name [(Name.Name, Type)] Type
95 | VarN Variable
95 | VarN Variable
96− | AppN ModuleName.Canonical N.Name [Type]
96+ | AppN ModuleName.Canonical Name.Name [Type]
97 | FunN Type Type
97 | FunN Type Type
98 | EmptyRecordN
98 | EmptyRecordN
99− | RecordN (Map.Map N.Name Type) Type
99+ | RecordN (Map.Map Name.Name Type) Type
100 | UnitN
100 | UnitN
101 | TupleN Type Type (Maybe Type)
101 | TupleN Type Type (Maybe Type)
102
102
@@ -115,12 +115,12 @@ data Descriptor =
115
115
116
116
117data Content
117data Content
118− = FlexVar (Maybe N.Name)
118+ = FlexVar (Maybe Name.Name)
119− | FlexSuper SuperType (Maybe N.Name)
119+ | FlexSuper SuperType (Maybe Name.Name)
120− | RigidVar N.Name
120+ | RigidVar Name.Name
121− | RigidSuper SuperType N.Name
121+ | RigidSuper SuperType Name.Name
122 | Structure FlatType
122 | Structure FlatType
123− | Alias ModuleName.Canonical N.Name [(N.Name,Variable)] Variable
123+ | Alias ModuleName.Canonical Name.Name [(Name.Name,Variable)] Variable
124 | Error
124 | Error
125
125
126
126
@@ -301,30 +301,30 @@ unnamedFlexSuper super =
301-- MAKE NAMED VARIABLES
301-- MAKE NAMED VARIABLES
302
302
303
303
304−nameToFlex :: N.Name -> IO Variable
304+nameToFlex :: Name.Name -> IO Variable
305nameToFlex name =
305nameToFlex name =
306 UF.fresh $ makeDescriptor $
306 UF.fresh $ makeDescriptor $
307 maybe FlexVar FlexSuper (toSuper name) (Just name)
307 maybe FlexVar FlexSuper (toSuper name) (Just name)
308
308
309
309
310−nameToRigid :: N.Name -> IO Variable
310+nameToRigid :: Name.Name -> IO Variable
311nameToRigid name =
311nameToRigid name =
312 UF.fresh $ makeDescriptor $
312 UF.fresh $ makeDescriptor $
313 maybe RigidVar RigidSuper (toSuper name) name
313 maybe RigidVar RigidSuper (toSuper name) name
314
314
315
315
316−toSuper :: N.Name -> Maybe SuperType
316+toSuper :: Name.Name -> Maybe SuperType
317toSuper name =
317toSuper name =
318− if N.startsWith "number" name then
318+ if Name.isNumberType name then
319 Just Number
319 Just Number
320
320
321− else if N.startsWith "comparable" name then
321+ else if Name.isComparableType name then
322 Just Comparable
322 Just Comparable
323
323
324− else if N.startsWith "appendable" name then
324+ else if Name.isAppendableType name then
325 Just Appendable
325 Just Appendable
326
326
327− else if N.startsWith "compappend" name then
327+ else if Name.isCompappendType name then
328 Just CompAppend
328 Just CompAppend
329
329
330 else
330 else
@@ -557,7 +557,7 @@ termToErrorType term =
557
557
558data NameState =
558data NameState =
559 NameState
559 NameState
560− { _taken :: Map.Map N.Name ()
560+ { _taken :: Map.Map Name.Name ()
561 , _normals :: Int
561 , _normals :: Int
562 , _numbers :: Int
562 , _numbers :: Int
563 , _comparables :: Int
563 , _comparables :: Int
@@ -566,7 +566,7 @@ data NameState =
566 }
566 }
567
567
568
568
569−makeNameState :: Map.Map N.Name Variable -> NameState
569+makeNameState :: Map.Map Name.Name Variable -> NameState
570makeNameState taken =
570makeNameState taken =
571 NameState (Map.map (const ()) taken) 0 0 0 0 0
571 NameState (Map.map (const ()) taken) 0 0 0 0 0
572
572
@@ -575,7 +575,7 @@ makeNameState taken =
575-- FRESH VAR NAMES
575-- FRESH VAR NAMES
576
576
577
577
578−getFreshVarName :: (Monad m) => StateT NameState m N.Name
578+getFreshVarName :: (Monad m) => StateT NameState m Name.Name
579getFreshVarName =
579getFreshVarName =
580 do index <- State.gets _normals
580 do index <- State.gets _normals
581 taken <- State.gets _taken
581 taken <- State.gets _taken
@@ -584,26 +584,23 @@ getFreshVarName =
584 return name
584 return name
585
585
586
586
587−getFreshVarNameHelp :: Int -> Map.Map N.Name () -> (N.Name, Int, Map.Map N.Name ())
587+getFreshVarNameHelp :: Int -> Map.Map Name.Name () -> (Name.Name, Int, Map.Map Name.Name ())
588getFreshVarNameHelp index taken =
588getFreshVarNameHelp index taken =
589 let
589 let
590− (postfix, letter) =
590+ name =
591− quotRem index 26
591+ Name.fromTypeVariableScheme index
592−
593− chr = N.fromLetter letter
594− name = if postfix <= 0 then chr else N.addIndex chr postfix
595 in
592 in
596− if Map.member name taken then
593+ if Map.member name taken then
597− getFreshVarNameHelp (index + 1) taken
594+ getFreshVarNameHelp (index + 1) taken
598− else
595+ else
599− ( name, index + 1, Map.insert name () taken )
596+ ( name, index + 1, Map.insert name () taken )
600
597
601
598
602
599
603-- FRESH SUPER NAMES
600-- FRESH SUPER NAMES
604
601
605
602
606−getFreshSuperName :: (Monad m) => SuperType -> StateT NameState m N.Name
603+getFreshSuperName :: (Monad m) => SuperType -> StateT NameState m Name.Name
607getFreshSuperName super =
604getFreshSuperName super =
608 case super of
605 case super of
609 Number ->
606 Number ->
@@ -619,7 +616,7 @@ getFreshSuperName super =
619 getFreshSuper "compappend" _compAppends (\index state -> state { _compAppends = index })
616 getFreshSuper "compappend" _compAppends (\index state -> state { _compAppends = index })
620
617
621
618
622−getFreshSuper :: (Monad m) => N.Name -> (NameState -> Int) -> (Int -> NameState -> NameState) -> StateT NameState m N.Name
619+getFreshSuper :: (Monad m) => Name.Name -> (NameState -> Int) -> (Int -> NameState -> NameState) -> StateT NameState m Name.Name
623getFreshSuper prefix getter setter =
620getFreshSuper prefix getter setter =
624 do index <- State.gets getter
621 do index <- State.gets getter
625 taken <- State.gets _taken
622 taken <- State.gets _taken
@@ -628,11 +625,11 @@ getFreshSuper prefix getter setter =
628 return name
625 return name
629
626
630
627
631−getFreshSuperHelp :: N.Name -> Int -> Map.Map N.Name () -> (N.Name, Int, Map.Map N.Name ())
628+getFreshSuperHelp :: Name.Name -> Int -> Map.Map Name.Name () -> (Name.Name, Int, Map.Map Name.Name ())
632getFreshSuperHelp prefix index taken =
629getFreshSuperHelp prefix index taken =
633 let
630 let
634 name =
631 name =
635− if index <= 0 then prefix else N.addIndex prefix index
632+ Name.fromTypeVariable prefix index
636 in
633 in
637 if Map.member name taken then
634 if Map.member name taken then
638 getFreshSuperHelp prefix (index + 1) taken
635 getFreshSuperHelp prefix (index + 1) taken
@@ -645,7 +642,7 @@ getFreshSuperHelp prefix index taken =
645-- GET ALL VARIABLE NAMES
642-- GET ALL VARIABLE NAMES
646
643
647
644
648−getVarNames :: Variable -> Map.Map N.Name Variable -> IO (Map.Map N.Name Variable)
645+getVarNames :: Variable -> Map.Map Name.Name Variable -> IO (Map.Map Name.Name Variable)
649getVarNames var takenNames =
646getVarNames var takenNames =
650 do (Descriptor content rank mark copy) <- UF.get var
647 do (Descriptor content rank mark copy) <- UF.get var
651 if mark == getVarNamesMark
648 if mark == getVarNamesMark
@@ -710,14 +707,11 @@ getVarNames var takenNames =
710-- REGISTER NAME / RENAME DUPLICATES
707-- REGISTER NAME / RENAME DUPLICATES
711
708
712
709
713−addName :: Int -> N.Name -> Variable -> (N.Name -> Content) -> Map.Map N.Name Variable -> IO (Map.Map N.Name Variable)
710+addName :: Int -> Name.Name -> Variable -> (Name.Name -> Content) -> Map.Map Name.Name Variable -> IO (Map.Map Name.Name Variable)
714addName index givenName var makeContent takenNames =
711addName index givenName var makeContent takenNames =
715 let
712 let
716 indexedName =
713 indexedName =
717− if index <= 0 then
718− givenName
719− else
720− N.addSafeIndex givenName index
714+ Name.fromTypeVariable givenName index
721 in
715 in
722 case Map.lookup indexedName takenNames of
716 case Map.lookup indexedName takenNames of
723 Nothing ->
717 Nothing ->
compiler/src/Type/Unify.hs+11−11
@@ -8,9 +8,9 @@ module Type.Unify
8
8
9
9
10import qualified Data.Map.Strict as Map
10import qualified Data.Map.Strict as Map
11+import qualified Data.Name as Name
11
12
12import qualified AST.Module.Name as ModuleName
13import qualified AST.Module.Name as ModuleName
13−import qualified Elm.Name as N
14import qualified Type.Error as Error
14import qualified Type.Error as Error
15import qualified Type.Occurs as Occurs
15import qualified Type.Occurs as Occurs
16import Type.Type as Type
16import Type.Type as Type
@@ -342,7 +342,7 @@ combineRigidSupers rigid flex =
342 || (rigid == CompAppend && (flex == Comparable || flex == Appendable))
342 || (rigid == CompAppend && (flex == Comparable || flex == Appendable))
343
343
344
344
345−atomMatchesSuper :: SuperType -> ModuleName.Canonical -> N.Name -> Bool
345+atomMatchesSuper :: SuperType -> ModuleName.Canonical -> Name.Name -> Bool
346atomMatchesSuper super home name =
346atomMatchesSuper super home name =
347 case super of
347 case super of
348 Number ->
348 Number ->
@@ -360,11 +360,11 @@ atomMatchesSuper super home name =
360 Error.isString home name
360 Error.isString home name
361
361
362
362
363−isNumber :: ModuleName.Canonical -> N.Name -> Bool
363+isNumber :: ModuleName.Canonical -> Name.Name -> Bool
364isNumber home name =
364isNumber home name =
365 home == ModuleName.basics
365 home == ModuleName.basics
366 &&
366 &&
367− (name == N.int || name == N.float)
367+ (name == Name.int || name == Name.float)
368
368
369
369
370unifyFlexSuperStructure :: Context -> SuperType -> FlatType -> Unify ()
370unifyFlexSuperStructure :: Context -> SuperType -> FlatType -> Unify ()
@@ -376,7 +376,7 @@ unifyFlexSuperStructure context super flatType =
376 else
376 else
377 mismatch
377 mismatch
378
378
379− App1 home name [variable] | home == ModuleName.list && name == N.list ->
379+ App1 home name [variable] | home == ModuleName.list && name == Name.list ->
380 case super of
380 case super of
381 Number ->
381 Number ->
382 mismatch
382 mismatch
@@ -444,7 +444,7 @@ unifyComparableRecursive var =
444-- UNIFY ALIASES
444-- UNIFY ALIASES
445
445
446
446
447−unifyAlias :: Context -> ModuleName.Canonical -> N.Name -> [(N.Name, Variable)] -> Variable -> Content -> Unify ()
447+unifyAlias :: Context -> ModuleName.Canonical -> Name.Name -> [(Name.Name, Variable)] -> Variable -> Content -> Unify ()
448unifyAlias context home name args realVar otherContent =
448unifyAlias context home name args realVar otherContent =
449 case otherContent of
449 case otherContent of
450 FlexVar _ ->
450 FlexVar _ ->
@@ -480,7 +480,7 @@ unifyAlias context home name args realVar otherContent =
480 merge context Error
480 merge context Error
481
481
482
482
483−unifyAliasArgs :: [Variable] -> Context -> [(N.Name,Variable)] -> [(N.Name,Variable)] -> ([Variable] -> () -> IO r) -> ([Variable] -> () -> IO r) -> IO r
483+unifyAliasArgs :: [Variable] -> Context -> [(Name.Name,Variable)] -> [(Name.Name,Variable)] -> ([Variable] -> () -> IO r) -> ([Variable] -> () -> IO r) -> IO r
484unifyAliasArgs vars context args1 args2 ok err =
484unifyAliasArgs vars context args1 args2 ok err =
485 case args1 of
485 case args1 of
486 (_,arg1):others1 ->
486 (_,arg1):others1 ->
@@ -648,7 +648,7 @@ unifyRecord context (RecordStructure fields1 ext1) (RecordStructure fields2 ext2
648 unifySharedFields context sharedFields otherFields ext
648 unifySharedFields context sharedFields otherFields ext
649
649
650
650
651−unifySharedFields :: Context -> Map.Map N.Name (Variable, Variable) -> Map.Map N.Name Variable -> Variable -> Unify ()
651+unifySharedFields :: Context -> Map.Map Name.Name (Variable, Variable) -> Map.Map Name.Name Variable -> Variable -> Unify ()
652unifySharedFields context sharedFields otherFields ext =
652unifySharedFields context sharedFields otherFields ext =
653 do matchingFields <- Map.traverseMaybeWithKey unifyField sharedFields
653 do matchingFields <- Map.traverseMaybeWithKey unifyField sharedFields
654 if Map.size sharedFields == Map.size matchingFields
654 if Map.size sharedFields == Map.size matchingFields
@@ -656,7 +656,7 @@ unifySharedFields context sharedFields otherFields ext =
656 else mismatch
656 else mismatch
657
657
658
658
659−unifyField :: N.Name -> (Variable, Variable) -> Unify (Maybe Variable)
659+unifyField :: Name.Name -> (Variable, Variable) -> Unify (Maybe Variable)
660unifyField _ (actual, expected) =
660unifyField _ (actual, expected) =
661 Unify $ \vars ok _ ->
661 Unify $ \vars ok _ ->
662 case subUnify actual expected of
662 case subUnify actual expected of
@@ -672,12 +672,12 @@ unifyField _ (actual, expected) =
672
672
673data RecordStructure =
673data RecordStructure =
674 RecordStructure
674 RecordStructure
675− { _fields :: Map.Map N.Name Variable
675+ { _fields :: Map.Map Name.Name Variable
676 , _extension :: Variable
676 , _extension :: Variable
677 }
677 }
678
678
679
679
680−gatherFields :: Map.Map N.Name Variable -> Variable -> IO RecordStructure
680+gatherFields :: Map.Map Name.Name Variable -> Variable -> IO RecordStructure
681gatherFields fields variable =
681gatherFields fields variable =
682 do (Descriptor content _ _ _) <- UF.get variable
682 do (Descriptor content _ _ _) <- UF.get variable
683 case content of
683 case content of