@@ -17,6 +17,7 @@ import qualified AST.Canonical as Can
1717import qualified AST.Module.Name as ModuleName
1818import qualified AST.Utils.Binop as Binop
1919import qualified Elm.Name as N
20+import qualified Reporting.Annotation as A
2021
2122
2223
@@ -54,15 +55,38 @@ data Binop =
5455
5556
5657fromModule :: Map.Map N.Name Can.Annotation -> Can.Module -> Interface
57−fromModule types (Can.Module _ _ _ _ unions aliases binops _) =
58+fromModule types (Can.Module _ _ exports _ unions aliases binops _) =
5859 Interface
59− { _types = types
60− , _unions = unions
61− , _aliases = aliases
62− , _binops = Map.map (toOp types) binops
60+ { _types = privatize exports const types
61+ , _unions = privatize exports toUnion unions
62+ , _aliases = privatize exports const aliases
63+ , _binops = privatize exports const (Map.map (toOp types) binops)
6364 }
6465
6566
67+privatize :: Can.Exports -> (a -> A.Located Can.Export -> a) -> Map.Map N.Name a -> Map.Map N.Name a
68+privatize exports func dict =
69+ case exports of
70+ Can.ExportEverything ->
71+ dict
72+
73+ Can.Export explicitExports ->
74+ Map.intersectionWith func dict explicitExports
75+
76+
77+toUnion :: Can.Union -> A.Located Can.Export -> Can.Union
78+toUnion union@(Can.Union vars _ _ opts) (A.At _ export) =
79+ case export of
80+ Can.ExportUnionOpen ->
81+ union
82+
83+ Can.ExportUnionClosed ->
84+ Can.Union vars [] 0 opts
85+
86+ _ ->
87+ error "Compiler bug. Should not run into non-union exports here."
88+
89+
6690toOp :: Map.Map N.Name Can.Annotation -> Can.Binop -> Binop
6791toOp types (Can.Binop_ associativity precedence name) =
6892 Binop name (types ! name) associativity precedence