on master help sign in
Add fixities to module interfaces
fea6e5dEvan Czaplicki
compiler/Compiler.hs+2−1
@@ -150,7 +150,8 @@ buildFile flags moduleNum numModules interfaces filePath =
150 let interface = Canonical.interface name $ ModuleInterface {
150 let interface = Canonical.interface name $ ModuleInterface {
151 iTypes = types metaModule,
151 iTypes = types metaModule,
152 iAdts = datatypes metaModule,
152 iAdts = datatypes metaModule,
153− iAliases = aliases metaModule
153+ iAliases = aliases metaModule,
154+ iFixities = fixities metaModule
154 }
155 }
155 createDirectoryIfMissing True . dropFileName $ elmi flags filePath
156 createDirectoryIfMissing True . dropFileName $ elmi flags filePath
156 handle <- openBinaryFile (elmi flags filePath) WriteMode
157 handle <- openBinaryFile (elmi flags filePath) WriteMode
compiler/SourceSyntax/Module.hs+17−5
@@ -41,11 +41,23 @@ type Interfaces = Map.Map String ModuleInterface
41type ADT = (String, [String], [(String,[Type])])
41type ADT = (String, [String], [(String,[Type])])
42
42
43data ModuleInterface = ModuleInterface {
43data ModuleInterface = ModuleInterface {
44− iTypes :: Map.Map String Type,
44+ iTypes :: Map.Map String Type,
45− iAdts :: [ADT],
45+ iAdts :: [ADT],
46− iAliases :: [(String, [String], Type)]
46+ iAliases :: [(String, [String], Type)],
47+ iFixities :: [(Assoc, Int, String)]
47} deriving Show
48} deriving Show
48
49
49instance Binary ModuleInterface where
50instance Binary ModuleInterface where
51+ get = ModuleInterface <$> get <*> get <*> get <*> get
52+ put modul = do
53+ put (iTypes modul)
54+ put (iAdts modul)
50− put modul = put (iTypes modul) >> put (iAdts modul) >> put (iAliases modul)
55+ put (iAliases modul)
51− get = ModuleInterface <$> get <*> get <*> get
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
18
18
19interface :: String -> ModuleInterface -> ModuleInterface
19interface :: String -> ModuleInterface -> ModuleInterface
20interface moduleName iface =
20interface moduleName iface =
21− ModuleInterface {
21+ ModuleInterface
22− iTypes = Map.mapKeys prefix (Map.map renameType' (iTypes iface)),
22+ { iTypes = Map.mapKeys prefix (Map.map renameType' (iTypes iface))
23− iAdts = map (both prefix renameCtors) (iAdts iface),
23+ , iAdts = map (both prefix renameCtors) (iAdts iface)
24− iAliases = map (both prefix renameType') (iAliases iface)
24+ , iAliases = map (both prefix renameType') (iAliases iface)
25+ , iFixities = map (both id prefix) (iFixities iface)
25 }
26 }
26 where
27 where
27 both f g (a,b,c) = (f a, b, g c)
28 both f g (a,b,c) = (f a, b, g c)