on master help sign in
Add package to interface file
commit4f369b8b327c92d4eb6c0df30b058d492c325be9 authorJoeyEremondi <joey@eremondi.com> dateThu 27 Aug 2015, 19:13 (11 years ago) parent499e6d9
5 files changed+22−9
src/AST/Module.hs+6−3 src/Compile.hs+1−1 src/Elm/Compiler.hs+1−1 src/Elm/Compiler/Module.hs+11−4 src/Elm/Package.hs+3
src/AST/Module.hs+6−3
@@ -145,11 +145,12 @@ data Interface = Interface
145145 , iAliases :: Aliases
146146 , iFixities :: [(Decl.Assoc, Int, String)]
147147 , iPorts :: [String]
148+ , iPackage :: Package.Name
148149 }
149150
150151
151−toInterface :: CanonicalModule -> Interface
152−toInterface modul =
152+toInterface :: Package.Name -> CanonicalModule -> Interface
153+toInterface pkgName modul =
153154 let body' = body modul in
154155 Interface
155156 { iVersion = Package.versionToString Compiler.version
@@ -160,11 +161,12 @@ toInterface modul =
160161 , iAliases = aliases body'
161162 , iFixities = fixities body'
162163 , iPorts = ports body'
164+ , iPackage = pkgName
163165 }
164166
165167
166168instance 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
168170 put modul = do
169171 put (iVersion modul)
170172 put (iExports modul)
@@ -174,3 +176,4 @@ instance Binary Interface where
174176 put (iAliases modul)
175177 put (iFixities modul)
176178 put (iPorts modul)
179+ put (iPackage modul)
src/Compile.hs+1−1
@@ -76,7 +76,7 @@ unCanonicalizeInterfaces packageInfo ifaces =
7676 let
7777 foldFun canonName iface mapSoFar =
7878 case Map.lookup (Module.canonModul canonName) packageInfo of
79− Just pkg | pkg == (error "TODO iface pkg") ->
79+ Just pkg | pkg == Module.iPackage iface ->
8080 Map.insert (Module.canonModul canonName) iface mapSoFar
8181
8282 _ ->
src/Elm/Compiler.hs+1−1
@@ -81,7 +81,7 @@ compile context source interfaces =
8181 do modul <- Compile.compile unwrappedPackages packageName isRoot unwrappedInterfaces source
8282 docs <- docsGen isExposed modul
8383
84− let interface = Module.toInterface modul
84+ let interface = Module.toInterface packageName modul
8585 let optModule = Optimize.optimize modul
8686 let javascript = JS.generate optModule
8787
src/Elm/Compiler/Module.hs+11−4
@@ -1,6 +1,7 @@
11module Elm.Compiler.Module
22 ( Interface, Name(Name), name
3− , CanonicalName(CanonicalName), canonicalName, canonPkg, canonModul, fromCanonicalName
3+ , CanonicalName(CanonicalName), canonicalName, canonPkg, canonModul
4+ , fromCanonicalName, canonFromPackage
45 , nameToPath
56 , nameToString, nameFromString
67 , hyphenate, dehyphenate
@@ -37,16 +38,22 @@ newtype Name = Name [String]
3738data CanonicalName =
3839 CanonicalName
3940 { canonPkg :: Package.Name
41+ , canonVersion :: Package.Version
4042 , 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
4249
4350
4451fromCanonicalName :: CanonicalName -> Module.CanonicalName
45−fromCanonicalName (CanonicalName p (Name n)) =
52+fromCanonicalName (CanonicalName p _ (Name n)) =
4653 Module.CanonicalName p n
4754
4855
49−canonicalName :: Package.Name -> Name -> CanonicalName
56+canonicalName :: Package.Name -> Package.Version -> Name -> CanonicalName
5057canonicalName = CanonicalName
5158
5259
src/Elm/Package.hs+3
@@ -19,6 +19,9 @@ data Name = Name
1919 deriving (Eq, Ord)
2020
2121
22+type Package = (Name, Version)
23+
24+
2225dummyName :: Name
2326dummyName =
2427 Name "USER" "PROJECT"