@@ -9,15 +9,14 @@ module Reporting.Exit.Crawl
12−import qualified Data.ByteString as BS
13import qualified Data.Char as Char
12import qualified Data.Char as Char
14import qualified Data.Map as Map
13import qualified Data.Map as Map
15−import qualified Data.Text.Encoding as Text
16import qualified Data.Time.Clock as Time
14import qualified Data.Time.Clock as Time
18import qualified Elm.Compiler as Compiler
16import qualified Elm.Compiler as Compiler
19import qualified Elm.ModuleName as ModuleName
17import qualified Elm.ModuleName as ModuleName
20import qualified Elm.Package as Pkg
18import qualified Elm.Package as Pkg
19+import qualified Elm.Version as V
21import Reporting.Doc ((<+>), (<>))
20import Reporting.Doc ((<+>), (<>))
22import qualified Reporting.Doc as D
21import qualified Reporting.Doc as D
23import qualified Reporting.Exit.Compile as Compile
22import qualified Reporting.Exit.Compile as Compile
@@ -39,7 +38,7 @@ data Exit
39data Problem
38data Problem
40 = ModuleNotFound Origin ModuleName.Raw SrcDirs
39 = ModuleNotFound Origin ModuleName.Raw SrcDirs
41 | ModuleAmbiguous Origin ModuleName.Raw [FilePath] [Pkg.Canonical]
40 | ModuleAmbiguous Origin ModuleName.Raw [FilePath] [Pkg.Canonical]
42− | BadHeader FilePath Time.UTCTime BS.ByteString Compiler.Error
41+ | BadHeader FilePath Time.UTCTime String Compiler.Error
43 | ModuleNameReservedForKernel Origin ModuleName.Raw
42 | ModuleNameReservedForKernel Origin ModuleName.Raw
44 | ModuleNameMissing FilePath ModuleName.Raw
43 | ModuleNameMissing FilePath ModuleName.Raw
45 | ModuleNameMismatch
44 | ModuleNameMismatch
@@ -71,7 +70,7 @@ toReport exit =
71 RootFileNotFound path ->
70 RootFileNotFound path ->
72 Help.report "FILE NOT FOUND" Nothing
71 Help.report "FILE NOT FOUND" Nothing
73 "You want me to compile this file:"
72 "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
75 , "I cannot find it though! Is there a typo?"
74 , "I cannot find it though! Is there a typo?"
@@ -79,10 +78,10 @@ toReport exit =
79 Help.report "DUPLICATE NAMES" Nothing
78 Help.report "DUPLICATE NAMES" Nothing
80 "I am trying to compile multiple modules with the same name:"
79 "I am trying to compile multiple modules with the same name:"
81 [ D.indent 4 $ D.dullyellow $ D.vcat $
80 [ D.indent 4 $ D.dullyellow $ D.vcat $
82− map D.fromString paths
81+ map D.fromChars paths
83 , D.fillSep $
82 , D.fillSep $
84 [ "These", "modules", if length paths == 2 then "both" else "all", "claim"
83 [ "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)) <> "."
86 , "Change", "them", "to", "have", "unique", "names", "and", "you"
85 , "Change", "them", "to", "have", "unique", "names", "and", "you"
87 , "should", "be", "all", "set!"
86 , "should", "be", "all", "set!"
@@ -103,7 +102,7 @@ toReport exit =
103 BadKernelHeader filePath ->
102 BadKernelHeader filePath ->
104 Help.report "BAD KERNEL HEADER" Nothing
103 Help.report "BAD KERNEL HEADER" Nothing
105 "I ran into a bad header in this file:"
104 "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
107 , D.reflow $
106 , D.reflow $
108 "NOTE: Kernel code is only available to core Elm libraries to ensure\
107 "NOTE: Kernel code is only available to core Elm libraries to ensure\
109 \ the portability and security of the Elm ecosystem. This restriction\
108 \ the portability and security of the Elm ecosystem. This restriction\
@@ -128,7 +127,7 @@ problemToReport problem =
128 BadHeader path time source compilerError ->
127 BadHeader path time source compilerError ->
130 compilerExit =
129 compilerExit =
131− Compile.Exit "???" path time (Text.decodeUtf8 source) [compilerError]
130+ Compile.Exit "???" path time source [compilerError]
133 Help.compilerReport compilerExit []
132 Help.compilerReport compilerExit []
@@ -139,9 +138,9 @@ problemToReport problem =
139 Help.report "MODULE NAME MISMATCH" (Just path)
138 Help.report "MODULE NAME MISMATCH" (Just path)
140 ( "The file at " ++ path ++ " has a typo in the module name. It says:"
139 ( "The file at " ++ path ++ " has a typo in the module name. It says:"
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 (..)"
143 , "Looks like a typo or copy/paste error. Instead it needs to say:"
142 , "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 (..)"
145 , "Make the change and you should be all set!"
144 , "Make the change and you should be all set!"
@@ -167,9 +166,9 @@ badTagToDoc path name tag hintName summary =
168 [ D.fillSep $
167 [ D.fillSep $
169 [ "Get", "rid", "of", "all", "the"
168 [ "Get", "rid", "of", "all", "the"
170− , D.red (D.fromString tag)
169+ , D.red (D.fromChars tag)
171 , "stuff", "in"
170 , "stuff", "in"
172− , D.dullyellow (D.fromString (ModuleName.nameToString name))
171+ , D.dullyellow (D.fromChars (ModuleName.nameToChars name))
173 , "to", "proceed."
172 , "to", "proceed."
175 , D.toSimpleNote $
174 , D.toSimpleNote $
@@ -185,11 +184,11 @@ badTagToDoc path name tag hintName summary =
185namelessToDoc :: FilePath -> ModuleName.Raw -> Help.Report
184namelessToDoc :: FilePath -> ModuleName.Raw -> Help.Report
186namelessToDoc path name =
185namelessToDoc path name =
187 Help.report "UNNAMED MODULE" (Just path)
186 Help.report "UNNAMED MODULE" (Just path)
188− ( "The `" ++ ModuleName.nameToString name
187+ ( "The `" ++ ModuleName.nameToChars name
189 ++ "` module must start with a line like this:"
188 ++ "` module must start with a line like this:"
191− [ D.indent 4 $ D.dullyellow $ D.fromString $
190+ [ D.indent 4 $ D.dullyellow $ D.fromChars $
192− "module " ++ ModuleName.nameToString name ++ " exposing (..)"
191+ "module " ++ ModuleName.nameToChars name ++ " exposing (..)"
193 , D.reflow $
192 , D.reflow $
194 "Try adding that as the first line of your file!"
193 "Try adding that as the first line of your file!"
195 , D.toSimpleNote $
194 , D.toSimpleNote $
@@ -210,19 +209,19 @@ notFoundToDoc origin child srcDirs =
210 ElmJson ->
209 ElmJson ->
211 Help.report "MODULE NOT FOUND" (Just "elm.json")
210 Help.report "MODULE NOT FOUND" (Just "elm.json")
212 "Your elm.json says your project has the following module:"
211 "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
214 , D.reflow $
213 , D.reflow $
215 "When creating packages, all modules must live in the src/ directory."
214 "When creating packages, all modules must live in the src/ directory."
218 File path ->
217 File path ->
219 Help.report "UNKNOWN IMPORT" (Just path)
218 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.")
221 (notFoundDetails child srcDirs)
220 (notFoundDetails child srcDirs)
223 Module path parent ->
222 Module path parent ->
224 Help.report "UNKNOWN IMPORT" (Just path)
223 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:")
226 (notFoundDetails child srcDirs)
225 (notFoundDetails child srcDirs)
@@ -230,26 +229,26 @@ notFoundDetails :: ModuleName.Raw -> SrcDirs -> [D.Doc]
230notFoundDetails child srcDirs =
229notFoundDetails child srcDirs =
232 simulatedCode =
231 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
235 case Map.lookup child Pkg.suggestions of
234 case Map.lookup child Pkg.suggestions of
236 Just pkg ->
235 Just pkg ->
237 [ simulatedCode
236 [ simulatedCode
238 , D.reflow $
237 , D.reflow $
239− "Do you want the one from the " ++ Pkg.toString pkg
238+ "Do you want the one from the " ++ Pkg.toChars pkg
240 ++ " package? If so, run this command to add that dependency to your elm.json file:"
239 ++ " 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
242 , case srcDirs of
241 , case srcDirs of
244 D.reflow $
243 D.reflow $
245 "If you want a local file, make sure the `"
244 "If you want a local file, make sure the `"
246− ++ ModuleName.nameToString child
245+ ++ ModuleName.nameToChars child
247 ++ "` module is in your src/ directory."
246 ++ "` module is in your src/ directory."
250 D.reflow $
249 D.reflow $
251 "If you want a local file, make sure the `"
250 "If you want a local file, make sure the `"
252− ++ ModuleName.nameToString child
251+ ++ ModuleName.nameToChars child
253 ++ "` module is in one of the \"source-directories\" listed in your elm.json file."
252 ++ "` module is in one of the \"source-directories\" listed in your elm.json file."
@@ -279,15 +278,15 @@ ambiguousToDoc :: Origin -> ModuleName.Raw -> [FilePath] -> [Pkg.Canonical] -> H
279ambiguousToDoc origin child paths pkgs =
278ambiguousToDoc origin child paths pkgs =
281 pkgToString (Pkg.Canonical pkg vsn) =
280 pkgToString (Pkg.Canonical pkg vsn) =
282− "exposed by " ++ Pkg.toString pkg ++ " " ++ Pkg.versionToString vsn
281+ "exposed by " ++ Pkg.toChars pkg ++ " " ++ V.toChars vsn
284 makeReport maybePath summary yellowString =
283 makeReport maybePath summary yellowString =
285 Help.report "AMBIGUOUS IMPORT" maybePath summary
284 Help.report "AMBIGUOUS IMPORT" maybePath summary
286− [ D.indent 4 $ D.dullyellow $ D.fromString yellowString
285+ [ D.indent 4 $ D.dullyellow $ D.fromChars yellowString
287 , D.reflow $
286 , D.reflow $
288 "I found multiple module with that name though:"
287 "I found multiple module with that name though:"
289 , D.indent 4 $ D.dullyellow $ D.vcat $
288 , D.indent 4 $ D.dullyellow $ D.vcat $
290− map D.fromString $ paths ++ map pkgToString pkgs
289+ map D.fromChars $ paths ++ map pkgToString pkgs
291 , D.reflow $
290 , D.reflow $
292 if null paths then
291 if null paths then
293 "It looks like the name clash is in your dependencies, which is\
292 "It looks like the name clash is in your dependencies, which is\
@@ -303,19 +302,19 @@ ambiguousToDoc origin child paths pkgs =
303 makeReport
302 makeReport
305 "Your elm.json wants the following module:"
304 "Your elm.json wants the following module:"
306− (ModuleName.nameToString child)
305+ (ModuleName.nameToChars child)
308 File path ->
307 File path ->
309 makeReport
308 makeReport
310 (Just path)
309 (Just path)
311 ("The file at " ++ path ++ " has an ambiguous import:")
310 ("The file at " ++ path ++ " has an ambiguous import:")
312− ("import " ++ ModuleName.nameToString child)
311+ ("import " ++ ModuleName.nameToChars child)
314 Module path parent ->
313 Module path parent ->
315 makeReport
314 makeReport
316 (Just path)
315 (Just path)
317− ("The " ++ ModuleName.nameToString parent ++ " module has an ambiguous import:")
316+ ("The " ++ ModuleName.nameToChars parent ++ " module has an ambiguous import:")
318− ("import " ++ ModuleName.nameToString child)
317+ ("import " ++ ModuleName.nameToChars child)
321kernelNameToDoc :: Origin -> ModuleName.Raw -> Help.Report
320kernelNameToDoc :: Origin -> ModuleName.Raw -> Help.Report
@@ -335,11 +334,11 @@ kernelNameToDoc origin kernelName =
336 Module path parent ->
335 Module path parent ->
337 ( Just path
336 ( Just path
338− , "Your " ++ ModuleName.nameToString parent ++ " module is trying to import:"
337+ , "Your " ++ ModuleName.nameToChars parent ++ " module is trying to import:"
341 Help.report "BAD MODULE NAME" maybePath statement
340 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
343 , D.reflow $
342 , D.reflow $
344 "But names like that are reserved for internal use.\
343 "But names like that are reserved for internal use.\
345 \ Switch to a name outside of the Elm/Kernel/ namespace."
344 \ Switch to a name outside of the Elm/Kernel/ namespace."