@@ -7,6 +7,8 @@ import qualified Data.Map as Map
7import qualified Data.Maybe as Maybe
7import qualified Data.Maybe as Maybe
8import qualified Data.Set as Set
8import qualified Data.Set as Set
9import qualified Data.Foldable as T
9import qualified Data.Foldable as T
10+import qualified Data.Text as Text
11+import Data.Text (Text)
11import Elm.Utils ((|>))
13import Elm.Utils ((|>))
@@ -78,7 +80,7 @@ module' allCanonicalImports interfaces modul =
78 canonicalDecls
80 canonicalDecls
80 centralizedDocs =
82 centralizedDocs =
81− A.map (fmap (Docs.centralize canonicalDecls)) docs
83+ fmap (A.map (Docs.centralize canonicalDecls)) docs
83 typeToPair (A.A _ (D.Type name args body)) =
85 typeToPair (A.A _ (D.Type name args body)) =
84 ( name, (args, body) )
86 ( name, (args, body) )
@@ -88,7 +90,7 @@ module' allCanonicalImports interfaces modul =
89 do program <- Result.mapError Error.Canonicalize getProgram
91 do program <- Result.mapError Error.Canonicalize getProgram
90 canonicalImports <- filterImports uses imports
92 canonicalImports <- filterImports uses imports
91− Result.accumulate (Result.One (Env.toDealiaser env)) $
93+ Result.accumulate (Result.One (Env.toLocalizer env)) $
93 Module.info =
95 Module.info =
94 Module.Info
96 Module.Info
@@ -164,7 +166,7 @@ resolveExports fullList (Var.Listing partialList open) =
164 <*> allUnique partialList
166 <*> allUnique partialList
167−getValueExport :: [String] -> Set.Set String -> A.Located String -> CResult Var.Value
169+getValueExport :: [Text] -> Set.Set Text -> A.Located Text -> CResult Var.Value
168getValueExport allValues allValuesSet (A.A region name) =
170getValueExport allValues allValuesSet (A.A region name) =
169 if Set.member name allValuesSet then
171 if Set.member name allValuesSet then
170 Result.ok (Var.Value name)
172 Result.ok (Var.Value name)
@@ -172,7 +174,7 @@ getValueExport allValues allValuesSet (A.A region name) =
172 manyNotFound region [name] allValues
174 manyNotFound region [name] allValues
175−getAliasExport :: [String] -> [String] -> [String] -> A.Located String -> CResult [Var.Value]
177+getAliasExport :: [Text] -> [Text] -> [Text] -> A.Located Text -> CResult [Var.Value]
176getAliasExport allValues allAliases adtTypes (A.A region alias) =
178getAliasExport allValues allAliases adtTypes (A.A region alias) =
177 if alias `elem` allAliases then
179 if alias `elem` allAliases then
@@ -189,9 +191,9 @@ getAliasExport allValues allAliases adtTypes (A.A region alias) =
191getAdtExport
193getAdtExport
192− :: [(String, Var.Listing String)]
194+ :: [(Text, Var.Listing Text)]
193− -> [String]
195+ -> [Text]
194− -> A.Located (String, Var.Listing String)
196+ -> A.Located (Text, Var.Listing Text)
195 -> CResult Var.Value
197 -> CResult Var.Value
196getAdtExport allAdts adtTypes (A.A region (name, Var.Listing ctors open)) =
198getAdtExport allAdts adtTypes (A.A region (name, Var.Listing ctors open)) =
197 case List.lookup name allAdts of
199 case List.lookup name allAdts of
@@ -209,21 +211,25 @@ getAdtExport allAdts adtTypes (A.A region (name, Var.Listing ctors open)) =
209 manyNotFound region unfoundCtors allCtors
211 manyNotFound region unfoundCtors allCtors
212−manyNotFound :: Region.Region -> [String] -> [String] -> CResult a
214+manyNotFound :: Region.Region -> [Text] -> [Text] -> CResult a
213manyNotFound region nameList possibilities =
215manyNotFound region nameList possibilities =
214 Result.throwMany (map (notFound region possibilities) nameList)
216 Result.throwMany (map (notFound region possibilities) nameList)
217−notFound :: Region.Region -> [String] -> String -> A.Located CError.Error
219+notFound :: Region.Region -> [Text] -> Text -> A.Located CError.Error
218−notFound region possibilities name =
220+notFound region possibilities badName =
219− A.A region $ CError.Export name $
225+ A.A region $ CError.Export badNameString $
220− ErrorHelp.nearbyNames id name possibilities
226+ ErrorHelp.nearbyNames id badNameString (map Text.unpack possibilities)
223allUnique :: [A.Located Var.Value] -> CResult ()
229allUnique :: [A.Located Var.Value] -> CResult ()
224allUnique statedExports =
230allUnique statedExports =
226− valueToString value =
232+ valueToText value =
227 case value of
233 case value of
228 Var.Value name -> name
234 Var.Value name -> name
229 Var.Alias name -> name
235 Var.Alias name -> name
@@ -235,7 +241,7 @@ allUnique statedExports =
235 isUnique value allRegions =
241 isUnique value allRegions =
236 case allRegions of
242 case allRegions of
237 region : _ : _ ->
243 region : _ : _ ->
238− Result.throw region (CError.DuplicateExport (valueToString value))
244+ Result.throw region (CError.DuplicateExport (valueToText value))
241 Result.ok ()
247 Result.ok ()
@@ -284,7 +290,7 @@ maybeUnzip3 tuples =
285splitValue
291splitValue
286 :: Var.Value
292 :: Var.Value
287− -> ( Maybe String, Maybe String, Maybe (String, Var.Listing String) )
293+ -> ( Maybe Text, Maybe Text, Maybe (Text, Var.Listing Text) )
288splitValue value =
294splitValue value =
289 case value of
295 case value of
290 Var.Value name ->
296 Var.Value name ->
@@ -300,9 +306,9 @@ splitValue value =
300splitLocatedValue
306splitLocatedValue
301 :: A.Located Var.Value
307 :: A.Located Var.Value
303− ( Maybe (A.Located String)
309+ ( Maybe (A.Located Text)
304− , Maybe (A.Located String)
310+ , Maybe (A.Located Text)
305− , Maybe (A.Located (String, Var.Listing String))
311+ , Maybe (A.Located (Text, Var.Listing Text))
307splitLocatedValue (A.A region value) =
313splitLocatedValue (A.A region value) =
308 case value of
314 case value of
@@ -414,7 +420,9 @@ canonicalizeExpr env (A.A region validExpr) =
414 C.Var <$> Canon.variable region env x
420 C.Var <$> Canon.variable region env x
416 Src.Ctor name exprs ->
422 Src.Ctor name exprs ->
424+ <$> Canon.variable region env name
417− C.Ctor name <$> traverse go exprs
425+ <*> traverse go exprs
419 Src.List exprs ->
427 Src.List exprs ->
420 C.List <$> traverse go exprs
428 C.List <$> traverse go exprs
@@ -433,8 +441,8 @@ canonicalizeExpr env (A.A region validExpr) =
434canonicalizeFields
442canonicalizeFields
435 :: Env.Env
443 :: Env.Env
436− -> (A.Located String, Src.ValidExpr)
444+ -> (A.Located Text, Src.ValidExpr)
437− -> CResult (String, C.Expr)
445+ -> CResult (Text, C.Expr)
438canonicalizeFields env (A.A _ key, expr) =
446canonicalizeFields env (A.A _ key, expr) =
439 (\value -> (key, value)) <$> canonicalizeExpr env expr
447 (\value -> (key, value)) <$> canonicalizeExpr env expr
@@ -462,8 +470,8 @@ canonicalizePattern env (A.A region ptrn) =
462 P.Alias x p ->
470 P.Alias x p ->
463 P.Alias x <$> canonicalizePattern env p
471 P.Alias x <$> canonicalizePattern env p
465− P.Data (Var.Raw name) patterns ->
473+ P.Ctor (Var.Raw name) patterns ->
467 <$> Canon.pvar region env name (length patterns)
475 <$> Canon.pvar region env name (length patterns)
468 <*> traverse (canonicalizePattern env) patterns
476 <*> traverse (canonicalizePattern env) patterns
@@ -475,7 +483,7 @@ canonicalizePattern env (A.A region ptrn) =
475canonicalizeBinop
483canonicalizeBinop
476 :: Region.Region
484 :: Region.Region
477 -> Env.Env
485 -> Env.Env
478− -> [(Src.ValidExpr, A.Located String)]
486+ -> [(Src.ValidExpr, A.Located Text)]
479 -> Src.ValidExpr
487 -> Src.ValidExpr
480 -> CResult C.Expr'
488 -> CResult C.Expr'
481canonicalizeBinop region env srcOps srcLast =
489canonicalizeBinop region env srcOps srcLast =
@@ -490,7 +498,7 @@ canonicalizeBinop region env srcOps srcLast =
490 A.drop <$> Binops.flatten region expr ops
498 A.drop <$> Binops.flatten region expr ops
493−binopHelp :: Env.Env -> (Src.ValidExpr, A.Located String) -> CResult (C.Expr, Binops.Op)
501+binopHelp :: Env.Env -> (Src.ValidExpr, A.Located Text) -> CResult (C.Expr, Binops.Op)
494binopHelp env (expr, op) =
502binopHelp env (expr, op) =
496 <$> canonicalizeExpr env expr
504 <$> canonicalizeExpr env expr