on master help sign in
Add package to interface file
4f369b8JoeyEremondi
src/AST/Module.hs+6−3
@@ -145,11 +145,12 @@ data Interface = Interface
145 , iAliases :: Aliases
145 , iAliases :: Aliases
146 , iFixities :: [(Decl.Assoc, Int, String)]
146 , iFixities :: [(Decl.Assoc, Int, String)]
147 , iPorts :: [String]
147 , iPorts :: [String]
148+ , iPackage :: Package.Name
148 }
149 }
149
150
150
151
151−toInterface :: CanonicalModule -> Interface
152+toInterface :: Package.Name -> CanonicalModule -> Interface
152−toInterface modul =
153+toInterface pkgName modul =
153 let body' = body modul in
154 let body' = body modul in
154 Interface
155 Interface
155 { iVersion = Package.versionToString Compiler.version
156 { iVersion = Package.versionToString Compiler.version
@@ -160,11 +161,12 @@ toInterface modul =
160 , iAliases = aliases body'
161 , iAliases = aliases body'
161 , iFixities = fixities body'
162 , iFixities = fixities body'
162 , iPorts = ports body'
163 , iPorts = ports body'
164+ , iPackage = pkgName
163 }
165 }
164
166
165
167
166instance Binary Interface where
168instance Binary Interface where
167− get = Interface <$> get <*> get <*> get <*> get <*> get <*> get <*> get <*> get
169+ get = Interface <$> get <*> get <*> get <*> get <*> get <*> get <*> get <*> get <*> get
168 put modul = do
170 put modul = do
169 put (iVersion modul)
171 put (iVersion modul)
170 put (iExports modul)
172 put (iExports modul)
@@ -174,3 +176,4 @@ instance Binary Interface where
174 put (iAliases modul)
176 put (iAliases modul)
175 put (iFixities modul)
177 put (iFixities modul)
176 put (iPorts modul)
178 put (iPorts modul)
179+ put (iPackage modul)
src/Compile.hs+1−1
@@ -76,7 +76,7 @@ unCanonicalizeInterfaces packageInfo ifaces =
76 let
76 let
77 foldFun canonName iface mapSoFar =
77 foldFun canonName iface mapSoFar =
78 case Map.lookup (Module.canonModul canonName) packageInfo of
78 case Map.lookup (Module.canonModul canonName) packageInfo of
79− Just pkg | pkg == (error "TODO iface pkg") ->
79+ Just pkg | pkg == Module.iPackage iface ->
80 Map.insert (Module.canonModul canonName) iface mapSoFar
80 Map.insert (Module.canonModul canonName) iface mapSoFar
81
81
82 _ ->
82 _ ->
src/Elm/Compiler.hs+1−1
@@ -81,7 +81,7 @@ compile context source interfaces =
81 do modul <- Compile.compile unwrappedPackages packageName isRoot unwrappedInterfaces source
81 do modul <- Compile.compile unwrappedPackages packageName isRoot unwrappedInterfaces source
82 docs <- docsGen isExposed modul
82 docs <- docsGen isExposed modul
83
83
84− let interface = Module.toInterface modul
84+ let interface = Module.toInterface packageName modul
85 let optModule = Optimize.optimize modul
85 let optModule = Optimize.optimize modul
86 let javascript = JS.generate optModule
86 let javascript = JS.generate optModule
87
87
src/Elm/Compiler/Module.hs+11−4
@@ -1,6 +1,7 @@
1module Elm.Compiler.Module
1module Elm.Compiler.Module
2 ( Interface, Name(Name), name
2 ( Interface, Name(Name), name
3− , CanonicalName(CanonicalName), canonicalName, canonPkg, canonModul, fromCanonicalName
3+ , CanonicalName(CanonicalName), canonicalName, canonPkg, canonModul
4+ , fromCanonicalName, canonFromPackage
4 , nameToPath
5 , nameToPath
5 , nameToString, nameFromString
6 , nameToString, nameFromString
6 , hyphenate, dehyphenate
7 , hyphenate, dehyphenate
@@ -37,16 +38,22 @@ newtype Name = Name [String]
37data CanonicalName =
38data CanonicalName =
38 CanonicalName
39 CanonicalName
39 { canonPkg :: Package.Name
40 { canonPkg :: Package.Name
41+ , canonVersion :: Package.Version
40 , canonModul :: Name
42 , canonModul :: Name
41− }
43+ } deriving (Eq, Ord)
44+
45+
46+canonFromPackage :: Package.Package -> Name -> CanonicalName
47+canonFromPackage (pk, vr) nm =
48+ CanonicalName pk vr nm
42
49
43
50
44fromCanonicalName :: CanonicalName -> Module.CanonicalName
51fromCanonicalName :: CanonicalName -> Module.CanonicalName
45−fromCanonicalName (CanonicalName p (Name n)) =
52+fromCanonicalName (CanonicalName p _ (Name n)) =
46 Module.CanonicalName p n
53 Module.CanonicalName p n
47
54
48
55
49−canonicalName :: Package.Name -> Name -> CanonicalName
56+canonicalName :: Package.Name -> Package.Version -> Name -> CanonicalName
50canonicalName = CanonicalName
57canonicalName = CanonicalName
51
58
52
59
src/Elm/Package.hs+3
@@ -19,6 +19,9 @@ data Name = Name
19 deriving (Eq, Ord)
19 deriving (Eq, Ord)
20
20
21
21
22+type Package = (Name, Version)
23+
24+
22dummyName :: Name
25dummyName :: Name
23dummyName =
26dummyName =
24 Name "USER" "PROJECT"
27 Name "USER" "PROJECT"