on master help sign in
Put type aliases in ModuleInterface
637c7e0Evan Czaplicki
compiler/Compiler.hs+2−1
@@ -120,7 +120,8 @@ buildFile flags moduleNum numModules interfaces filePath =
120 tipes <- toSrcTypes (types metaModule)
120 tipes <- toSrcTypes (types metaModule)
121 let interface = ModuleInterface {
121 let interface = ModuleInterface {
122 iTypes = tipes,
122 iTypes = tipes,
123− iAdts = datatypes metaModule
123+ iAdts = datatypes metaModule,
124+ iAliases = aliases metaModule
124 }
125 }
125 Binary.encodeFile (elmi flags filePath) interface
126 Binary.encodeFile (elmi flags filePath) interface
126 let js = jsModule metaModule
127 let js = jsModule metaModule
compiler/SourceSyntax/Module.hs+9−6
@@ -42,19 +42,21 @@ type Interfaces = Map.Map String ModuleInterface
42type ADT = (String, [String], [(String,[Type])])
42type ADT = (String, [String], [(String,[Type])])
43
43
44data ModuleInterface = ModuleInterface {
44data ModuleInterface = ModuleInterface {
45− iTypes :: Map.Map String Type,
45+ iTypes :: Map.Map String Type,
46− iAdts :: [ADT]
46+ iAdts :: [ADT],
47+ iAliases :: [(String, [String], Type)]
47} deriving Show
48} deriving Show
48
49
49instance Binary ModuleInterface where
50instance Binary ModuleInterface where
50− put modul = put (iTypes modul) >> put (iAdts modul)
51+ put modul = put (iTypes modul) >> put (iAdts modul) >> put (iAliases modul)
51− get = ModuleInterface <$> get <*> get
52+ get = ModuleInterface <$> get <*> get <*> get
52
53
53
54
54canonicalize :: String -> [ImportMethod] -> ModuleInterface -> ModuleInterface
55canonicalize :: String -> [ImportMethod] -> ModuleInterface -> ModuleInterface
55canonicalize prefix importMethods interface =
56canonicalize prefix importMethods interface =
56 ModuleInterface { iTypes = Map.unions (map iTypes ifaces)
57 ModuleInterface { iTypes = Map.unions (map iTypes ifaces)
57− , iAdts = concatMap iAdts ifaces }
58+ , iAdts = concatMap iAdts ifaces
59+ , iAliases = concatMap iAliases ifaces }
58 where
60 where
59 ifaces = map (canonicalizeHelp prefix interface) importMethods
61 ifaces = map (canonicalizeHelp prefix interface) importMethods
60
62
@@ -63,7 +65,8 @@ canonicalizeHelp :: String -> ModuleInterface -> ImportMethod -> ModuleInterface
63canonicalizeHelp prefix interface importMethod =
65canonicalizeHelp prefix interface importMethod =
64 ModuleInterface {
66 ModuleInterface {
65 iTypes = renameNames $ Map.map (renameType rename) (iTypes interface),
67 iTypes = renameNames $ Map.map (renameType rename) (iTypes interface),
66− iAdts = map renameADT (iAdts interface)
68+ iAdts = map renameADT (iAdts interface),
69+ iAliases = iAliases interface
67 }
70 }
68 where
71 where
69 addPrefix name = prefix ++ "." ++ name
72 addPrefix name = prefix ++ "." ++ name