@@ -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."