on master help sign in
Switch to Elm.Version and away from Data.Text in some builder/* files
commit83cd588b00b839d4052427c9ebec23b9c9b6592d authorEvan Czaplicki <evancz@users.noreply.github.com> dateFri 28 Dec 2018, 17:10 (8 years ago) parent032555a
16 files changed+196−198
builder/src/Elm/Bump.hs+17−18 builder/src/Elm/Install.hs+43−43 builder/src/Reporting/Exit/Bump.hs+4−4 builder/src/Reporting/Exit/Crawl.hs+31−32 builder/src/Reporting/Exit/Deps.hs+16−16 builder/src/Reporting/Exit/Diff.hs+7−6 builder/src/Reporting/Exit/Help.hs+13−12 builder/src/Reporting/Exit/Init.hs+3−4 builder/src/Reporting/Exit/Install.hs+4−4 builder/src/Reporting/Exit/Make.hs+1−1 builder/src/Reporting/Exit/Publish.hs+22−22 builder/src/Reporting/Progress.hs+9−8 builder/src/Reporting/Progress/Terminal.hs+19−19 builder/src/Reporting/Task.hs+3−3 builder/src/Reporting/Task/Http.hs+2−3 builder/src/Stuff/Paths.hs+2−3
builder/src/Elm/Bump.hs+17−18
@@ -11,10 +11,9 @@ import qualified Data.List as List
1111
1212import qualified Deps.Cache as Cache
1313import qualified Deps.Diff as Diff
14−import qualified Elm.Package as Pkg
15−import qualified Elm.Project as Project
1614import qualified Elm.Project.Json as Project
1715import qualified Elm.Project.Summary as Summary
16+import qualified Elm.Version as V
1817import Reporting.Doc ((<>), (<+>))
1918import qualified Reporting.Doc as D
2019import qualified Reporting.Exit as Exit
@@ -56,7 +55,7 @@ bump summary@(Summary.Summary root project _ _ _) =
5655-- VALID BUMPS
5756
5857
59−toPossibleBumps :: [Pkg.Version] -> [(Pkg.Version, Pkg.Version, Diff.Magnitude)]
58+toPossibleBumps :: [V.Version] -> [(V.Version, V.Version, Diff.Magnitude)]
6059toPossibleBumps publishedVersions =
6160 case publishedVersions of
6261 [] ->
@@ -65,17 +64,17 @@ toPossibleBumps publishedVersions =
6564 _ ->
6665 let
6766 patchPoints =
68− Pkg.filterLatest Pkg.majorAndMinor publishedVersions
67+ V.filterLatest V.majorAndMinor publishedVersions
6968
7069 minorPoints =
71− Pkg.filterLatest Pkg._major publishedVersions
70+ V.filterLatest V._major publishedVersions
7271
7372 majorPoint =
7473 maximum publishedVersions
7574 in
76− (majorPoint, Pkg.bumpMajor majorPoint, Diff.MAJOR)
77− : map (\v -> (v, Pkg.bumpMinor v, Diff.MINOR)) minorPoints
78− ++ map (\v -> (v, Pkg.bumpPatch v, Diff.PATCH)) patchPoints
75+ (majorPoint, V.bumpMajor majorPoint, Diff.MAJOR)
76+ : map (\v -> (v, V.bumpMinor v, Diff.MINOR)) minorPoints
77+ ++ map (\v -> (v, V.bumpPatch v, Diff.PATCH)) patchPoints
7978
8079
8180
@@ -85,14 +84,14 @@ toPossibleBumps publishedVersions =
8584checkNewPackage :: FilePath -> Project.PkgInfo -> Task.Task ()
8685checkNewPackage root info@(Project.PkgInfo _ _ _ version _ _ _ _) =
8786 do liftIO $ putStrLn Terminal.newPackageOverview
88− if version == Pkg.initialVersion
87+ if version == V.one
8988 then
9089 liftIO $ putStrLn "The version number in elm.json is correct so you are all set!"
9190 else
92− changeVersion root info Pkg.initialVersion $
91+ changeVersion root info V.one $
9392 "It looks like the version in elm.json has been changed though!\n\
9493 \Would you like me to change it back to "
95− <> D.fromText (Pkg.versionToText Pkg.initialVersion) <> "? [Y/n] "
94+ <> D.fromUtf8 (V.toString V.one) <> "? [Y/n] "
9695
9796
9897
@@ -100,16 +99,16 @@ checkNewPackage root info@(Project.PkgInfo _ _ _ version _ _ _ _) =
10099
101100
102101suggestVersion :: Summary.Summary -> Project.PkgInfo -> Task.Task ()
103−suggestVersion summary@(Summary.Summary root _ _ _ _) info@(Project.PkgInfo name _ _ version _ _ _ _) =
102+suggestVersion (Summary.Summary root _ _ _ _) info@(Project.PkgInfo name _ _ version _ _ _ _) =
104103 do oldDocs <- Cache.getDocs name version
105− newDocs <- Task.silently (Project.generateDocs summary)
104+ newDocs <- Task.silently (error "TODO Project.generateDocs summary")
106105 let changes = Diff.diff oldDocs newDocs
107106 let newVersion = Diff.bump changes version
108107 changeVersion root info newVersion $
109108 let
110− old = D.fromText $ Pkg.versionToText version
111− new = D.fromText $ Pkg.versionToText newVersion
112− mag = D.fromString $ Diff.magnitudeToString (Diff.toMagnitude changes)
109+ old = D.fromUtf8 $ V.toString version
110+ new = D.fromUtf8 $ V.toString newVersion
111+ mag = D.fromChars $ Diff.magnitudeToString (Diff.toMagnitude changes)
113112 in
114113 "Based on your new API, this should be a" <+> D.green mag <+> "change (" <> old <> " => " <> new <> ")\n"
115114 <> "Bail out of this command and run 'elm diff' for a full explanation.\n"
@@ -121,7 +120,7 @@ suggestVersion summary@(Summary.Summary root _ _ _ _) info@(Project.PkgInfo name
121120-- CHANGE VERSION
122121
123122
124−changeVersion :: FilePath -> Project.PkgInfo -> Pkg.Version -> D.Doc -> Task.Task ()
123+changeVersion :: FilePath -> Project.PkgInfo -> V.Version -> D.Doc -> Task.Task ()
125124changeVersion root info targetVersion explanation =
126125 do approved <- Task.getApproval explanation
127126 if not approved
@@ -134,5 +133,5 @@ changeVersion root info targetVersion explanation =
134133
135134 liftIO $ Help.toStdout $
136135 "Version changed to "
137− <> D.green (D.fromText (Pkg.versionToText targetVersion))
136+ <> D.green (D.fromUtf8 (V.toString targetVersion))
138137 <> "!\n"
builder/src/Elm/Install.hs+43−43
@@ -18,10 +18,10 @@ import Deps.Explorer (Explorer)
1818import qualified Deps.Explorer as Explorer
1919import qualified Deps.Verify as Verify
2020import qualified Deps.Solver as Solver
21−import Elm.Project.Constraint (Constraint)
22−import qualified Elm.Project.Constraint as Con
21+import qualified Elm.Constraint as C
2322import qualified Elm.Project.Json as Project
2423import qualified Elm.Project.Root as Root
24+import qualified Elm.Version as V
2525import Reporting.Doc ((<>), (<+>))
2626import qualified Reporting.Doc as D
2727import qualified Reporting.Exit as Exit
@@ -41,15 +41,15 @@ install pkg =
4141 case oldProject of
4242 Project.App info ->
4343 do changes <- makeAppPlan registry pkg info
44− attemptElmJsonChange root oldProject Pkg.versionToString changes
44+ attemptElmJsonChange root oldProject V.toChars changes
4545
4646 Project.Pkg info ->
4747 do changes <- makePkgPlan registry pkg info
48− attemptElmJsonChange root oldProject Con.toString changes
48+ attemptElmJsonChange root oldProject C.toChars changes
4949
5050
5151attemptElmJsonChange :: FilePath -> Project.Project -> (a -> String) -> Changes a -> Task.Task ()
52−attemptElmJsonChange root oldProject toString changes =
52+attemptElmJsonChange root oldProject toChars changes =
5353 let
5454 attempt newProject question =
5555 do approved <- Task.getApproval question
@@ -97,8 +97,8 @@ attemptElmJsonChange root oldProject toString changes =
9797
9898 Changes changeDict newProject ->
9999 let
100− widths = Map.foldrWithKey (widen toString) (Widths 0 0 0) changeDict
101− changeDocs = Map.foldrWithKey (addChange toString widths) (Docs [] [] []) changeDict
100+ widths = Map.foldrWithKey (widen toChars) (Widths 0 0 0) changeDict
101+ changeDocs = Map.foldrWithKey (addChange toChars widths) (Docs [] [] []) changeDict
102102 in
103103 attempt newProject $ D.vcat $
104104 [ "Here is my plan:"
@@ -119,7 +119,7 @@ data Changes vsn
119119 | Changes (Map.Map Pkg.Name (Change vsn)) Project.Project
120120
121121
122−makeAppPlan :: Cache.PackageRegistry -> Pkg.Name -> Project.AppInfo -> Task.Task (Changes Pkg.Version)
122+makeAppPlan :: Cache.PackageRegistry -> Pkg.Name -> Project.AppInfo -> Task.Task (Changes V.Version)
123123makeAppPlan registry pkg info@(Project.AppInfo _ _ depsDirect depsTrans testDirect testTrans) =
124124 if Map.member pkg depsDirect then
125125 return AlreadyInstalled
@@ -137,7 +137,7 @@ makeAppPlan registry pkg info@(Project.AppInfo _ _ depsDirect depsTrans testDire
137137 Changes (detectChanges old new) (Project.App newInfo)
138138
139139
140−makePkgPlan :: Cache.PackageRegistry -> Pkg.Name -> Project.PkgInfo -> Task.Task (Changes Constraint)
140+makePkgPlan :: Cache.PackageRegistry -> Pkg.Name -> Project.PkgInfo -> Task.Task (Changes C.Constraint)
141141makePkgPlan registry pkg info@(Project.PkgInfo _ _ _ _ _ deps test _) =
142142 if Map.member pkg deps then
143143 return AlreadyInstalled
@@ -217,8 +217,8 @@ keepNew change =
217217
218218data AppAnswer =
219219 AppAnswer
220− { _old :: Map.Map Pkg.Name Pkg.Version
221− , _new :: Map.Map Pkg.Name Pkg.Version
220+ { _old :: Map.Map Pkg.Name V.Version
221+ , _new :: Map.Map Pkg.Name V.Version
222222 , _info :: Project.AppInfo
223223 }
224224
@@ -252,8 +252,8 @@ toAppAnswerHelp pkg (Project.AppInfo elm srcDirs depsDirect depsTrans testDirect
252252 Map.union directs (Map.union depsTrans testTrans)
253253
254254 try toConstraint deps =
255− do solution <- Solver.solve $ Map.insert pkg Con.anything (Map.map toConstraint deps)
256− let newDepsDirect = Map.intersection solution (Map.insert pkg Pkg.dummyVersion depsDirect)
255+ do solution <- Solver.solve $ Map.insert pkg C.anything (Map.map toConstraint deps)
256+ let newDepsDirect = Map.intersection solution (Map.insert pkg V.one depsDirect)
257257 newDeps <- lift $ foldM (collectTransitive solution) Map.empty (Map.keys newDepsDirect)
258258 return $
259259 AppAnswer
@@ -270,19 +270,19 @@ toAppAnswerHelp pkg (Project.AppInfo elm srcDirs depsDirect depsTrans testDirect
270270 }
271271 in
272272 msum
273− [ try Con.exactly directAndTrans
274− , try Con.exactly directs
275− , try Con.untilNextMinor directs
276− , try Con.untilNextMajor directs
277− , try (\_ -> Con.anything) directs
273+ [ try C.exactly directAndTrans
274+ , try C.exactly directs
275+ , try C.untilNextMinor directs
276+ , try C.untilNextMajor directs
277+ , try (\_ -> C.anything) directs
278278 ]
279279
280280
281281collectTransitive
282− :: Map.Map Pkg.Name Pkg.Version
283− -> Map.Map Pkg.Name Pkg.Version
282+ :: Map.Map Pkg.Name V.Version
283+ -> Map.Map Pkg.Name V.Version
284284 -> Pkg.Name
285− -> Explorer (Map.Map Pkg.Name Pkg.Version)
285+ -> Explorer (Map.Map Pkg.Name V.Version)
286286collectTransitive solution state name =
287287 do let version = solution ! name
288288 (Explorer.Info _ trans) <- Explorer.getConstraints name version
@@ -298,7 +298,7 @@ collectTransitive solution state name =
298298-- ADD TO PKG
299299
300300
301−addToPkg :: Cache.PackageRegistry -> Pkg.Name -> Project.PkgInfo -> Task.Task (Map.Map Pkg.Name (Change Constraint))
301+addToPkg :: Cache.PackageRegistry -> Pkg.Name -> Project.PkgInfo -> Task.Task (Map.Map Pkg.Name (Change C.Constraint))
302302addToPkg registry pkg info@(Project.PkgInfo _ _ _ _ _ deps tests _) =
303303 Explorer.run registry $
304304 do Explorer.exists pkg
@@ -314,12 +314,12 @@ addToPkg registry pkg info@(Project.PkgInfo _ _ _ _ _ deps tests _) =
314314 lift $ Task.throw (Exit.Install (E.NoSolution badNames))
315315
316316
317−addToPkgHelp :: Pkg.Name -> Project.PkgInfo -> Solver.Solver (Map.Map Pkg.Name Constraint)
317+addToPkgHelp :: Pkg.Name -> Project.PkgInfo -> Solver.Solver (Map.Map Pkg.Name C.Constraint)
318318addToPkgHelp pkg (Project.PkgInfo _ _ _ _ _ deps tests _) =
319319 do let directs = Map.union deps tests
320− let newCons = Map.insert pkg Con.anything directs
320+ let newCons = Map.insert pkg C.anything directs
321321 solution <- Solver.solve newCons
322− let con = Con.untilNextMajor (solution ! pkg)
322+ let con = C.untilNextMajor (solution ! pkg)
323323 return $ Map.insert pkg con directs
324324
325325
@@ -334,7 +334,7 @@ isBadElm name =
334334 elmVersions <- forM versions $ \vsn ->
335335 Explorer._elm <$> Explorer.getConstraints name vsn
336336
337− return (not (any Con.goodElm elmVersions))
337+ return (not (any C.goodElm elmVersions))
338338
339339
340340
@@ -364,7 +364,7 @@ viewNonZero title entries =
364364 []
365365 else
366366 [ ""
367− , D.fromString title
367+ , D.fromChars title
368368 , D.indent 2 (D.vcat entries)
369369 ]
370370
@@ -374,46 +374,46 @@ viewNonZero title entries =
374374
375375
376376addChange :: (a -> String) -> Widths -> Pkg.Name -> Change a -> ChangeDocs -> ChangeDocs
377−addChange toString widths name change (Docs inserts changes removes) =
377+addChange toChars widths name change (Docs inserts changes removes) =
378378 case change of
379379 Insert new ->
380− Docs (viewInsert toString widths name new : inserts) changes removes
380+ Docs (viewInsert toChars widths name new : inserts) changes removes
381381
382382 Change old new ->
383− Docs inserts (viewChange toString widths name old new : changes) removes
383+ Docs inserts (viewChange toChars widths name old new : changes) removes
384384
385385 Remove old ->
386− Docs inserts changes (viewRemove toString widths name old : removes)
386+ Docs inserts changes (viewRemove toChars widths name old : removes)
387387
388388
389389viewInsert :: (a -> String) -> Widths -> Pkg.Name -> a -> D.Doc
390−viewInsert toString (Widths nameWidth leftWidth _) name new =
391− viewName nameWidth name <+> pad leftWidth (toString new)
390+viewInsert toChars (Widths nameWidth leftWidth _) name new =
391+ viewName nameWidth name <+> pad leftWidth (toChars new)
392392
393393
394394viewChange :: (a -> String) -> Widths -> Pkg.Name -> a -> a -> D.Doc
395−viewChange toString (Widths nameWidth leftWidth rightWidth) name old new =
395+viewChange toChars (Widths nameWidth leftWidth rightWidth) name old new =
396396 D.hsep
397397 [ viewName nameWidth name
398− , pad leftWidth (toString old)
398+ , pad leftWidth (toChars old)
399399 , "=>"
400− , pad rightWidth (toString new)
400+ , pad rightWidth (toChars new)
401401 ]
402402
403403
404404viewRemove :: (a -> String) -> Widths -> Pkg.Name -> a -> D.Doc
405−viewRemove toString (Widths nameWidth leftWidth _) name old =
406− viewName nameWidth name <+> pad leftWidth (toString old)
405+viewRemove toChars (Widths nameWidth leftWidth _) name old =
406+ viewName nameWidth name <+> pad leftWidth (toChars old)
407407
408408
409409viewName :: Int -> Pkg.Name -> D.Doc
410410viewName width name =
411− D.fill (width + 3) (D.fromText (Pkg.toText name))
411+ D.fill (width + 3) (D.fromUtf8 (Pkg.toString name))
412412
413413
414414pad :: Int -> String -> D.Doc
415415pad width string =
416− D.fromString (replicate (width - length string) ' ') <> D.fromString string
416+ D.fromChars (replicate (width - length string) ' ') <> D.fromChars string
417417
418418
419419
@@ -429,13 +429,13 @@ data Widths =
429429
430430
431431widen :: (a -> String) -> Pkg.Name -> Change a -> Widths -> Widths
432−widen toString pkg change (Widths name left right) =
432+widen toChars pkg change (Widths name left right) =
433433 let
434434 toLength a =
435− length (toString a)
435+ length (toChars a)
436436
437437 newName =
438− max name (length (Pkg.toString pkg))
438+ max name (length (Pkg.toChars pkg))
439439 in
440440 case change of
441441 Insert new ->
builder/src/Reporting/Exit/Bump.hs+4−4
@@ -6,7 +6,7 @@ module Reporting.Exit.Bump
66 where
77
88
9−import qualified Elm.Package as Pkg
9+import qualified Elm.Version as V
1010import Reporting.Doc ((<>))
1111import qualified Reporting.Doc as D
1212import qualified Reporting.Exit.Help as Help
@@ -18,7 +18,7 @@ import qualified Reporting.Exit.Help as Help
1818
1919data Exit
2020 = Application
21− | Unbumpable Pkg.Version [Pkg.Version]
21+ | Unbumpable V.Version [V.Version]
2222
2323
2424
@@ -38,7 +38,7 @@ toReport exit =
3838 Help.docReport "UNBUMPABLE" (Just "elm.json")
3939 ( D.fillSep
4040 ["Your","elm.json","says","I","should","bump","relative","to","version"
41− ,D.red (D.fromText (Pkg.versionToText vsn)) <> ","
41+ ,D.red (D.fromUtf8 (V.toString vsn)) <> ","
4242 ,"but","I","cannot","find","that","version","on","<https://package.elm-lang.org>."
4343 ,"That","means","there","is","no","API","for","me","to","diff","against","and"
4444 ,"figure","out","if","these","are","MAJOR,","MINOR,","or","PATCH","changes."
@@ -47,5 +47,5 @@ toReport exit =
4747 [ D.fillSep $
4848 ["Try","bumping","again","after","changing","the",D.dullyellow "\"version\"","in","elm.json"]
4949 ++ if length versions == 1 then ["to:"] else ["to","one","of","these:"]
50− , D.vcat $ map (D.green . D.fromText . Pkg.versionToText) versions
50+ , D.vcat $ map (D.green . D.fromUtf8 . V.toString) versions
5151 ]
builder/src/Reporting/Exit/Crawl.hs+31−32
@@ -9,15 +9,14 @@ module Reporting.Exit.Crawl
99 where
1010
1111
12−import qualified Data.ByteString as BS
1312import qualified Data.Char as Char
1413import qualified Data.Map as Map
15−import qualified Data.Text.Encoding as Text
1614import qualified Data.Time.Clock as Time
1715
1816import qualified Elm.Compiler as Compiler
1917import qualified Elm.ModuleName as ModuleName
2018import qualified Elm.Package as Pkg
19+import qualified Elm.Version as V
2120import Reporting.Doc ((<+>), (<>))
2221import qualified Reporting.Doc as D
2322import qualified Reporting.Exit.Compile as Compile
@@ -39,7 +38,7 @@ data Exit
3938data Problem
4039 = ModuleNotFound Origin ModuleName.Raw SrcDirs
4140 | ModuleAmbiguous Origin ModuleName.Raw [FilePath] [Pkg.Canonical]
42− | BadHeader FilePath Time.UTCTime BS.ByteString Compiler.Error
41+ | BadHeader FilePath Time.UTCTime String Compiler.Error
4342 | ModuleNameReservedForKernel Origin ModuleName.Raw
4443 | ModuleNameMissing FilePath ModuleName.Raw
4544 | ModuleNameMismatch
@@ -71,7 +70,7 @@ toReport exit =
7170 RootFileNotFound path ->
7271 Help.report "FILE NOT FOUND" Nothing
7372 "You want me to compile this file:"
74− [ D.indent 4 $ D.dullyellow $ D.fromString path
73+ [ D.indent 4 $ D.dullyellow $ D.fromChars path
7574 , "I cannot find it though! Is there a typo?"
7675 ]
7776
@@ -79,10 +78,10 @@ toReport exit =
7978 Help.report "DUPLICATE NAMES" Nothing
8079 "I am trying to compile multiple modules with the same name:"
8180 [ D.indent 4 $ D.dullyellow $ D.vcat $
82− map D.fromString paths
81+ map D.fromChars paths
8382 , D.fillSep $
8483 [ "These", "modules", if length paths == 2 then "both" else "all", "claim"
85− , "to", "be", "named", D.dullyellow (D.fromString (ModuleName.nameToString name)) <> "."
84+ , "to", "be", "named", D.dullyellow (D.fromChars (ModuleName.nameToChars name)) <> "."
8685 , "Change", "them", "to", "have", "unique", "names", "and", "you"
8786 , "should", "be", "all", "set!"
8887 ]
@@ -103,7 +102,7 @@ toReport exit =
103102 BadKernelHeader filePath ->
104103 Help.report "BAD KERNEL HEADER" Nothing
105104 "I ran into a bad header in this file:"
106− [ D.indent 4 $ D.dullyellow $ D.fromString filePath
105+ [ D.indent 4 $ D.dullyellow $ D.fromChars filePath
107106 , D.reflow $
108107 "NOTE: Kernel code is only available to core Elm libraries to ensure\
109108 \ the portability and security of the Elm ecosystem. This restriction\
@@ -128,7 +127,7 @@ problemToReport problem =
128127 BadHeader path time source compilerError ->
129128 let
130129 compilerExit =
131− Compile.Exit "???" path time (Text.decodeUtf8 source) [compilerError]
130+ Compile.Exit "???" path time source [compilerError]
132131 in
133132 Help.compilerReport compilerExit []
134133
@@ -139,9 +138,9 @@ problemToReport problem =
139138 Help.report "MODULE NAME MISMATCH" (Just path)
140139 ( "The file at " ++ path ++ " has a typo in the module name. It says:"
141140 )
142− [ D.indent 4 $ D.dullyellow $ "module" <+> D.red (D.fromString (ModuleName.nameToString actual)) <+> "exposing (..)"
141+ [ D.indent 4 $ D.dullyellow $ "module" <+> D.red (D.fromChars (ModuleName.nameToChars actual)) <+> "exposing (..)"
143142 , "Looks like a typo or copy/paste error. Instead it needs to say:"
144− , D.indent 4 $ D.dullyellow $ "module" <+> D.green (D.fromString (ModuleName.nameToString expected)) <+> "exposing (..)"
143+ , D.indent 4 $ D.dullyellow $ "module" <+> D.green (D.fromChars (ModuleName.nameToChars expected)) <+> "exposing (..)"
145144 , "Make the change and you should be all set!"
146145 ]
147146
@@ -167,9 +166,9 @@ badTagToDoc path name tag hintName summary =
167166 summary
168167 [ D.fillSep $
169168 [ "Get", "rid", "of", "all", "the"
170− , D.red (D.fromString tag)
169+ , D.red (D.fromChars tag)
171170 , "stuff", "in"
172− , D.dullyellow (D.fromString (ModuleName.nameToString name))
171+ , D.dullyellow (D.fromChars (ModuleName.nameToChars name))
173172 , "to", "proceed."
174173 ]
175174 , D.toSimpleNote $
@@ -185,11 +184,11 @@ badTagToDoc path name tag hintName summary =
185184namelessToDoc :: FilePath -> ModuleName.Raw -> Help.Report
186185namelessToDoc path name =
187186 Help.report "UNNAMED MODULE" (Just path)
188− ( "The `" ++ ModuleName.nameToString name
187+ ( "The `" ++ ModuleName.nameToChars name
189188 ++ "` module must start with a line like this:"
190189 )
191− [ D.indent 4 $ D.dullyellow $ D.fromString $
192− "module " ++ ModuleName.nameToString name ++ " exposing (..)"
190+ [ D.indent 4 $ D.dullyellow $ D.fromChars $
191+ "module " ++ ModuleName.nameToChars name ++ " exposing (..)"
193192 , D.reflow $
194193 "Try adding that as the first line of your file!"
195194 , D.toSimpleNote $
@@ -210,19 +209,19 @@ notFoundToDoc origin child srcDirs =
210209 ElmJson ->
211210 Help.report "MODULE NOT FOUND" (Just "elm.json")
212211 "Your elm.json says your project has the following module:"
213− [ D.indent 4 $ D.red $ D.fromString $ ModuleName.nameToString child
212+ [ D.indent 4 $ D.red $ D.fromChars $ ModuleName.nameToChars child
214213 , D.reflow $
215214 "When creating packages, all modules must live in the src/ directory."
216215 ]
217216
218217 File path ->
219218 Help.report "UNKNOWN IMPORT" (Just path)
220− ("I cannot find a `" ++ ModuleName.nameToString child ++ "` module to import.")
219+ ("I cannot find a `" ++ ModuleName.nameToChars child ++ "` module to import.")
221220 (notFoundDetails child srcDirs)
222221
223222 Module path parent ->
224223 Help.report "UNKNOWN IMPORT" (Just path)
225− ("The " ++ ModuleName.nameToString parent ++ " module has a bad import:")
224+ ("The " ++ ModuleName.nameToChars parent ++ " module has a bad import:")
226225 (notFoundDetails child srcDirs)
227226
228227
@@ -230,26 +229,26 @@ notFoundDetails :: ModuleName.Raw -> SrcDirs -> [D.Doc]
230229notFoundDetails child srcDirs =
231230 let
232231 simulatedCode =
233− D.indent 4 $ D.red $ D.fromString $ "import " ++ ModuleName.nameToString child
232+ D.indent 4 $ D.red $ D.fromChars $ "import " ++ ModuleName.nameToChars child
234233 in
235234 case Map.lookup child Pkg.suggestions of
236235 Just pkg ->
237236 [ simulatedCode
238237 , D.reflow $
239− "Do you want the one from the " ++ Pkg.toString pkg
238+ "Do you want the one from the " ++ Pkg.toChars pkg
240239 ++ " package? If so, run this command to add that dependency to your elm.json file:"
241− , D.indent 4 $ D.green $ D.fromString $ "elm install " ++ Pkg.toString pkg
240+ , D.indent 4 $ D.green $ D.fromChars $ "elm install " ++ Pkg.toChars pkg
242241 , case srcDirs of
243242 Pkg ->
244243 D.reflow $
245244 "If you want a local file, make sure the `"
246− ++ ModuleName.nameToString child
245+ ++ ModuleName.nameToChars child
247246 ++ "` module is in your src/ directory."
248247
249248 App _ ->
250249 D.reflow $
251250 "If you want a local file, make sure the `"
252− ++ ModuleName.nameToString child
251+ ++ ModuleName.nameToChars child
253252 ++ "` module is in one of the \"source-directories\" listed in your elm.json file."
254253 ]
255254
@@ -279,15 +278,15 @@ ambiguousToDoc :: Origin -> ModuleName.Raw -> [FilePath] -> [Pkg.Canonical] -> H
279278ambiguousToDoc origin child paths pkgs =
280279 let
281280 pkgToString (Pkg.Canonical pkg vsn) =
282− "exposed by " ++ Pkg.toString pkg ++ " " ++ Pkg.versionToString vsn
281+ "exposed by " ++ Pkg.toChars pkg ++ " " ++ V.toChars vsn
283282
284283 makeReport maybePath summary yellowString =
285284 Help.report "AMBIGUOUS IMPORT" maybePath summary
286− [ D.indent 4 $ D.dullyellow $ D.fromString yellowString
285+ [ D.indent 4 $ D.dullyellow $ D.fromChars yellowString
287286 , D.reflow $
288287 "I found multiple module with that name though:"
289288 , D.indent 4 $ D.dullyellow $ D.vcat $
290− map D.fromString $ paths ++ map pkgToString pkgs
289+ map D.fromChars $ paths ++ map pkgToString pkgs
291290 , D.reflow $
292291 if null paths then
293292 "It looks like the name clash is in your dependencies, which is\
@@ -303,19 +302,19 @@ ambiguousToDoc origin child paths pkgs =
303302 makeReport
304303 Nothing
305304 "Your elm.json wants the following module:"
306− (ModuleName.nameToString child)
305+ (ModuleName.nameToChars child)
307306
308307 File path ->
309308 makeReport
310309 (Just path)
311310 ("The file at " ++ path ++ " has an ambiguous import:")
312− ("import " ++ ModuleName.nameToString child)
311+ ("import " ++ ModuleName.nameToChars child)
313312
314313 Module path parent ->
315314 makeReport
316315 (Just path)
317− ("The " ++ ModuleName.nameToString parent ++ " module has an ambiguous import:")
318− ("import " ++ ModuleName.nameToString child)
316+ ("The " ++ ModuleName.nameToChars parent ++ " module has an ambiguous import:")
317+ ("import " ++ ModuleName.nameToChars child)
319318
320319
321320kernelNameToDoc :: Origin -> ModuleName.Raw -> Help.Report
@@ -335,11 +334,11 @@ kernelNameToDoc origin kernelName =
335334
336335 Module path parent ->
337336 ( Just path
338− , "Your " ++ ModuleName.nameToString parent ++ " module is trying to import:"
337+ , "Your " ++ ModuleName.nameToChars parent ++ " module is trying to import:"
339338 )
340339 in
341340 Help.report "BAD MODULE NAME" maybePath statement
342− [ D.indent 4 $ D.dullyellow $ D.fromString $ ModuleName.nameToString kernelName
341+ [ D.indent 4 $ D.dullyellow $ D.fromChars $ ModuleName.nameToChars kernelName
343342 , D.reflow $
344343 "But names like that are reserved for internal use.\
345344 \ Switch to a name outside of the Elm/Kernel/ namespace."
builder/src/Reporting/Exit/Deps.hs+16−16
@@ -6,9 +6,9 @@ module Reporting.Exit.Deps
66 where
77
88
9−import qualified Elm.Compiler as Compiler
9+import qualified Elm.Constraint as Con
1010import qualified Elm.Package as Pkg
11−import qualified Elm.Project.Constraint as Con
11+import qualified Elm.Version as V
1212import Reporting.Doc ((<>))
1313import qualified Reporting.Doc as D
1414import qualified Reporting.Exit.Help as Help
@@ -23,10 +23,10 @@ data Exit
2323 | PackageNotFound Pkg.Name [Pkg.Name]
2424 -- verify
2525 | PkgBadElm Con.Constraint
26− | AppBadElm Pkg.Version
27− | AppMissingTrans [(Pkg.Name, Pkg.Version)]
26+ | AppBadElm V.Version
27+ | AppMissingTrans [(Pkg.Name, V.Version)]
2828 | BadDeps
29− | BuildFailure FilePath Pkg.Name Pkg.Version
29+ | BuildFailure FilePath Pkg.Name V.Version
3030
3131
3232
@@ -40,7 +40,7 @@ toReport exit =
4040 Help.report "CORRUPT CACHE" Nothing
4141 ( "I ran into an unknown package while exploring dependencies:"
4242 )
43− [ D.indent 4 $ D.dullyellow $ D.fromString $ Pkg.toString pkg
43+ [ D.indent 4 $ D.dullyellow $ D.fromUtf8 $ Pkg.toString pkg
4444 , D.reflow $
4545 "This suggests that your " ++ elmHome ++ " directory has been corrupted.\
4646 \ Maybe some program is messing with it? It is just cached files,\
@@ -51,22 +51,22 @@ toReport exit =
5151 Help.docReport "PACKAGE NOT FOUND" Nothing
5252 ( D.fillSep
5353 ["I","cannot","find","a"
54− ,D.red (D.fromString (Pkg.toString package))
54+ ,D.red (D.fromUtf8 (Pkg.toString package))
5555 ,"package","on","the","package","website."
5656 ]
5757 )
5858 [ "Maybe you want one of these instead?"
59− , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromString . Pkg.toString) suggestions
59+ , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromUtf8 . Pkg.toString) suggestions
6060 , "But check <https://package.elm-lang.org> to see all possibilities!"
6161 ]
6262
6363 PkgBadElm constraint ->
6464 Help.report "ELM VERSION MISMATCH" (Just "elm.json")
6565 "Your elm.json says this package needs a version of Elm in this range:"
66− [ D.indent 4 $ D.dullyellow $ D.fromString $ Con.toString constraint
66+ [ D.indent 4 $ D.dullyellow $ D.fromUtf8 $ Con.toString constraint
6767 , D.fillSep
6868 [ "But", "you", "are", "using", "Elm"
69− , D.red (D.fromString (Pkg.versionToString Compiler.version))
69+ , D.red (D.fromUtf8 (V.toString V.compiler))
7070 , "right", "now."
7171 ]
7272 ]
@@ -76,9 +76,9 @@ toReport exit =
7676 "Your elm.json says this application needs a different version of Elm."
7777 [ D.fillSep
7878 [ "It", "requires"
79− , D.green (D.fromString (Pkg.versionToString version)) <> ","
79+ , D.green (D.fromUtf8 (V.toString version)) <> ","
8080 , "but", "you", "are", "using"
81− , D.red (D.fromString (Pkg.versionToString Compiler.version))
81+ , D.red (D.fromUtf8 (V.toString V.compiler))
8282 , "right", "now."
8383 ]
8484 ]
@@ -86,11 +86,11 @@ toReport exit =
8686 AppMissingTrans missingDeps ->
8787 let
8888 toEntry (pkg, vsn) =
89− "\"" ++ Pkg.toString pkg ++ "\": \"" ++ Pkg.versionToString vsn ++ "\""
89+ "\"" ++ Pkg.toChars pkg ++ "\": \"" ++ V.toChars vsn ++ "\""
9090 in
9191 Help.report "MISSING DEPENDENCIES" (Just "elm.json")
9292 "Your elm.json is missing some \"indirect\" dependencies:"
93− [ D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromString . toEntry) missingDeps
93+ [ D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromChars . toEntry) missingDeps
9494 , D.fillSep
9595 ["This","usually","means","you","are","editing","elm.json","by","hand."
9696 ,"It","is","much","more","reliable","to","use","the"
@@ -114,10 +114,10 @@ toReport exit =
114114 BuildFailure elmHome pkg vsn ->
115115 Help.report "CORRUPT DEPENDENCY" Nothing
116116 "I ran into a problem while building the following package:"
117− [ D.indent 4 $ D.red $ D.fromString $ Pkg.toString pkg ++ " " ++ Pkg.versionToString vsn
117+ [ D.indent 4 $ D.red $ D.fromChars $ Pkg.toChars pkg ++ " " ++ V.toChars vsn
118118 , D.fillSep
119119 ["This","probably","means","the","downloaded","files","got","corrupted","somehow."
120− ,"Try","deleting",D.dullyellow (D.fromString elmHome),"(a","directory","for"
120+ ,"Try","deleting",D.dullyellow (D.fromChars elmHome),"(a","directory","for"
121121 ,"caching","build","artifacts)","and","see","if","that","resolves","the","issue."
122122 ]
123123 ]
builder/src/Reporting/Exit/Diff.hs+7−6
@@ -9,6 +9,7 @@ module Reporting.Exit.Diff
99import qualified Data.List as List
1010
1111import qualified Elm.Package as Pkg
12+import qualified Elm.Version as V
1213import qualified Reporting.Doc as D
1314import qualified Reporting.Exit.Help as Help
1415
@@ -21,7 +22,7 @@ data Exit
2122 = Application
2223 | Unpublished
2324 | UnknownPackage Pkg.Name [Pkg.Name]
24− | UnknownVersion Pkg.Name Pkg.Version [Pkg.Version]
25+ | UnknownVersion Pkg.Name V.Version [V.Version]
2526
2627
2728
@@ -47,16 +48,16 @@ toReport exit =
4748 Help.report "UNKNOWN PACKAGE" Nothing
4849 ( "I cannot find a package called:"
4950 )
50− [ D.indent 4 $ D.red $ D.fromText $ Pkg.toText pkg
51+ [ D.indent 4 $ D.red $ D.fromUtf8 $ Pkg.toString pkg
5152 , "Maybe you want one of these instead?"
52− , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromText . Pkg.toText) suggestions
53+ , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromUtf8 . Pkg.toString) suggestions
5354 , "But check <https://package.elm-lang.org> to see all possibilities!"
5455 ]
5556
5657 UnknownVersion _pkg vsn realVersions ->
5758 Help.docReport "UNKNOWN VERSION" Nothing
5859 ( D.fillSep $
59− [ "Version", D.red (D.fromText (Pkg.versionToText vsn))
60+ [ "Version", D.red (D.fromUtf8 (V.toString vsn))
6061 , "has", "never", "been", "published,", "so", "I"
6162 , "cannot", "diff", "against", "it."
6263 ]
@@ -64,8 +65,8 @@ toReport exit =
6465 [ "Here are all the versions that HAVE been published:"
6566 , D.indent 4 $ D.dullyellow $ D.vcat $
6667 let
67− sameMajor v1 v2 = Pkg._major v1 == Pkg._major v2
68− mkRow vsns = D.hsep $ map (D.fromText . Pkg.versionToText) vsns
68+ sameMajor v1 v2 = V._major v1 == V._major v2
69+ mkRow vsns = D.hsep $ map (D.fromUtf8 . V.toString) vsns
6970 in
7071 map mkRow $ List.groupBy sameMajor (List.sort realVersions)
7172 , "Want one of those instead?"
builder/src/Reporting/Exit/Help.hs+13−12
@@ -14,11 +14,12 @@ module Reporting.Exit.Help
1414 where
1515
1616
17−import qualified Data.Text as Text
17+import qualified Data.Utf8 as Utf8
1818import GHC.IO.Handle (hIsTerminalDevice)
1919import System.IO (Handle, hPutStr, stderr, stdout)
2020
21−import qualified Json.Encode as Encode
21+import qualified Json.Encode as E
22+import Json.Encode ((==>))
2223import Reporting.Doc ((<+>))
2324import qualified Reporting.Doc as D
2425import qualified Reporting.Exit.Compile as Compile
@@ -82,7 +83,7 @@ reportToDoc report_ =
8283
8384 errorBar =
8485 D.dullcyan $
85− "--" <+> D.fromString title <+> D.fromString errorBarEnd
86+ "--" <+> D.fromChars title <+> D.fromChars errorBarEnd
8687 in
8788 D.stack [errorBar, message, ""]
8889
@@ -91,21 +92,21 @@ reportToDoc report_ =
9192-- TO JSON
9293
9394
94−reportToJson :: Report -> Encode.Value
95+reportToJson :: Report -> E.Value
9596reportToJson report_ =
9697 case report_ of
9798 CompilerReport e es ->
98− Encode.object
99− [ ("type", Encode.text "compile-errors")
100− , ("errors", Encode.list Compile.toJson (e:es))
99+ E.object
100+ [ "type" ==> E.string "compile-errors"
101+ , "errors" ==> E.list Compile.toJson (e:es)
101102 ]
102103
103104 Report title maybePath message ->
104− Encode.object
105− [ ("type", Encode.text "error")
106− , ("path", maybe Encode.null (Encode.text . Text.pack) maybePath)
107− , ("title", Encode.text (Text.pack title))
108− , ("message", D.encode message)
105+ E.object
106+ [ "type" ==> E.string "error"
107+ , "path" ==> maybe E.null (E.string . Utf8.fromChars) maybePath
108+ , "title" ==> E.string (Utf8.fromChars title)
109+ , "message" ==> D.encode message
109110 ]
110111
111112
builder/src/Reporting/Exit/Init.hs+3−4
@@ -6,11 +6,10 @@ module Reporting.Exit.Init
66 where
77
88
9+import qualified Elm.Package as Pkg
910import qualified Reporting.Doc as D
1011import qualified Reporting.Exit.Help as Help
1112
12−import qualified Elm.Package as Pkg
13−
1413
1514
1615-- EXITS
@@ -32,7 +31,7 @@ toReport exit =
3231 Help.report "NO SOLUTION" Nothing
3332 "I tried to create an elm.json with the following direct dependencies:"
3433 [ D.indent 4 $ D.vcat $
35− map (D.dullyellow . D.fromString . Pkg.toString) pkgs
34+ map (D.dullyellow . D.fromChars . Pkg.toChars) pkgs
3635 , D.reflow $
3736 "I could not find compatible versions though! This should not happen, so please\
3837 \ ask around one of the community forums <http://elm-lang.org/community> to learn\
@@ -43,7 +42,7 @@ toReport exit =
4342 Help.report "EXISTING PROJECT" Nothing
4443 "You already have an elm.json file, so there is nothing for me to initialize!"
4544 [ D.fillSep
46− ["Maybe",D.green (D.fromString (D.makeLink "init")),"can","help"
45+ ["Maybe",D.green (D.fromChars (D.makeLink "init")),"can","help"
4746 ,"you","figure","out","what","to","do","next?"
4847 ]
4948 ]
builder/src/Reporting/Exit/Install.hs+4−4
@@ -6,8 +6,8 @@ module Reporting.Exit.Install
66 where
77
88
9−import qualified Elm.Compiler as Compiler
109import qualified Elm.Package as Pkg
10+import qualified Elm.Version as V
1111import qualified Reporting.Doc as D
1212import qualified Reporting.Exit.Help as Help
1313
@@ -40,7 +40,7 @@ toReport exit =
4040 ["In","JavaScript","folks","run","`npm install`","to","start","projects."
4141 ,"\"Gotta","download","everything!\"","But","why","download","packages"
4242 ,"again","and","again?","Instead,","Elm","caches","packages","in"
43− ,D.dullyellow (D.fromString elmHome)
43+ ,D.dullyellow (D.fromChars elmHome)
4444 ,"so","each","one","is","downloaded","and","built","ONCE","on","your","machine."
4545 ,"Elm","projects","check","that","cache","before","trying","the","internet."
4646 ,"This","reduces","build","times,","reduces","server","costs,","and","makes","it"
@@ -65,9 +65,9 @@ toReport exit =
6565
6666 _:_ ->
6767 Help.report "OLD DEPENDENCIES" (Just "elm.json")
68− ( "The following packages do not work with Elm " ++ Pkg.versionToString Compiler.version ++ " right now:"
68+ ( "The following packages do not work with Elm " ++ V.toChars V.compiler ++ " right now:"
6969 )
70− [ D.indent 4 $ D.vcat $ map (D.red . D.fromString . Pkg.toString) badPackages
70+ [ D.indent 4 $ D.vcat $ map (D.red . D.fromUtf8 . Pkg.toString) badPackages
7171 , D.reflow $
7272 "This may be because it is not upgraded yet. It may be because a\
7373 \ better solution came along, so there was no need to upgrade it.\
builder/src/Reporting/Exit/Make.hs+1−1
@@ -42,7 +42,7 @@ toReport exit =
4242 CannotOptimizeDebugValues m ms ->
4343 Help.report "DEBUG REMNANTS" Nothing
4444 "There are uses of the `Debug` module in the following modules:"
45− [ D.indent 4 $ D.red $ D.vcat $ map (D.fromString . ModuleName.nameToString) (m:ms)
45+ [ D.indent 4 $ D.red $ D.vcat $ map (D.fromChars . ModuleName.nameToChars) (m:ms)
4646 , D.reflow "But the --optimize flag only works if all `Debug` functions are removed!"
4747 , D.toSimpleNote $
4848 "The issue is that --optimize strips out info needed by `Debug` functions.\
builder/src/Reporting/Exit/Publish.hs+22−22
@@ -7,7 +7,7 @@ module Reporting.Exit.Publish
77
88
99import Deps.Diff (Magnitude, magnitudeToString)
10−import qualified Elm.Package as Pkg
10+import qualified Elm.Version as V
1111import Reporting.Doc ((<>))
1212import qualified Reporting.Doc as D
1313import qualified Reporting.Exit.Help as Help
@@ -19,18 +19,18 @@ import qualified Reporting.Exit.Help as Help
1919
2020data Exit
2121 = Application
22− | NotInitialVersion Pkg.Version
23− | AlreadyPublished Pkg.Version
24− | InvalidBump Pkg.Version Pkg.Version
25− | BadBump Pkg.Version Pkg.Version Magnitude Pkg.Version Magnitude
22+ | NotInitialVersion V.Version
23+ | AlreadyPublished V.Version
24+ | InvalidBump V.Version V.Version
25+ | BadBump V.Version V.Version Magnitude V.Version Magnitude
2626 | NoSummary
2727 | NoExposed
2828 | NoReadme
2929 | ShortReadme
3030 | NoLicense
31− | MissingTag Pkg.Version
31+ | MissingTag V.Version
3232 | NoGit
33− | LocalChanges Pkg.Version
33+ | LocalChanges V.Version
3434
3535
3636
@@ -47,7 +47,7 @@ toReport exit =
4747 Help.docReport "INVALID VERSION" Nothing
4848 ( D.fillSep
4949 ["I","cannot","publish"
50− ,D.red (D.fromString (Pkg.versionToString vsn))
50+ ,D.red (D.fromUtf8 (V.toString vsn))
5151 ,"as","the","initial","version."
5252 ]
5353 )
@@ -61,7 +61,7 @@ toReport exit =
6161 Help.docReport "ALREADY PUBLISHED" Nothing
6262 ( D.vcat
6363 [ D.fillSep
64− [ "Version", D.green (D.fromString (Pkg.versionToString vsn))
64+ [ "Version", D.green (D.fromUtf8 (V.toString vsn))
6565 , "has", "already", "been", "published.", "You", "cannot"
6666 , "publish", "it", "again!"
6767 ]
@@ -78,14 +78,14 @@ toReport exit =
7878 Help.docReport "INVALID VERSION" (Just "elm.json")
7979 ( D.fillSep $
8080 ["Your","elm.json","says","the","next","version","should","be"
81− ,D.red (D.fromString (Pkg.versionToString statedVersion)) <> ","
81+ ,D.red (D.fromUtf8 (V.toString statedVersion)) <> ","
8282 ,"but","that","is","not","valid","based","on","the","previously"
8383 ,"published","versions."
8484 ]
8585 )
8686 [ D.fillSep $
8787 ["Change","the","version","back","to"
88− ,D.green (D.fromString (Pkg.versionToString latestVersion))
88+ ,D.green (D.fromUtf8 (V.toString latestVersion))
8989 ,"which","is","the","most","recently","published","version."
9090 ,"From","there,","have","Elm","bump","the","version","by","running:"
9191 ]
@@ -100,20 +100,20 @@ toReport exit =
100100 (
101101 D.fillSep $
102102 ["Your","elm.json","says","the","next","version","should","be"
103− ,D.red (D.fromString (Pkg.versionToString new)) <> ","
104− ,"indicating","a",D.fromString (magnitudeToString magnitude)
103+ ,D.red (D.fromUtf8 (V.toString new)) <> ","
104+ ,"indicating","a",D.fromChars (magnitudeToString magnitude)
105105 ,"change","to","the","public","API."
106106 ,"This","does","not","match","the","API","diff","given","by:"
107107 ]
108108 )
109− [ D.indent 4 $ D.fromString $
110− "elm diff " ++ Pkg.versionToString old
109+ [ D.indent 4 $ D.fromChars $
110+ "elm diff " ++ V.toChars old
111111
112112 , D.fillSep $
113113 ["This","command","says","this","is","a"
114− ,D.fromString (magnitudeToString realMagnitude)
114+ ,D.fromChars (magnitudeToString realMagnitude)
115115 ,"change,","so","the","next","version","should","be"
116− ,D.green (D.fromString (Pkg.versionToString realNew)) <> "."
116+ ,D.green (D.fromUtf8 (V.toString realNew)) <> "."
117117 ,"Double","check","everything","to","make","sure","you"
118118 ,"are","publishing","what","you","want!"
119119 ]
@@ -170,18 +170,18 @@ toReport exit =
170170 ]
171171
172172 MissingTag version ->
173− let vsn = Pkg.versionToString version in
173+ let vsn = V.toChars version in
174174 Help.docReport "NO TAG" Nothing
175175 ( D.fillSep $
176176 [ "Packages", "must", "be", "tagged", "in", "git,", "but", "I"
177− , "cannot", "find", "a", D.green (D.fromString vsn), "tag."
177+ , "cannot", "find", "a", D.green (D.fromChars vsn), "tag."
178178 ]
179179 )
180180 [ D.vcat
181181 [ "These tags make it possible to find this specific version on GitHub."
182182 , "To tag the most recent commit and push it to GitHub, run this:"
183183 ]
184− , D.indent 4 $ D.dullyellow $ D.vcat $ map D.fromString $
184+ , D.indent 4 $ D.dullyellow $ D.vcat $ map D.fromChars $
185185 [ "git tag -a " ++ vsn ++ " -m \"new release\""
186186 , "git push origin " ++ vsn
187187 ]
@@ -202,10 +202,10 @@ toReport exit =
202202 ]
203203
204204 LocalChanges version ->
205− let vsn = Pkg.versionToString version in
205+ let vsn = V.toChars version in
206206 Help.docReport "LOCAL CHANGES" Nothing
207207 ( D.fillSep $
208− [ "The", "code", "tagged", "as", D.green (D.fromString vsn), "in"
208+ [ "The", "code", "tagged", "as", D.green (D.fromChars vsn), "in"
209209 , "git", "does", "not", "match", "the", "code", "in", "your"
210210 , "working", "directory.", "This", "means", "you", "have"
211211 , "commits", "or", "local", "changes", "that", "are", "not"
builder/src/Reporting/Progress.hs+9−8
@@ -16,7 +16,8 @@ import Control.Concurrent.Chan (Chan, writeChan)
1616import Control.Concurrent.MVar (MVar, newEmptyMVar, readMVar)
1717import qualified Elm.ModuleName as ModuleName
1818import Deps.Diff (Magnitude)
19−import Elm.Package (Name, Version)
19+import qualified Elm.Package as Pkg
20+import qualified Elm.Version as V
2021import qualified Reporting.Doc as D
2122import Reporting.Exit (Exit)
2223
@@ -72,9 +73,9 @@ data Msg
7273data Progress
7374 -- download packages
7475 = DownloadSkip
75− | DownloadStart [(Name, Version)]
76− | DownloadPkgStart Name Version
77− | DownloadPkgEnd Name Version Outcome
76+ | DownloadStart [(Pkg.Name, V.Version)]
77+ | DownloadPkgStart Pkg.Name V.Version
78+ | DownloadPkgEnd Pkg.Name V.Version Outcome
7879 | DownloadEnd Outcome
7980
8081 -- build dependencies
@@ -89,8 +90,8 @@ data Progress
8990 | CompileEnd
9091
9192 -- publish
92− | PublishStart Name Version (Maybe [Version])
93− | PublishCheckBump Version BumpPhase
93+ | PublishStart Pkg.Name V.Version (Maybe [V.Version])
94+ | PublishCheckBump V.Version BumpPhase
9495 | PublishProgress PublishPhase (Maybe Outcome)
9596 | PublishEnd
9697
@@ -104,7 +105,7 @@ data Outcome = Good | Bad
104105data PublishPhase
105106 = CheckReadme
106107 | CheckLicense
107− | CheckTag Version
108+ | CheckTag V.Version
108109 | CheckDownload
109110 | CheckBuild
110111 | CheckChanges
@@ -113,5 +114,5 @@ data PublishPhase
113114data BumpPhase
114115 = StatedVersion
115116 | GoodStart
116− | GoodBump Version Magnitude
117+ | GoodBump V.Version Magnitude
117118 | BadBump
builder/src/Reporting/Progress/Terminal.hs+19−19
@@ -12,7 +12,7 @@ import Control.Concurrent.MVar (newEmptyMVar, putMVar)
1212import qualified System.Info as Info
1313import System.IO (hFlush, hPutStr, stdout)
1414import qualified Elm.Package as Pkg
15−import Elm.Package (Name, Version)
15+import qualified Elm.Version as V
1616
1717import qualified Deps.Diff as Diff
1818import Reporting.Doc ((<>), (<+>))
@@ -182,7 +182,7 @@ loopHelp chan progress state@(State total good bad) =
182182 loop chan state
183183
184184 Just _ ->
185− do putStrLn $ unwords [ "Verifying", Pkg.toString name, Pkg.versionToString version, "..." ]
185+ do putStrLn $ unwords [ "Verifying", Pkg.toChars name, V.toChars version, "..." ]
186186 putStrLn ""
187187 loop chan state
188188
@@ -214,11 +214,11 @@ loopHelp chan progress state@(State total good bad) =
214214-- BULLETS
215215
216216
217−makeBullet :: Name -> Version -> Outcome -> D.Doc
217+makeBullet :: Pkg.Name -> V.Version -> Outcome -> D.Doc
218218makeBullet name version outcome =
219219 let
220− nm = D.fromText (Pkg.toText name)
221− vsn = D.fromText (Pkg.versionToText version)
220+ nm = D.fromUtf8 (Pkg.toString name)
221+ vsn = D.fromUtf8 (V.toString version)
222222
223223 bullet =
224224 case outcome of
@@ -257,7 +257,7 @@ newPackageOverview =
257257 , ""
258258 , " - Versions all have exactly three parts: MAJOR.MINOR.PATCH"
259259 , ""
260− , " - All packages start with initial version " ++ Pkg.versionToString Pkg.initialVersion
260+ , " - All packages start with initial version " ++ V.toChars V.one
261261 , ""
262262 , " - Versions are incremented based on how the API changes:"
263263 , ""
@@ -282,13 +282,13 @@ toChecklistDoc status (ChecklistMessages waiting success failure) =
282282 in
283283 case status of
284284 Nothing ->
285− " " <> waitingMark <+> D.fromString waiting
285+ " " <> waitingMark <+> D.fromChars waiting
286286
287287 Just Good ->
288− "\r " <> goodMark <+> D.fromString (padded success ++ "\n")
288+ "\r " <> goodMark <+> D.fromChars (padded success ++ "\n")
289289
290290 Just Bad ->
291− "\r " <> badMark <+> D.fromString (padded failure ++ "\n\n")
291+ "\r " <> badMark <+> D.fromChars (padded failure ++ "\n\n")
292292
293293
294294data ChecklistMessages =
@@ -316,9 +316,9 @@ toChecklistMessages phase =
316316
317317 CheckTag version ->
318318 ChecklistMessages
319− ("Is version " ++ Pkg.versionToString version ++ " tagged on GitHub?")
320− ("Version " ++ Pkg.versionToString version ++ " is tagged on GitHub")
321− ("Version " ++ Pkg.versionToString version ++ " is not tagged on GitHub!")
319+ ("Is version " ++ V.toChars version ++ " tagged on GitHub?")
320+ ("Version " ++ V.toChars version ++ " is tagged on GitHub")
321+ ("Version " ++ V.toChars version ++ " is not tagged on GitHub!")
322322
323323 CheckDownload ->
324324 ChecklistMessages
@@ -343,14 +343,14 @@ toChecklistMessages phase =
343343-- BUMP PHASE
344344
345345
346−bumpPhaseToChecklistDoc :: Pkg.Version -> BumpPhase -> D.Doc
346+bumpPhaseToChecklistDoc :: V.Version -> BumpPhase -> D.Doc
347347bumpPhaseToChecklistDoc version bumpPhase =
348348 let
349349 mkMsgs success =
350350 ChecklistMessages
351− ("Checking semantic versioning rules. Is " ++ Pkg.versionToString version ++ " correct?")
351+ ("Checking semantic versioning rules. Is " ++ V.toChars version ++ " correct?")
352352 success
353− ("Version " ++ Pkg.versionToString version ++ " is not correct!")
353+ ("Version " ++ V.toChars version ++ " is not correct!")
354354 in
355355
356356 case bumpPhase of
@@ -359,7 +359,7 @@ bumpPhaseToChecklistDoc version bumpPhase =
359359
360360 GoodStart ->
361361 toChecklistDoc (Just Good) $ mkMsgs $
362− "All packages start at version " ++ Pkg.versionToString Pkg.initialVersion
362+ "All packages start at version " ++ V.toChars V.one
363363
364364 GoodBump old magnitude ->
365365 toChecklistDoc (Just Good) $ mkMsgs $
@@ -369,11 +369,11 @@ bumpPhaseToChecklistDoc version bumpPhase =
369369 toChecklistDoc (Just Bad) $ mkMsgs ""
370370
371371
372−toCheckVersionSuccessMessage :: Pkg.Version -> Pkg.Version -> Diff.Magnitude -> String
372+toCheckVersionSuccessMessage :: V.Version -> V.Version -> Diff.Magnitude -> String
373373toCheckVersionSuccessMessage oldVersion newVersion magnitude =
374374 let
375− old = Pkg.versionToString oldVersion
376− new = Pkg.versionToString newVersion
375+ old = V.toChars oldVersion
376+ new = V.toChars newVersion
377377 mag = Diff.magnitudeToString magnitude
378378 in
379379 "Version number " ++ new ++ " verified (" ++ mag ++ " change, " ++ old ++ " => " ++ new ++ ")"
builder/src/Reporting/Task.hs+3−3
@@ -30,9 +30,9 @@ import qualified System.Directory as Dir
3030import qualified System.Exit as Exit
3131import System.FilePath ((</>))
3232
33−import Elm.Package (Name, Version)
3433import qualified Elm.Package as Pkg
3534import qualified Elm.PerUserCache as PerUserCache
35+import qualified Elm.Version as V
3636import qualified Reporting.Doc as D
3737import qualified Reporting.Exit as Exit
3838import qualified Reporting.Progress as Progress
@@ -104,10 +104,10 @@ getPackageCacheDir =
104104 R.asks _cacheDir
105105
106106
107−getPackageCacheDirFor :: Name -> Version -> Task_ e FilePath
107+getPackageCacheDirFor :: Pkg.Name -> V.Version -> Task_ e FilePath
108108getPackageCacheDirFor name version =
109109 do cacheDir <- getPackageCacheDir
110− let dir = cacheDir </> Pkg.toFilePath name </> Pkg.versionToString version
110+ let dir = cacheDir </> Pkg.toFilePath name </> V.toChars version
111111 liftIO (Dir.createDirectoryIfMissing True dir)
112112 return dir
113113
builder/src/Reporting/Task/Http.hs+2−3
@@ -23,8 +23,7 @@ import qualified Network.HTTP as Http (urlEncodeVars)
2323import qualified Network.HTTP.Client as Http
2424import qualified Network.HTTP.Types.Header as Http (hAcceptEncoding, hUserAgent)
2525
26−import qualified Elm.Compiler as Compiler
27−import qualified Elm.Package as Pkg
26+import qualified Elm.Version as V
2827import qualified Reporting.Exit as Exit
2928import qualified Reporting.Exit.Http as E
3029import qualified Reporting.Progress as Progress
@@ -192,4 +191,4 @@ addHeaders request =
192191{-# NOINLINE userAgent #-}
193192userAgent :: BS.ByteString
194193userAgent =
195− BS.pack ("elm/" ++ Pkg.versionToString Compiler.version)
194+ BS.pack ("elm/" ++ V.toChars V.compiler)
builder/src/Stuff/Paths.hs+2−3
@@ -16,9 +16,8 @@ import Control.Monad.Trans (liftIO)
1616import qualified System.Directory as Dir
1717import System.FilePath ((</>), (<.>))
1818
19−import qualified Elm.Compiler as Compiler
2019import qualified Elm.ModuleName as ModuleName
21−import qualified Elm.Package as Pkg
20+import qualified Elm.Version as V
2221import qualified Reporting.Task as Task
2322
2423
@@ -28,7 +27,7 @@ import qualified Reporting.Task as Task
2827
2928stuff :: FilePath
3029stuff =
31− "elm-stuff" </> Pkg.versionToString Compiler.version
30+ "elm-stuff" </> V.toChars V.compiler
3231
3332
3433docs :: FilePath