@@ -17,19 +17,23 @@ import qualified Type.Inference as TI
1717
1818
1919compile
20− :: Package.Name
20+ :: Map.Map Module.Name Package.Name
21+ -> Package.Name
2122 -> Bool
22− -> Module.Interfaces
23+ -> Module.CanonicalInterfaces
2324 -> String
2425 -> Result.Result Warning.Warning Error.Error Module.CanonicalModule
2526
26−compile packageName isRoot interfaces source =
27+compile importedPackages packageName isRoot interfaces source =
2728 do
2829 -- determine if default imports should be added
2930 -- only elm-lang/core is exempt
3031 let needsDefaults =
3132 not (packageName == Package.coreName)
3233
34+ let normalInterfaces =
35+ unCanonicalizeInterfaces importedPackages interfaces
36+
3337 -- Parse the source code
3438 validModule <-
3539 Result.mapError Error.Syntax $
@@ -37,7 +41,7 @@ compile packageName isRoot interfaces source =
3741
3842 -- Canonicalize all variables, pinning down where they came from.
3943 canonicalModule <-
40− Canonicalize.module' interfaces validModule
44+ Canonicalize.module' normalInterfaces validModule
4145
4246 -- Run type inference on the program.
4347 types <-
@@ -48,7 +52,7 @@ compile packageName isRoot interfaces source =
4852 Result.mapError Error.Type $
4953 Nitpick.topLevelTypes types (Module.body validModule)
5054
51− Nitpick.patternMatches interfaces canonicalModule
55+ Nitpick.patternMatches normalInterfaces canonicalModule
5256
5357 -- Add the real list of types
5458 let body = (Module.body canonicalModule) { Module.types = types }
@@ -56,9 +60,26 @@ compile packageName isRoot interfaces source =
5660 return $ canonicalModule { Module.body = body }
5761
5862
59−getOpTable :: Module.Interfaces -> Parse.OpTable
63+getOpTable :: Module.CanonicalInterfaces -> Parse.OpTable
6064getOpTable interfaces =
6165 Map.elems interfaces
6266 |> concatMap Module.iFixities
6367 |> map (\(assoc,lvl,op) -> (op,(lvl,assoc)))
6468 |> Map.fromList
69+
70+
71+unCanonicalizeInterfaces
72+ :: Map.Map Module.Name Package.Name
73+ -> Module.CanonicalInterfaces
74+ -> Module.Interfaces
75+unCanonicalizeInterfaces packageInfo ifaces =
76+ let
77+ foldFun canonName iface mapSoFar =
78+ case Map.lookup (Module.canonModul canonName) packageInfo of
79+ Just pkg | pkg == (error "TODO iface pkg") ->
80+ Map.insert (Module.canonModul canonName) iface mapSoFar
81+
82+ _ ->
83+ mapSoFar
84+ in
85+ Map.foldrWithKey foldFun Map.empty ifaces