@@ -10,6 +10,7 @@ module Elm.Kernel
1010import qualified Data.ByteString as B
1111import qualified Data.List as List
1212import qualified Data.Map as Map
13+import qualified Data.Name as Name
1314import qualified Data.Set as Set
1415import Data.Word (Word8)
1516
@@ -17,7 +18,6 @@ import Data.Word (Word8)
1718import qualified AST.Optimized as Opt
1819import qualified AST.Source as Src
1920import qualified AST.Module.Name as ModuleName
20−import qualified Elm.Name as N
2121import qualified Elm.Package as Pkg
2222import Parse.Primitives (Parser, run)
2323import qualified Parse.Primitives.Kernel as K
@@ -32,7 +32,7 @@ import qualified Reporting.Error as E
3232
3333
3434type ImportDict =
35− Map.Map N.Name [Pkg.Name]
35+ Map.Map Name.Name [Pkg.Name]
3636
3737
3838parse :: ImportDict -> B.ByteString -> Either E.Error Opt.KContent
@@ -64,7 +64,7 @@ parser importDict =
6464
6565
6666type VarTable =
67− Map.Map N.Name Opt.KChunk
67+ Map.Map Name.Name Opt.KChunk
6868
6969
7070data State =
@@ -78,13 +78,13 @@ processImports importDict imports =
7878
7979addImport :: ImportDict -> State -> Src.Import -> State
8080addImport importDict state (Src.Import (A.At _ home) maybeAlias exposing) =
81− if ModuleName.isKernel home then
81+ if Name.isKernel home then
8282 case maybeAlias of
8383 Just _ ->
84− error ("Cannot use aliases on kernel import of: " ++ N.toString home)
84+ error ("Cannot use aliases on kernel import of: " ++ Name.toString home)
8585
8686 Nothing ->
87− addKernelImport (ModuleName.getKernel home) exposing state
87+ addKernelImport (Name.getKernel home) exposing state
8888
8989 else
9090 case Map.lookup home importDict of
@@ -96,46 +96,46 @@ addImport importDict state (Src.Import (A.At _ home) maybeAlias exposing) =
9696 addNormalImport canonicalHome prefix exposing state
9797
9898 _ ->
99− error ("Cannot find kernel import of: " ++ N.toString home)
99+ error ("Cannot find kernel import of: " ++ Name.toString home)
100100
101101
102102-- INVARIANT: the `home` is the * in `Elm.Kernel.*`
103103--
104−addKernelImport :: N.Name -> Src.Exposing -> State -> State
104+addKernelImport :: Name.Name -> Src.Exposing -> State -> State
105105addKernelImport home exposing (State vtable deps) =
106106 let
107107 addVar table name =
108− Map.insert (N.sepBy 0x5F {- _ -} home name) (Opt.JsVar home name) table
108+ Map.insert (Name.sepBy 0x5F {- _ -} home name) (Opt.JsVar home name) table
109109 in
110110 State
111111 (List.foldl' addVar vtable (toNames exposing))
112112 (Set.insert (Opt.kernel home) deps)
113113
114114
115−addNormalImport :: ModuleName.Canonical -> N.Name -> Src.Exposing -> State -> State
115+addNormalImport :: ModuleName.Canonical -> Name.Name -> Src.Exposing -> State -> State
116116addNormalImport home prefix exposing state =
117117 let
118118 addVar (State vtable deps) name =
119119 State
120− (Map.insert (N.sepBy 0x5F {- _ -} prefix name) (Opt.ElmVar home name) vtable)
120+ (Map.insert (Name.sepBy 0x5F {- _ -} prefix name) (Opt.ElmVar home name) vtable)
121121 (Set.insert (Opt.Global home name) deps)
122122 in
123123 List.foldl' addVar state (toNames exposing)
124124
125125
126−toPrefix :: N.Name -> Maybe N.Name -> N.Name
126+toPrefix :: Name.Name -> Maybe Name.Name -> Name.Name
127127toPrefix home maybeAlias =
128128 case maybeAlias of
129129 Just alias ->
130130 alias
131131
132132 Nothing ->
133− if N.contains 0x2E {- . -} home then
134− error ("kernel imports with dots need an alias: " ++ show (N.toString home))
133+ if Name.hasDot home then
134+ error ("kernel imports with dots need an alias: " ++ show (Name.toString home))
135135 else
136136 home
137137
138−toNames :: Src.Exposing -> [N.Name]
138+toNames :: Src.Exposing -> [Name.Name]
139139toNames exposing =
140140 case exposing of
141141 Src.Open ->
@@ -145,7 +145,7 @@ toNames exposing =
145145 map toName exposedList
146146
147147
148−toName :: A.Located Src.Exposed -> N.Name
148+toName :: A.Located Src.Exposed -> Name.Name
149149toName (A.At _ exposed) =
150150 case exposed of
151151 Src.Lower name ->
@@ -185,7 +185,7 @@ chompChunks vtable enums fields chunks =
185185 K.Import var ->
186186 case Map.lookup var vtable of
187187 Nothing ->
188− error ("Bad kernel symbol: " ++ N.toString var)
188+ error ("Bad kernel symbol: " ++ Name.toString var)
189189
190190 Just chunk ->
191191 chompChunks vtable enums fields $
@@ -211,10 +211,10 @@ chompChunks vtable enums fields chunks =
211211
212212
213213type Fields =
214− Map.Map N.Name Int
214+ Map.Map Name.Name Int
215215
216216
217−lookupField :: N.Name -> Fields -> (Int, Fields)
217+lookupField :: Name.Name -> Fields -> (Int, Fields)
218218lookupField name fields =
219219 case Map.lookup name fields of
220220 Just n ->
@@ -230,10 +230,10 @@ lookupField name fields =
230230
231231
232232type Enums =
233− Map.Map Word8 (Map.Map N.Name Int)
233+ Map.Map Word8 (Map.Map Name.Name Int)
234234
235235
236−lookupEnum :: Word8 -> N.Name -> Enums -> (Int, Enums)
236+lookupEnum :: Word8 -> Name.Name -> Enums -> (Int, Enums)
237237lookupEnum word var allEnums =
238238 let
239239 enums =