on master help sign in
Add fixities to module interfaces
commitfea6e5d408332fa0c0ab3b33794092d7e8d1efaa authorEvan Czaplicki <info@elm-lang.org> dateThu 29 Aug 2013, 00:06 (13 years ago) parent95ec3a8
3 files changed+24−10
compiler/Compiler.hs+2−1 compiler/SourceSyntax/Module.hs+17−5 compiler/Transform/Canonicalize.hs+5−4
compiler/Compiler.hs+2−1
@@ -150,7 +150,8 @@ buildFile flags moduleNum numModules interfaces filePath =
150150 let interface = Canonical.interface name $ ModuleInterface {
151151 iTypes = types metaModule,
152152 iAdts = datatypes metaModule,
153− iAliases = aliases metaModule
153+ iAliases = aliases metaModule,
154+ iFixities = fixities metaModule
154155 }
155156 createDirectoryIfMissing True . dropFileName $ elmi flags filePath
156157 handle <- openBinaryFile (elmi flags filePath) WriteMode
compiler/SourceSyntax/Module.hs+17−5
@@ -41,11 +41,23 @@ type Interfaces = Map.Map String ModuleInterface
4141type ADT = (String, [String], [(String,[Type])])
4242
4343data ModuleInterface = ModuleInterface {
44− iTypes :: Map.Map String Type,
45− iAdts :: [ADT],
46− iAliases :: [(String, [String], Type)]
44+ iTypes :: Map.Map String Type,
45+ iAdts :: [ADT],
46+ iAliases :: [(String, [String], Type)],
47+ iFixities :: [(Assoc, Int, String)]
4748} deriving Show
4849
4950instance Binary ModuleInterface where
50− put modul = put (iTypes modul) >> put (iAdts modul) >> put (iAliases modul)
51− get = ModuleInterface <$> get <*> get <*> get
51+ get = ModuleInterface <$> get <*> get <*> get <*> get
52+ put modul = do
53+ put (iTypes modul)
54+ put (iAdts modul)
55+ put (iAliases modul)
56+ put (iFixities modul)
57+
58+
59+instance Binary Assoc where
60+ get = do n <- getWord8
61+ return $ case n of { 0 -> L ; 1 -> N ; 2 -> R }
62+
63+ put assoc = putWord8 $ case assoc of { L -> 0 ; N -> 1 ; R -> 2 }
compiler/Transform/Canonicalize.hs+5−4
@@ -18,10 +18,11 @@ import Text.PrettyPrint as P
1818
1919interface :: String -> ModuleInterface -> ModuleInterface
2020interface moduleName iface =
21− ModuleInterface {
22− iTypes = Map.mapKeys prefix (Map.map renameType' (iTypes iface)),
23− iAdts = map (both prefix renameCtors) (iAdts iface),
24− iAliases = map (both prefix renameType') (iAliases iface)
21+ ModuleInterface
22+ { iTypes = Map.mapKeys prefix (Map.map renameType' (iTypes iface))
23+ , iAdts = map (both prefix renameCtors) (iAdts iface)
24+ , iAliases = map (both prefix renameType') (iAliases iface)
25+ , iFixities = map (both id prefix) (iFixities iface)
2526 }
2627 where
2728 both f g (a,b,c) = (f a, b, g c)