on master help sign in
Put type aliases in ModuleInterface
commit637c7e0da00903aad44e4acc7bea404f124ee25a authorEvan Czaplicki <info@elm-lang.org> dateFri 26 Jul 2013, 15:06 (13 years ago) parentd7cdace
2 files changed+11−7
compiler/Compiler.hs+2−1 compiler/SourceSyntax/Module.hs+9−6
compiler/Compiler.hs+2−1
@@ -120,7 +120,8 @@ buildFile flags moduleNum numModules interfaces filePath =
120120 tipes <- toSrcTypes (types metaModule)
121121 let interface = ModuleInterface {
122122 iTypes = tipes,
123− iAdts = datatypes metaModule
123+ iAdts = datatypes metaModule,
124+ iAliases = aliases metaModule
124125 }
125126 Binary.encodeFile (elmi flags filePath) interface
126127 let js = jsModule metaModule
compiler/SourceSyntax/Module.hs+9−6
@@ -42,19 +42,21 @@ type Interfaces = Map.Map String ModuleInterface
4242type ADT = (String, [String], [(String,[Type])])
4343
4444data ModuleInterface = ModuleInterface {
45− iTypes :: Map.Map String Type,
46− iAdts :: [ADT]
45+ iTypes :: Map.Map String Type,
46+ iAdts :: [ADT],
47+ iAliases :: [(String, [String], Type)]
4748} deriving Show
4849
4950instance Binary ModuleInterface where
50− put modul = put (iTypes modul) >> put (iAdts modul)
51− get = ModuleInterface <$> get <*> get
51+ put modul = put (iTypes modul) >> put (iAdts modul) >> put (iAliases modul)
52+ get = ModuleInterface <$> get <*> get <*> get
5253
5354
5455canonicalize :: String -> [ImportMethod] -> ModuleInterface -> ModuleInterface
5556canonicalize prefix importMethods interface =
5657 ModuleInterface { iTypes = Map.unions (map iTypes ifaces)
57− , iAdts = concatMap iAdts ifaces }
58+ , iAdts = concatMap iAdts ifaces
59+ , iAliases = concatMap iAliases ifaces }
5860 where
5961 ifaces = map (canonicalizeHelp prefix interface) importMethods
6062
@@ -63,7 +65,8 @@ canonicalizeHelp :: String -> ModuleInterface -> ImportMethod -> ModuleInterface
6365canonicalizeHelp prefix interface importMethod =
6466 ModuleInterface {
6567 iTypes = renameNames $ Map.map (renameType rename) (iTypes interface),
66− iAdts = map renameADT (iAdts interface)
68+ iAdts = map renameADT (iAdts interface),
69+ iAliases = iAliases interface
6770 }
6871 where
6972 addPrefix name = prefix ++ "." ++ name