@@ -14,7 +14,6 @@ import qualified AST.Source as Src
14import qualified AST.Module.Name as ModuleName
14import qualified AST.Module.Name as ModuleName
15import qualified Canonicalize.Environment as Env
15import qualified Canonicalize.Environment as Env
16import qualified Data.List as List
16import qualified Data.List as List
17−import qualified Data.OneOrMore as OneOrMore
18import qualified Elm.Interface as I
17import qualified Elm.Interface as I
19import qualified Elm.Name as N
18import qualified Elm.Name as N
20import qualified Reporting.Annotation as A
19import qualified Reporting.Annotation as A
@@ -58,11 +57,11 @@ isNotKernel (Src.Import (A.At _ name) _ _) =
59data State =
58data State =
61− { _vars :: Env.Exposed Env.ForeignVar
60+ { _vars :: Env.Exposed Can.Annotation
62 , _types :: Env.Exposed Env.Type
61 , _types :: Env.Exposed Env.Type
63 , _ctors :: Env.Exposed Env.Ctor
62 , _ctors :: Env.Exposed Env.Ctor
64 , _binops :: Env.Exposed Env.Binop
63 , _binops :: Env.Exposed Env.Binop
65− , _q_vars :: Env.Qualified Env.ForeignVar
64+ , _q_vars :: Env.Qualified Can.Annotation
66 , _q_types :: Env.Qualified Env.Type
65 , _q_types :: Env.Qualified Env.Type
67 , _q_ctors :: Env.Qualified Env.Ctor
66 , _q_ctors :: Env.Qualified Env.Ctor
@@ -75,7 +74,7 @@ emptyState =
76emptyTypes :: Env.Exposed Env.Type
75emptyTypes :: Env.Exposed Env.Type
77emptyTypes =
76emptyTypes =
78− Map.singleton "List" (OneOrMore.one (Env.Union 1 ModuleName.list))
77+ Map.singleton "List" (Map.singleton ModuleName.list (Env.Union 1 ModuleName.list))
@@ -90,8 +89,8 @@ addImport (State vs ts cs bs qvs qts qcs) (Import home (I.Interface defs unions
90 (Map.mapWithKey (unionToType home) unions)
89 (Map.mapWithKey (unionToType home) unions)
91 (Map.mapWithKey (aliasToType home) aliases)
90 (Map.mapWithKey (aliasToType home) aliases)
93− !vars = Map.map (OneOrMore.one . Env.ForeignVar home) defs
92+ !vars = Map.map (Map.singleton home) defs
94− !types = Map.map (OneOrMore.one . fst) rawTypeInfo
93+ !types = Map.map (Map.singleton home . fst) rawTypeInfo
95 !ctors = Map.foldr (addExposed . snd) Map.empty rawTypeInfo
94 !ctors = Map.foldr (addExposed . snd) Map.empty rawTypeInfo
97 !qvs2 = addQualified prefix vars qvs
96 !qvs2 = addQualified prefix vars qvs
@@ -117,7 +116,7 @@ addImport (State vs ts cs bs qvs qts qcs) (Import home (I.Interface defs unions
118addExposed :: Env.Exposed a -> Env.Exposed a -> Env.Exposed a
117addExposed :: Env.Exposed a -> Env.Exposed a -> Env.Exposed a
119addExposed =
118addExposed =
120− Map.unionWith OneOrMore.more
119+ Map.unionWith Map.union
123addQualified :: N.Name -> Env.Exposed a -> Env.Qualified a -> Env.Qualified a
122addQualified :: N.Name -> Env.Exposed a -> Env.Qualified a -> Env.Qualified a
@@ -133,7 +132,7 @@ unionToType :: ModuleName.Canonical -> N.Name -> Can.Union -> (Env.Type, Env.Exp
133unionToType home name union@(Can.Union vars ctors _ _) =
132unionToType home name union@(Can.Union vars ctors _ _) =
135 addCtor dict (Can.Ctor ctor index _ args) =
134 addCtor dict (Can.Ctor ctor index _ args) =
136− Map.insert ctor (OneOrMore.one (Env.Ctor home name union index args)) dict
135+ Map.insert ctor (Map.singleton home (Env.Ctor home name union index args)) dict
138 ( Env.Union (length vars) home
137 ( Env.Union (length vars) home
139 , List.foldl' addCtor Map.empty ctors
138 , List.foldl' addCtor Map.empty ctors
@@ -150,13 +149,13 @@ aliasToType home name (Can.Alias vars tipe maybeRecordArgs) =
150 Map.empty
149 Map.empty
152 Just _ ->
151 Just _ ->
153− Map.singleton name (OneOrMore.one (Env.RecordCtor home vars tipe))
152+ Map.singleton name (Map.singleton home (Env.RecordCtor home vars tipe))
157−binopToBinop :: ModuleName.Canonical -> N.Name -> I.Binop -> OneOrMore.OneOrMore Env.Binop
156+binopToBinop :: ModuleName.Canonical -> N.Name -> I.Binop -> Map.Map ModuleName.Canonical Env.Binop
158binopToBinop home op (I.Binop name annotation associativity precedence) =
157binopToBinop home op (I.Binop name annotation associativity precedence) =
159− OneOrMore.one (Env.Binop op home name annotation associativity precedence)
158+ Map.singleton home (Env.Binop op home name annotation associativity precedence)
@@ -165,7 +164,7 @@ binopToBinop home op (I.Binop name annotation associativity precedence) =
166addExposedValue
165addExposedValue
167 :: ModuleName.Canonical
166 :: ModuleName.Canonical
168− -> Env.Exposed Env.ForeignVar
167+ -> Env.Exposed Can.Annotation
169 -> Map.Map N.Name (Env.Type, Env.Exposed Env.Ctor)
168 -> Map.Map N.Name (Env.Type, Env.Exposed Env.Ctor)
170 -> Map.Map N.Name I.Binop
169 -> Map.Map N.Name I.Binop
@@ -189,13 +188,13 @@ addExposedValue home vars types binops (State vs ts cs bs qvs qts qcs) (A.At reg
189 case tipe of
188 case tipe of
190 Env.Union _ _ ->
189 Env.Union _ _ ->
192− !ts2 = Map.insert name (OneOrMore.one tipe) ts
191+ !ts2 = Map.insert name (Map.singleton home tipe) ts
194 Result.ok (State vs ts2 cs bs qvs qts qcs)
193 Result.ok (State vs ts2 cs bs qvs qts qcs)
196 Env.Alias _ _ _ _ ->
195 Env.Alias _ _ _ _ ->
198− !ts2 = Map.insert name (OneOrMore.one tipe) ts
197+ !ts2 = Map.insert name (Map.singleton home tipe) ts
199 !cs2 = addExposed cs ctors
198 !cs2 = addExposed cs ctors
201 Result.ok (State vs ts2 cs2 bs qvs qts qcs)
200 Result.ok (State vs ts2 cs2 bs qvs qts qcs)
@@ -209,7 +208,7 @@ addExposedValue home vars types binops (State vs ts cs bs qvs qts qcs) (A.At reg
209 case tipe of
208 case tipe of
210 Env.Union _ _ ->
209 Env.Union _ _ ->
212− !ts2 = Map.insert name (OneOrMore.one tipe) ts
211+ !ts2 = Map.insert name (Map.singleton home tipe) ts
213 !cs2 = addExposed cs ctors
212 !cs2 = addExposed cs ctors
215 Result.ok (State vs ts2 cs2 bs qvs qts qcs)
214 Result.ok (State vs ts2 cs2 bs qvs qts qcs)