@@ -1,27 +1,31 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2module Reporting.Exit
2module Reporting.Exit
3− ( Init(..), initToReport
6+ , initToReport
4− , Diff(..), diffToReport
9+ , diffToReport
5− , Make(..), makeToReport
10+ --
6− , Bump(..), bumpToReport
11+ , Install(..)
7− , Repl(..), replToReport
8− , Publish(..), publishToReport
9− , Install(..), installToReport
12+ , installToReport
10− , Reactor(..), reactorToReport
13 , Solver(..)
14 , Solver(..)
14 , Outline(..)
16 , Outline(..)
15 , OutlineProblem(..)
17 , OutlineProblem(..)
16 , Details(..)
19 , Details(..)
19 , RegistryProblem(..)
20 , RegistryProblem(..)
20 , BuildProblem(..)
24 , BuildProblem(..)
21 , BuildProjectProblem(..)
25 , BuildProjectProblem(..)
22− , DocsProblem(..)
26+ , makeToReport
25 , toString
29 , toString
26 , toStderr
30 , toStderr
@@ -29,56 +33,61 @@ module Reporting.Exit
32−import qualified Data.ByteString as BS
33−import qualified Data.ByteString.UTF8 as BS_UTF8
34import qualified Data.List as List
36import qualified Data.List as List
35−import qualified Data.Map as Map
36−import qualified Data.Name as N
37import qualified Data.NonEmptyList as NE
37import qualified Data.NonEmptyList as NE
38−import qualified Network.HTTP.Client as HTTP
38+import qualified Data.Utf8 as Utf8
39−import qualified Network.HTTP.Types.Header as HTTP
40−import qualified Network.HTTP.Types.Status as HTTP
41−import qualified System.FilePath as FP
42−import System.FilePath ((</>), (<.>))
44import qualified Elm.Constraint as C
40import qualified Elm.Constraint as C
45import qualified Elm.Magnitude as M
41import qualified Elm.Magnitude as M
46import qualified Elm.ModuleName as ModuleName
42import qualified Elm.ModuleName as ModuleName
47import qualified Elm.Package as Pkg
43import qualified Elm.Package as Pkg
48import qualified Elm.Version as V
44import qualified Elm.Version as V
50import qualified Http
45import qualified Http
51−import qualified Json.Decode as Decode
52import qualified Json.Encode as Encode
46import qualified Json.Encode as Encode
53−import qualified Json.String as Json
54−import Parse.Primitives (Row, Col)
55−import qualified Reporting.Annotation as A
56import Reporting.Doc ((<>))
47import Reporting.Doc ((<>))
57import qualified Reporting.Doc as D
48import qualified Reporting.Doc as D
58import qualified Reporting.Error.Import as Import
49import qualified Reporting.Error.Import as Import
59import qualified Reporting.Error.Json as Json
50import qualified Reporting.Error.Json as Json
60import qualified Reporting.Exit.Help as Help
51import qualified Reporting.Exit.Help as Help
61import qualified Reporting.Error as Error
52import qualified Reporting.Error as Error
62−import qualified Reporting.Render.Code as Code
69−toString :: Help.Report -> String
56+-- ALL POSSIBLE ERRORS
71− Help.toString (Help.reportToDoc report)
74−toStderr :: Help.Report -> IO ()
59+data Exit
75−toStderr report =
60+ -- bump
76− Help.toStderr (Help.reportToDoc report)
61+ = BumpApplication
62+ | BumpUnexpectedVersion V.Version [V.Version]
63+ | BumpMustHaveLatestRegistry RegistryProblem
64+ | BumpCannotFindDocs Pkg.Name V.Version DocsProblem
66+ | PublishMustHaveLatestRegistry RegistryProblem
68+ | PublishNotInitialVersion V.Version
69+ | PublishAlreadyPublished V.Version
70+ | PublishInvalidBump V.Version V.Version
71+ | PublishBadBump V.Version V.Version M.Magnitude V.Version M.Magnitude
77+ | PublishCannotGetTag Http.Error
78+ | PublishCannotGetZip Http.Error
79+ | PublishCannotDecodeZip
80+ | PublishCannotGetDocs DocsProblem
81+ | PublishCannotRegister Http.Error
82+ | PublishMissingTag V.Version
84+ | PublishLocalChanges V.Version
79−toJson :: Help.Report -> Encode.Value
87+data DocsProblem
80−toJson report =
88+ = DP_Http Http.Error
81− Help.reportToJson report
89+ | DP_Data
@@ -109,18 +118,13 @@ initToReport exit =
110 InitNoOfflineSolution pkgs ->
119 InitNoOfflineSolution pkgs ->
111 Help.report "NO OFFLINE SOLUTION" Nothing
120 Help.report "NO OFFLINE SOLUTION" Nothing
112− "I tried to create an elm.json with the following direct dependencies:"
121+ (error "TODO InitNoOfflineSolution" pkgs)
113− [ D.indent 4 $ D.vcat $
122+ (error "TODO InitNoOfflineSolution" pkgs)
114− map (D.dullyellow . D.fromChars . Pkg.toChars) pkgs
123+ -- note about Russia IP addresses?
115− , D.reflow $
124+ -- ask if they are on a plane or train
116− "I could not find compatible versions though, but that may be because I could not\
117− \ connect to https://package.elm-lang.org to get the latest list of packages. Are\
118− \ you able to connect to the internet? Please ask around one of the community\
119− \ forums at https://elm-lang.org/community for help!"
122 InitSolverProblem solver ->
126 InitSolverProblem solver ->
123− toSolverReport solver
127+ error "TODO InitSolverProblem" solver
125 InitAlreadyExists ->
129 InitAlreadyExists ->
126 Help.report "EXISTING PROJECT" Nothing
130 Help.report "EXISTING PROJECT" Nothing
@@ -131,9 +135,8 @@ initToReport exit =
134− InitRegistryProblem problem ->
138+ InitRegistryProblem _ ->
135− toRegistryProblemReport "PROBLEM LOADING PACKAGE LIST" problem $
139+ error "TODO InitRegistryProblem"
136− "I need the list of published packages before I can start initializing projects"
@@ -141,48 +144,22 @@ initToReport exit =
145− | DiffBadOutline Outline
146− | DiffApplication
147+ = DiffApplication
148 | DiffUnpublished
148 | DiffUnpublished
149 | DiffUnknownPackage Pkg.Name [Pkg.Name]
149 | DiffUnknownPackage Pkg.Name [Pkg.Name]
150 | DiffUnknownVersion Pkg.Name V.Version [V.Version]
150 | DiffUnknownVersion Pkg.Name V.Version [V.Version]
151− | DiffDocsProblem V.Version DocsProblem
151+ | DiffCannotFindDocs DocsProblem
152 | DiffMustHaveLatestRegistry RegistryProblem
152 | DiffMustHaveLatestRegistry RegistryProblem
153− | DiffBadDetails Details
154− | DiffBadBuild BuildProblem
157diffToReport :: Diff -> Help.Report
155diffToReport :: Diff -> Help.Report
158diffToReport diff =
156diffToReport diff =
159 case diff of
157 case diff of
161− Help.report "DIFF WHAT?" Nothing
162− "I cannot find an elm.json so I am not sure what you want me to diff.\
163− \ Normally you run `elm diff` from within a project!"
164− [ D.reflow $ "If you are just curious to see a diff, try running this command:"
165− , D.indent 4 $ D.green $ "elm diff elm/http 1.0.0 2.0.0"
168− DiffBadOutline outline ->
169− toOutlineReport outline
171 DiffApplication ->
158 DiffApplication ->
172− Help.report "CANNOT DIFF APPLICATIONS" (Just "elm.json")
159+ Help.report "CANNOT DIFF APPLICATIONS" Nothing
173− "Your elm.json says this project is an application, but `elm diff` only works\
160+ "I cannot perform diffs on applications, only packages! If you are\
174− \ with packages. That way there are previously published versions of the API to\
176− [ D.reflow $ "If you are just curious to see a diff, try running this command:"
161+ \ just curious to see a diff, try running this command:"
177− , D.indent 4 $ D.dullyellow $ "elm diff elm/json 1.0.0 1.1.2"
162+ [ D.indent 4 $ D.green $ "elm diff elm/html 5.1.1 6.0.0"
181− Help.report "NO EXPOSED MODULES" (Just "elm.json")
182− "Your elm.json has no \"exposed-modules\" which means there is no public API at\
183− \ all right now! What am I supposed to diff?"
185− "Try adding some modules back to the \"exposed-modules\" field."
188 DiffUnpublished ->
165 DiffUnpublished ->
@@ -194,16 +171,16 @@ diffToReport diff =
194 Help.report "UNKNOWN PACKAGE" Nothing
171 Help.report "UNKNOWN PACKAGE" Nothing
195 ( "I cannot find a package called:"
172 ( "I cannot find a package called:"
197− [ D.indent 4 $ D.red $ D.fromChars $ Pkg.toChars pkg
174+ [ D.indent 4 $ D.red $ D.fromUtf8 $ Pkg.toString pkg
198 , "Maybe you want one of these instead?"
175 , "Maybe you want one of these instead?"
199− , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromChars . Pkg.toChars) suggestions
176+ , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromUtf8 . Pkg.toString) suggestions
200 , "But check <https://package.elm-lang.org> to see all possibilities!"
177 , "But check <https://package.elm-lang.org> to see all possibilities!"
203 DiffUnknownVersion _pkg vsn realVersions ->
180 DiffUnknownVersion _pkg vsn realVersions ->
204 Help.docReport "UNKNOWN VERSION" Nothing
181 Help.docReport "UNKNOWN VERSION" Nothing
205 ( D.fillSep $
182 ( D.fillSep $
206− [ "Version", D.red (D.fromVersion vsn)
183+ [ "Version", D.red (D.fromUtf8 (V.toString vsn))
207 , "has", "never", "been", "published,", "so", "I"
184 , "has", "never", "been", "published,", "so", "I"
208 , "cannot", "diff", "against", "it."
185 , "cannot", "diff", "against", "it."
@@ -212,57 +189,232 @@ diffToReport diff =
212 , D.indent 4 $ D.dullyellow $ D.vcat $
189 , D.indent 4 $ D.dullyellow $ D.vcat $
214 sameMajor v1 v2 = V._major v1 == V._major v2
191 sameMajor v1 v2 = V._major v1 == V._major v2
215− mkRow vsns = D.hsep $ map D.fromVersion vsns
192+ mkRow vsns = D.hsep $ map (D.fromUtf8 . V.toString) vsns
217 map mkRow $ List.groupBy sameMajor (List.sort realVersions)
194 map mkRow $ List.groupBy sameMajor (List.sort realVersions)
218 , "Want one of those instead?"
195 , "Want one of those instead?"
221− DiffDocsProblem version problem ->
198+ DiffCannotFindDocs problem ->
222− toDocsProblemReport problem $
199+ error "TODO DiffCannotFindDocs" problem
223− "I need the docs for " ++ V.toChars version ++ " to compute this diff"
225 DiffMustHaveLatestRegistry problem ->
201 DiffMustHaveLatestRegistry problem ->
226− toRegistryProblemReport "PROBLEM UPDATING PACKAGE LIST" problem $
202+ error "TODO DiffMustHaveLatestRegistry" problem
227− "I need the latest list of published packages before I do this diff"
229− DiffBadDetails details ->
230− toDetailsReport details
232− DiffBadBuild buildProblem ->
233− toBuildProblemReport buildProblem
237−-- BUMP
209+data Install
211+ | InstallNoArgs FilePath
212+ | InstallNoOnlineSolution
213+ | InstallNoOfflineSolution
214+ | InstallHadSolverTrouble Solver
215+ | InstallUnknownPackageOnline [Pkg.Name]
216+ | InstallUnknownPackageOffline [Pkg.Name]
217+ | InstallHasBadDetails Details
240−data Bump
220+installToReport :: Install -> Help.Report
241− = BumpNoOutline
221+installToReport exit =
242− | BumpBadOutline Outline
222+ case exit of
243− | BumpApplication
223+ InstallNoProject ->
244− | BumpUnexpectedVersion V.Version [V.Version]
224+ Help.report "NEW PROJECT?" Nothing
245− | BumpMustHaveLatestRegistry RegistryProblem
225+ "Are you trying to start a new project? Try this command instead:"
246− | BumpCannotFindDocs Pkg.Name V.Version DocsProblem
226+ [ D.indent 4 $ D.green "elm init"
247− | BumpBadDetails Details
227+ , D.reflow "It will help you get started!"
248− | BumpNoExposed
228+ ]
249− | BumpBadBuild BuildProblem
230+ InstallNoArgs elmHome ->
231+ Help.report "INSTALL WHAT?" Nothing
232+ "I am expecting commands like:"
233+ [ D.green $ D.indent 4 $ D.vcat $
234+ [ "elm install elm/http"
235+ , "elm install elm/json"
236+ , "elm install elm/random"
239+ ["In","JavaScript","folks","run","`npm install`","to","start","projects."
240+ ,"\"Gotta","download","everything!\"","But","why","download","packages"
241+ ,"again","and","again?","Instead,","Elm","caches","packages","in"
242+ ,D.dullyellow (D.fromChars elmHome)
243+ ,"so","each","one","is","downloaded","and","built","ONCE","on","your","machine."
244+ ,"Elm","projects","check","that","cache","before","trying","the","internet."
245+ ,"This","reduces","build","times,","reduces","server","costs,","and","makes","it"
246+ ,"easier","to","work","offline.","As","a","result"
247+ ,D.dullcyan "elm install","is","only","for","adding","dependencies","to","elm.json,"
248+ ,"whereas",D.dullcyan "elm make","is","in","charge","of","gathering","dependencies"
249+ ,"and","building","everything.","So","maybe","try",D.green "elm make","instead?"
252−bumpToReport :: Bump -> Help.Report
253+ InstallNoOnlineSolution ->
253−bumpToReport bump =
254+ Help.report "UNSOLVABLE DEPENDENCIES" (Just "elm.json") -- TODO recommend using solver in `elm reactor`
254− case bump of
255+ "This usually happens if you try to modify dependency constraints by\
255− BumpNoOutline ->
256+ \ hand. I recommend deleting any dependency you added recently (or all\
256− Help.report "BUMP WHAT?" Nothing
257+ \ of them if things are bad) and then adding them again with:"
257− "I cannot find an elm.json so I am not sure what you want me to bump."
258+ [ D.indent 4 $ D.green "elm install"
258− [ D.reflow $
259+ , D.reflow $
259− "Elm packages always have an elm.json that says current the version number. If\
260+ "And do not be afaid to ask for help on Slack if you get stuck!"
260− \ you run this command from a directory with an elm.json file, I will try to bump\
261− \ the version in there based on the API changes."
264− BumpBadOutline outline ->
263+ InstallNoOfflineSolution ->
265− toOutlineReport outline
264+ error "TODO InstallNoOfflineSolution"
266+ InstallHadSolverTrouble solver ->
267+ error "TODO InstallHadSolverTrouble" solver
269+ InstallUnknownPackageOnline suggestions ->
270+ error "TODO InstallUnknownPackageOnline" suggestions
272+ InstallUnknownPackageOffline suggestions ->
273+ error "TODO InstallUnknownPackageOffline" suggestions
275+ InstallHasBadDetails _ ->
276+ error "TODO InstallHasBadDetails"
279+{- TODO detect if library has no 0.19.0 version. Maybe do this on website though?
280+ Help.report "OLD DEPENDENCIES" (Just "elm.json")
281+ ( "The following packages do not work with Elm " ++ V.toChars V.compiler ++ " right now:"
283+ [ D.indent 4 $ D.vcat $ map (D.red . D.fromUtf8 . Pkg.toString) badPackages
285+ "This may be because it is not upgraded yet. It may be because a\
286+ \ better solution came along, so there was no need to upgrade it.\
287+ \ Etc. Try asking around on Slack to learn more about the topic."
289+ "Whatever the case, please be kind to the relevant package authors! Having\
290+ \ friendly interactions with users is great motivation, and conversely, getting\
291+ \ berated by strangers on the internet sucks your soul dry. Furthermore, package\
292+ \ authors are humans with families, friends, jobs, vacations, responsibilities,\
293+ \ goals, etc. They face obstacles outside of their technical work you will never\
294+ \ know about, so please assume the best and try to be patient and supportive!"
304+ = SolverBadCacheData Pkg.Name V.Version
305+ | SolverBadHttpData Pkg.Name V.Version
306+ | SolverBadHttp Http.Error
314+ = OutlineHasBadStructure (Json.Error OutlineProblem)
315+ | OutlineHasBadSrcDirs FilePath [FilePath]
319+ = OP_BadType Utf8.String
320+ | OP_BadPkgName Pkg.BadName
321+ | OP_BadVersion Utf8.String
322+ | OP_BadConstraint C.Error
323+ | OP_BadModuleName Utf8.String
324+ | OP_BadModuleHeaderTooLong Utf8.String
325+ | OP_BadDependencyName Utf8.String
326+ | OP_BadLicense Utf8.String [Utf8.String]
327+ | OP_BadSummaryTooLong
338+ | DetailsNoOfflineSolution
339+ | DetailsSolverProblem Solver
340+ | DetailsBadElmInPkg C.Constraint
341+ | DetailsBadElmInAppOutline V.Version
342+ | DetailsHandEditedDependencies
343+ | DetailsBadOutline Outline
344+ | DetailsCannotGetRegistry RegistryProblem
345+ | DetailsCannotBuildPackage Pkg.Name V.Version PackageProblem
349+ = RP_Http Http.Error
354+ = PP_BadEndpointRequest Http.Error
355+ | PP_BadEndpointContent
356+ | PP_BadArchiveRequest Http.Error
357+ | PP_BadArchiveContent
358+ | PP_BadArchiveHash String String
367+ | MakeCannotOptimizeAndDebug
368+ | MakeBlockedByDetailsProblem Details
369+ | MakeAppNeedsFileNames
370+ | MakePkgNeedsExposing
371+ | MakeMultipleFilesIntoHtml
372+ | MakeNonMainFilesIntoJavaScript ModuleName.Raw [ModuleName.Raw]
373+ | MakeCannotOptimizeDebugValues ModuleName.Raw [ModuleName.Raw]
374+ | MakeCannotBuild BuildProblem
375+ | MakeCannotLoadArtifacts
379+ = BuildModuleProblems Error.Module [Error.Module]
380+ | BuildProjectProblem BuildProjectProblem
383+data BuildProjectProblem
384+ = BP_PathUnknown FilePath
385+ | BP_WithBadExtension FilePath
386+ | BP_WithAmbiguousSrcDir FilePath FilePath
387+ | BP_MainPathDuplicate FilePath FilePath
388+ | BP_MainNameDuplicate ModuleName.Raw FilePath FilePath
389+ | BP_CannotLoadDependencies
390+ | BP_Cycle ModuleName.Raw [ModuleName.Raw]
391+ | BP_MissingExposed (NE.List (ModuleName.Raw, Import.Problem))
398+toString :: Help.Report -> String
400+ Help.toString (Help.reportToDoc report)
403+toStderr :: Help.Report -> IO ()
405+ Help.toStderr (Help.reportToDoc report)
408+toJson :: Help.Report -> Encode.Value
410+ Help.reportToJson report
413+_toReport :: Exit -> Help.Report
267 BumpApplication ->
419 BumpApplication ->
268 Help.report "CANNOT BUMP APPLICATIONS" (Just "elm.json")
420 Help.report "CANNOT BUMP APPLICATIONS" (Just "elm.json")
@@ -274,7 +426,7 @@ bumpToReport bump =
274 Help.docReport "CANNOT BUMP" (Just "elm.json")
426 Help.docReport "CANNOT BUMP" (Just "elm.json")
275 ( D.fillSep
427 ( D.fillSep
276 ["Your","elm.json","says","I","should","bump","relative","to","version"
428 ["Your","elm.json","says","I","should","bump","relative","to","version"
277− ,D.red (D.fromVersion vsn) <> ","
429+ ,D.red (D.fromUtf8 (V.toString vsn)) <> ","
278 ,"but","I","cannot","find","that","version","on","<https://package.elm-lang.org>."
430 ,"but","I","cannot","find","that","version","on","<https://package.elm-lang.org>."
279 ,"That","means","there","is","no","API","for","me","to","diff","against","and"
431 ,"That","means","there","is","no","API","for","me","to","diff","against","and"
280 ,"figure","out","if","these","are","MAJOR,","MINOR,","or","PATCH","changes."
432 ,"figure","out","if","these","are","MAJOR,","MINOR,","or","PATCH","changes."
@@ -283,116 +435,19 @@ bumpToReport bump =
283 [ D.fillSep $
435 [ D.fillSep $
284 ["Try","bumping","again","after","changing","the",D.dullyellow "\"version\"","in","elm.json"]
436 ["Try","bumping","again","after","changing","the",D.dullyellow "\"version\"","in","elm.json"]
285 ++ if length versions == 1 then ["to:"] else ["to","one","of","these:"]
437 ++ if length versions == 1 then ["to:"] else ["to","one","of","these:"]
286− , D.vcat $ map (D.green . D.fromVersion) versions
438+ , D.vcat $ map (D.green . D.fromUtf8 . V.toString) versions
289 BumpMustHaveLatestRegistry problem ->
441 BumpMustHaveLatestRegistry problem ->
290− toRegistryProblemReport "PROBLEM UPDATING PACKAGE LIST" problem $
442+ error "TODO BumpMustHaveLatestRegistry" problem
291− "I need the latest list of published packages before I can bump any versions"
293− BumpCannotFindDocs _ version problem ->
294− toDocsProblemReport problem $
295− "I need the docs for " ++ V.toChars version ++ " to compute the next version number"
297− BumpBadDetails details ->
298− toDetailsReport details
301− Help.docReport "NO EXPOSED MODULES" (Just "elm.json")
303− [ "To", "bump", "a", "package,", "the"
304− , D.dullyellow "\"exposed-modules\"", "field", "of", "your"
305− , "elm.json", "must", "list", "at", "least", "one", "module."
309− "Try adding some modules back to the \"exposed-modules\" field."
312− BumpBadBuild problem ->
313− toBuildProblemReport problem
317−-- OVERVIEW OF VERSIONING
320−newPackageOverview :: String
323− [ "This package has never been published before. Here's how things work:"
325− , " - Versions all have exactly three parts: MAJOR.MINOR.PATCH"
327− , " - All packages start with initial version " ++ V.toChars V.one
329− , " - Versions are incremented based on how the API changes:"
331− , " PATCH = the API is the same, no risk of breaking code"
332− , " MINOR = values have been added, existing values are unchanged"
333− , " MAJOR = existing values have been changed or removed"
335− , " - I will bump versions for you, automatically enforcing these rules"
346− | PublishBadOutline Outline
347− | PublishBadDetails Details
348− | PublishMustHaveLatestRegistry RegistryProblem
349− | PublishApplication
350− | PublishNotInitialVersion V.Version
351− | PublishAlreadyPublished V.Version
352− | PublishInvalidBump V.Version V.Version
353− | PublishBadBump V.Version V.Version M.Magnitude V.Version M.Magnitude
357− | PublishShortReadme
359− | PublishBuildProblem BuildProblem
360− | PublishMissingTag V.Version
361− | PublishCannotGetTag V.Version Http.Error
362− | PublishCannotGetTagData V.Version String BS.ByteString
363− | PublishCannotGetZip Http.Error
364− | PublishCannotDecodeZip String
365− | PublishCannotGetDocs V.Version V.Version DocsProblem
366− | PublishCannotRegister Http.Error
368− | PublishLocalChanges V.Version
370− | PublishZipBadDetails Details
371− | PublishZipApplication
372− | PublishZipNoExposed
373− | PublishZipBuildProblem BuildProblem
376−publishToReport :: Publish -> Help.Report
377−publishToReport publish =
380− Help.report "PUBLISH WHAT?" Nothing
381− "I cannot find an elm.json so I am not sure what you want me to publish."
383− "Elm packages always have an elm.json that states the version number,\
384− \ dependencies, exposed modules, etc."
387− PublishBadOutline outline ->
444+ BumpCannotFindDocs name version problem ->
388− toOutlineReport outline
445+ error "TODO BumpCannotFindDocs" name version problem
390− PublishBadDetails problem ->
447+ -- publish
391− toDetailsReport problem
393 PublishMustHaveLatestRegistry problem ->
449 PublishMustHaveLatestRegistry problem ->
394− toRegistryProblemReport "PROBLEM UPDATING PACKAGE LIST" problem $
450+ error "TODO PublishMustHaveLatestRegistry" problem
395− "I need the latest list of published packages to make sure this is safe to publish"
397 PublishApplication ->
452 PublishApplication ->
398 Help.report "UNPUBLISHABLE" Nothing "I cannot publish applications, only packages!" []
453 Help.report "UNPUBLISHABLE" Nothing "I cannot publish applications, only packages!" []
@@ -401,7 +456,7 @@ publishToReport publish =
401 Help.docReport "INVALID VERSION" Nothing
456 Help.docReport "INVALID VERSION" Nothing
402 ( D.fillSep
457 ( D.fillSep
403 ["I","cannot","publish"
458 ["I","cannot","publish"
404− ,D.red (D.fromVersion vsn)
459+ ,D.red (D.fromUtf8 (V.toString vsn))
405 ,"as","the","initial","version."
460 ,"as","the","initial","version."
@@ -415,7 +470,7 @@ publishToReport publish =
415 Help.docReport "ALREADY PUBLISHED" Nothing
470 Help.docReport "ALREADY PUBLISHED" Nothing
417 [ D.fillSep
472 [ D.fillSep
418− [ "Version", D.green (D.fromVersion vsn)
473+ [ "Version", D.green (D.fromUtf8 (V.toString vsn))
419 , "has", "already", "been", "published.", "You", "cannot"
474 , "has", "already", "been", "published.", "You", "cannot"
420 , "publish", "it", "again!"
475 , "publish", "it", "again!"
@@ -432,14 +487,14 @@ publishToReport publish =
432 Help.docReport "INVALID VERSION" (Just "elm.json")
487 Help.docReport "INVALID VERSION" (Just "elm.json")
433 ( D.fillSep $
488 ( D.fillSep $
434 ["Your","elm.json","says","the","next","version","should","be"
489 ["Your","elm.json","says","the","next","version","should","be"
435− ,D.red (D.fromVersion statedVersion) <> ","
490+ ,D.red (D.fromUtf8 (V.toString statedVersion)) <> ","
436 ,"but","that","is","not","valid","based","on","the","previously"
491 ,"but","that","is","not","valid","based","on","the","previously"
437 ,"published","versions."
492 ,"published","versions."
440 [ D.fillSep $
495 [ D.fillSep $
441 ["Change","the","version","back","to"
496 ["Change","the","version","back","to"
442− ,D.green (D.fromVersion latestVersion)
497+ ,D.green (D.fromUtf8 (V.toString latestVersion))
443 ,"which","is","the","most","recently","published","version."
498 ,"which","is","the","most","recently","published","version."
444 ,"From","there,","have","Elm","bump","the","version","by","running:"
499 ,"From","there,","have","Elm","bump","the","version","by","running:"
@@ -454,7 +509,7 @@ publishToReport publish =
455 D.fillSep $
510 D.fillSep $
456 ["Your","elm.json","says","the","next","version","should","be"
511 ["Your","elm.json","says","the","next","version","should","be"
457− ,D.red (D.fromVersion new) <> ","
512+ ,D.red (D.fromUtf8 (V.toString new)) <> ","
458 ,"indicating","a",D.fromChars (M.toChars magnitude)
513 ,"indicating","a",D.fromChars (M.toChars magnitude)
459 ,"change","to","the","public","API."
514 ,"change","to","the","public","API."
460 ,"This","does","not","match","the","API","diff","given","by:"
515 ,"This","does","not","match","the","API","diff","given","by:"
@@ -467,7 +522,7 @@ publishToReport publish =
467 ["This","command","says","this","is","a"
522 ["This","command","says","this","is","a"
468 ,D.fromChars (M.toChars realMagnitude)
523 ,D.fromChars (M.toChars realMagnitude)
469 ,"change,","so","the","next","version","should","be"
524 ,"change,","so","the","next","version","should","be"
470− ,D.green (D.fromVersion realNew) <> "."
525+ ,D.green (D.fromUtf8 (V.toString realNew)) <> "."
471 ,"Double","check","everything","to","make","sure","you"
526 ,"Double","check","everything","to","make","sure","you"
472 ,"are","publishing","what","you","want!"
527 ,"are","publishing","what","you","want!"
@@ -497,17 +552,16 @@ publishToReport publish =
499 [ D.reflow $
554 [ D.reflow $
500− "Which modules do you want users of the package to have access to? Add their\
555+ "What is the point of a package that has no modules?!"
501− \ names to the \"exposed-modules\" list."
504 PublishNoReadme ->
558 PublishNoReadme ->
505− toBadReadmeReport "NO README" $
559+ badReadmeReport "NO README" $
506 "Every published package must have a helpful README.md\
560 "Every published package must have a helpful README.md\
507 \ file, but I do not see one in your project."
561 \ file, but I do not see one in your project."
509 PublishShortReadme ->
563 PublishShortReadme ->
510− toBadReadmeReport "SHORT README" $
564+ badReadmeReport "SHORT README" $
511 "This README.md is too short. Having more details will help\
565 "This README.md is too short. Having more details will help\
512 \ people assess your package quickly and fairly."
566 \ people assess your package quickly and fairly."
@@ -524,8 +578,20 @@ publishToReport publish =
524 \ named LICENSE. Add that file and you will be all set!"
578 \ named LICENSE. Add that file and you will be all set!"
527− PublishBuildProblem buildProblem ->
581+ PublishCannotGetTag httpError ->
528− toBuildProblemReport buildProblem
582+ error "TODO PublishCannotGetTag" httpError
584+ PublishCannotGetZip httpError ->
585+ error "TODO PublishCannotGetZip" httpError
587+ PublishCannotDecodeZip ->
588+ error "TODO PublishCannotDecodeZip"
590+ PublishCannotGetDocs docsProblem ->
591+ error "TODO PublishCannotGetDocs" docsProblem
593+ PublishCannotRegister httpError ->
594+ error "TODO PublishCannotRegister" httpError
530 PublishMissingTag version ->
596 PublishMissingTag version ->
531 let vsn = V.toChars version in
597 let vsn = V.toChars version in
@@ -546,70 +612,6 @@ publishToReport publish =
546 , "The -m flag is for a helpful message. Try to make it more informative!"
612 , "The -m flag is for a helpful message. Try to make it more informative!"
549− PublishCannotGetTag version httpError ->
551− Http.BadHttp _ (HTTP.StatusCodeException response _)
552− | HTTP.statusCode (HTTP.responseStatus response) == 404 ->
553− let vsn = V.toChars version in
554− Help.report "NO TAG ON GITHUB" Nothing
555− ("You have version " ++ vsn ++ " tagged locally, but not on GitHub.")
557− "Run the following command to make this tag available on GitHub:"
558− , D.indent 4 $ D.dullyellow $ D.fromChars $
559− "git push origin " ++ vsn
561− "This will make it possible to find your code online based on the version number."
565− toHttpErrorReport "PROBLEM VERIFYING TAG" httpError
566− "I need to check that the version tag is registered on GitHub"
568− PublishCannotGetTagData version url body ->
569− Help.report "PROBLEM VERIFYING TAG" Nothing
570− ("I need to check that version " ++ V.toChars version ++ " is tagged on GitHub, so I fetched:")
571− [ D.indent 4 $ D.dullyellow $ D.fromChars url
573− "I got the data back, but it was not what I was expecting. The response\
574− \ body contains " ++ show (BS.length body) ++ " bytes. Here is the "
575− ++ if BS.length body <= 76 then "whole thing:" else "beginning:"
576− , D.indent 4 $ D.dullyellow $ D.fromChars $
577− if BS.length body <= 76
578− then BS_UTF8.toString body
579− else take 73 (BS_UTF8.toString body) ++ "..."
581− "Does this error keep showing up? Maybe there is something weird with your\
582− \ internet connection. We have gotten reports that schools, businesses,\
583− \ airports, etc. sometimes intercept requests and add things to the body\
584− \ or change its contents entirely. Could that be the problem?"
587− PublishCannotGetZip httpError ->
588− toHttpErrorReport "PROBLEM DOWNLOADING CODE" httpError $
589− "I need to check that folks can download and build the source code when they\
590− \ install this package"
592− PublishCannotDecodeZip url ->
593− Help.report "PROBLEM DOWNLOADING CODE" Nothing
594− "I need to check that folks can download and build the source code when they\
595− \ install this package, so I downloaded the code from:"
596− [ D.indent 4 $ D.dullyellow $ D.fromChars url
598− "I was unable to unzip the archive though. Maybe there is something weird with\
599− \ your internet connection. We have gotten reports that schools, businesses,\
600− \ airports, etc. sometimes intercept requests and add things to the body or\
601− \ change its contents entirely. Could that be the problem?"
604− PublishCannotGetDocs old new docsProblem ->
605− toDocsProblemReport docsProblem $
606− "I need the docs for " ++ V.toChars old ++ " to verify that "
607− ++ V.toChars new ++ " really does come next"
609− PublishCannotRegister httpError ->
610− toHttpErrorReport "PROBLEM PUBLISHING PACKAGE" httpError $
611− "I need to send information about your package to the package website"
613 PublishNoGit ->
615 PublishNoGit ->
614 Help.report "NO GIT" Nothing
616 Help.report "NO GIT" Nothing
615 "I searched your PATH environment variable for `git` and could not\
617 "I searched your PATH environment variable for `git` and could not\
@@ -639,21 +641,9 @@ publishToReport publish =
639 ++ vsn ++ "` and publish your code from there."
641 ++ vsn ++ "` and publish your code from there."
642− PublishZipBadDetails _ ->
645− PublishZipApplication ->
648− PublishZipNoExposed ->
651− PublishZipBuildProblem _ ->
655−toBadReadmeReport :: String -> String -> Help.Report
645+badReadmeReport :: String -> String -> Help.Report
656−toBadReadmeReport title summary =
646+badReadmeReport title summary =
657 Help.report title (Just "README.md") summary
647 Help.report title (Just "README.md") summary
658 [ D.reflow $
648 [ D.reflow $
659 "When people look at your README, they are wondering:"
649 "When people look at your README, they are wondering:"
@@ -666,653 +656,32 @@ toBadReadmeReport title summary =
666 \ most common usage scenario. Show people what they can expect if\
656 \ most common usage scenario. Show people what they can expect if\
667 \ they learn more!"
657 \ they learn more!"
668 , D.toSimpleNote $
658 , D.toSimpleNote $
669− "By publishing your package, you are inviting people to invest time in\
659+ "By publishing your package, you are inviting people to invest time\
670− \ understanding your work. Spending an hour on your README to communicate your\
660+ \ in understanding your work. Spending an hour to communicate your\
671− \ knowledge more clearly can save the community days or weeks of time in\
661+ \ knowledge more clearly can save the community days or weeks of time\
672− \ aggregate, and saving time in aggregate is the whole point of publishing\
662+ \ in aggregate, and saving time in aggregate is the whole point of\
673− \ packages! People really appreciate it, and it makes the whole ecosystem feel\
663+ \ publishing packages! People really appreciate it, and it makes the\
674− \ nicer!"
664+ \ whole ecosystem feel nicer!"
678−badZipReport :: Help.Report
680− Help.report "PROBLEM VERIFYING PACKAGE" Nothing
681− "Before publishing packages, I download the code from GitHub and try to build it\
682− \ from scratch. That way I can be more confident that it will work for other\
683− \ people too. But I am not able to build it!"
685− "I was just able to build your local copy though. Is there some way the version\
686− \ on GitHub could be different?"
691−-- DOCS
669+-- DETAILS TO REPORT
695− = DP_Http Http.Error
696− | DP_Data String BS.ByteString
700−toDocsProblemReport :: DocsProblem -> String -> Help.Report
701−toDocsProblemReport problem context =
703− DP_Http httpError ->
704− toHttpErrorReport "PROBLEM LOADING DOCS" httpError context
707− Help.report "PROBLEM LOADING DOCS" Nothing (context ++ ", so I fetched:")
708− [ D.indent 4 $ D.dullyellow $ D.fromChars url
710− "I got the data back, but it was not what I was expecting. The response\
711− \ body contains " ++ show (BS.length body) ++ " bytes. Here is the "
712− ++ if BS.length body <= 76 then "whole thing:" else "beginning:"
713− , D.indent 4 $ D.dullyellow $ D.fromChars $
714− if BS.length body <= 76
715− then BS_UTF8.toString body
716− else take 73 (BS_UTF8.toString body) ++ "..."
718− "Does this error keep showing up? Maybe there is something weird with your\
719− \ internet connection. We have gotten reports that schools, businesses,\
720− \ airports, etc. sometimes intercept requests and add things to the body\
721− \ or change its contents entirely. Could that be the problem?"
725− Help.report "PROBLEM LOADING DOCS" Nothing (context ++ ", but the local copy seems to be corrupted.")
727− "I deleted the cached version, so the next run should download a fresh copy of\
728− \ the docs. Hopefully that will get you unstuck, but it will not resolve the root\
729− \ problem if, for example, a 3rd party editor plugin is modifing cached files\
740− | InstallBadOutline Outline
741− | InstallBadRegistry RegistryProblem
742− | InstallNoArgs FilePath
743− | InstallNoOnlineAppSolution Pkg.Name
744− | InstallNoOfflineAppSolution Pkg.Name
745− | InstallNoOnlinePkgSolution Pkg.Name
746− | InstallNoOfflinePkgSolution Pkg.Name
747− | InstallHadSolverTrouble Solver
748− | InstallUnknownPackageOnline Pkg.Name [Pkg.Name]
749− | InstallUnknownPackageOffline Pkg.Name [Pkg.Name]
750− | InstallBadDetails Details
753−installToReport :: Install -> Help.Report
754−installToReport exit =
757− Help.report "NEW PROJECT?" Nothing
758− "Are you trying to start a new project? Try this command instead:"
759− [ D.indent 4 $ D.green "elm init"
760− , D.reflow "It will help you get started!"
763− InstallBadOutline outline ->
764− toOutlineReport outline
766− InstallBadRegistry problem ->
767− toRegistryProblemReport "PROBLEM LOADING PACKAGE LIST" problem $
768− "I need the list of published packages to figure out how to install things"
770− InstallNoArgs elmHome ->
771− Help.report "INSTALL WHAT?" Nothing
772− "I am expecting commands like:"
773− [ D.green $ D.indent 4 $ D.vcat $
774− [ "elm install elm/http"
775− , "elm install elm/json"
776− , "elm install elm/random"
779− ["In","JavaScript","folks","run","`npm install`","to","start","projects."
780− ,"\"Gotta","download","everything!\"","But","why","download","packages"
781− ,"again","and","again?","Instead,","Elm","caches","packages","in"
782− ,D.dullyellow (D.fromChars elmHome)
783− ,"so","each","one","is","downloaded","and","built","ONCE","on","your","machine."
784− ,"Elm","projects","check","that","cache","before","trying","the","internet."
785− ,"This","reduces","build","times,","reduces","server","costs,","and","makes","it"
786− ,"easier","to","work","offline.","As","a","result"
787− ,D.dullcyan "elm install","is","only","for","adding","dependencies","to","elm.json,"
788− ,"whereas",D.dullcyan "elm make","is","in","charge","of","gathering","dependencies"
789− ,"and","building","everything.","So","maybe","try",D.green "elm make","instead?"
793− InstallNoOnlineAppSolution pkg ->
794− Help.report "CANNOT FIND COMPATIBLE VERSION" (Just "elm.json")
796− "I cannot find a version of " ++ Pkg.toChars pkg ++ " that is compatible\
797− \ with your existing dependencies."
800− "I checked all the published versions. When that failed, I tried to find any\
801− \ compatible combination of these packages, even if it meant changing all your\
802− \ existing dependencies! That did not work either!"
804− "This is most likely to happen when a package is not upgraded yet. Maybe a new\
805− \ version of Elm came out recently? Maybe a common package was changed recently?\
806− \ Maybe a better package came along, so there was no need to upgrade this one?\
807− \ Try asking around https://elm-lang.org/community to learn what might be going on\
808− \ with this package."
810− "Whatever the case, please be kind to the relevant package authors! Having\
811− \ friendly interactions with users is great motivation, and conversely, getting\
812− \ berated by strangers on the internet sucks your soul dry. Furthermore, package\
813− \ authors are humans with families, friends, jobs, vacations, responsibilities,\
814− \ goals, etc. They face obstacles outside of their technical work you will never\
815− \ know about, so please assume the best and try to be patient and supportive!"
818− InstallNoOfflineAppSolution pkg ->
819− Help.report "CANNOT FIND COMPATIBLE VERSION LOCALLY" (Just "elm.json")
821− "I cannot find a version of " ++ Pkg.toChars pkg ++ " that is compatible\
822− \ with your existing dependencies."
825− "I was not able to connect to https://package.elm-lang.org/ though, so I was only\
826− \ able to look through packages that you have downloaded in the past."
828− "Try again later when you have internet!"
831− InstallNoOnlinePkgSolution pkg ->
832− Help.report "CANNOT FIND COMPATIBLE VERSION" (Just "elm.json")
834− "I cannot find a version of " ++ Pkg.toChars pkg ++ " that is compatible\
835− \ with your existing constraints."
838− "With applications, I try to broaden the constraints to see if anything works,\
839− \ but messing with package constraints is much more delicate business. E.g. making\
840− \ your constraints stricter may make it harder for applications to find compatible\
841− \ dependencies. So fixing something here may break it for a lot of other people!"
843− "So I recommend making an application with the same dependencies as your package.\
844− \ See if there is a solution at all. From there it may be easier to figure out\
845− \ how to proceed in a way that will disrupt your users as little as possible. And\
846− \ the solution may be to help other package authors to get their packages updated,\
847− \ or to drop a dependency entirely."
850− InstallNoOfflinePkgSolution pkg ->
851− Help.report "CANNOT FIND COMPATIBLE VERSION LOCALLY" (Just "elm.json")
853− "I cannot find a version of " ++ Pkg.toChars pkg ++ " that is compatible\
854− \ with your existing constraints."
857− "I was not able to connect to https://package.elm-lang.org/ though, so I was only\
858− \ able to look through packages that you have downloaded in the past."
860− "Try again later when you have internet!"
863− InstallHadSolverTrouble solver ->
864− toSolverReport solver
866− InstallUnknownPackageOnline pkg suggestions ->
867− Help.docReport "UNKNOWN PACKAGE" Nothing
870− ["I","cannot","find","a","package","named",D.red (D.fromPackage pkg) <> "."]
873− "I looked through https://package.elm-lang.org for packages with similar names\
875− , D.indent 4 $ D.dullyellow $ D.vcat $ map D.fromPackage suggestions
876− , D.reflow $ "Maybe you want one of these instead?"
879− InstallUnknownPackageOffline pkg suggestions ->
880− Help.docReport "UNKNOWN PACKAGE" Nothing
883− ["I","cannot","find","a","package","named",D.red (D.fromPackage pkg) <> "."]
886− "I could not connect to https://package.elm-lang.org though, so new packages may\
887− \ have been published since I last updated my local cache of package names."
889− "Looking through the locally cached names, the closest ones are:"
890− , D.indent 4 $ D.dullyellow $ D.vcat $ map D.fromPackage suggestions
891− , D.reflow $ "Maybe you want one of these instead?"
894− InstallBadDetails details ->
895− toDetailsReport details
903− = SolverBadCacheData Pkg.Name V.Version
904− | SolverBadHttpData Pkg.Name V.Version String
905− | SolverBadHttp Pkg.Name V.Version Http.Error
908−toSolverReport :: Solver -> Help.Report
909−toSolverReport problem =
911− SolverBadCacheData pkg vsn ->
912− Help.report "PROBLEM SOLVING PACKAGE CONSTRAINTS" Nothing
914− "I need the elm.json of " ++ Pkg.toChars pkg ++ " " ++ V.toChars vsn ++ " to\
915− \ help me search for a set of compatible packages. I had it cached locally, but\
916− \ it looks like the file was corrupted!"
919− "I deleted the cached version, so the next run should download a fresh copy.\
920− \ Hopefully that will get you unstuck, but it will not resolve the root\
921− \ problem if a 3rd party tool is modifing cached files for some reason."
924− SolverBadHttpData pkg vsn url ->
925− Help.report "PROBLEM SOLVING PACKAGE CONSTRAINTS" Nothing
927− "I need the elm.json of " ++ Pkg.toChars pkg ++ " " ++ V.toChars vsn ++ " to\
928− \ help me search for a set of compatible packages, but I ran into corrupted\
929− \ information from:"
931− [ D.indent 4 $ D.dullyellow $ D.fromChars url
933− "Is something weird with your internet connection. We have gotten reports that\
934− \ schools, businesses, airports, etc. sometimes intercept requests and add things\
935− \ to the body or change its contents entirely. Could that be the problem?"
938− SolverBadHttp pkg vsn httpError ->
939− toHttpErrorReport "PROBLEM SOLVING PACKAGE CONSTRAINTS" httpError $
940− "I need the elm.json of " ++ Pkg.toChars pkg ++ " " ++ V.toChars vsn
941− ++ " to help me search for a set of compatible packages"
949− = OutlineHasBadStructure (Decode.Error OutlineProblem)
950− | OutlineHasMissingSrcDirs FilePath [FilePath]
951− | OutlineHasDuplicateSrcDirs FilePath FilePath FilePath
959− | OP_BadPkgName Row Col
960− | OP_BadVersion Row Col
961− | OP_BadConstraint C.Error
962− | OP_BadModuleName Row Col
963− | OP_BadModuleHeaderTooLong
964− | OP_BadDependencyName Row Col
965− | OP_BadLicense Json.String [Json.String]
966− | OP_BadSummaryTooLong
970−toOutlineReport :: Outline -> Help.Report
971−toOutlineReport problem =
973− OutlineHasBadStructure decodeError ->
974− Json.toReport "elm.json" (Json.FailureToReport toOutlineProblemReport) decodeError $
975− Json.ExplicitReason "I ran into a problem with your elm.json file."
977− OutlineHasMissingSrcDirs dir dirs ->
980− Help.report "MISSING SOURCE DIRECTORY" (Just "elm.json")
981− "I need a valid elm.json file, but the \"source-directories\" field lists the following directory:"
982− [ D.indent 4 $ D.red $ D.fromChars dir
984− "I cannot find it though. Is it missing? Is there a typo?"
988− Help.report "MISSING SOURCE DIRECTORIES" (Just "elm.json")
989− "I need a valid elm.json file, but the \"source-directories\" field lists the following directories:"
990− [ D.indent 4 $ D.vcat $
991− map (D.red . D.fromChars) (dir:dirs)
993− "I cannot find them though. Are they missing? Are there typos?"
996− OutlineHasDuplicateSrcDirs canonicalDir dir1 dir2 ->
997− if dir1 == dir2 then
998− Help.report "REDUNDANT SOURCE DIRECTORIES" (Just "elm.json")
999− "I need a valid elm.json file, but the \"source-directories\" field lists the same directory twice:"
1000− [ D.indent 4 $ D.vcat $
1001− map (D.red . D.fromChars) [dir1,dir2]
1003− "Remove one of the entries!"
1006− Help.report "REDUNDANT SOURCE DIRECTORIES" (Just "elm.json")
1007− "I need a valid elm.json file, but the \"source-directories\" field has some redundant directories:"
1008− [ D.indent 4 $ D.vcat $
1009− map (D.red . D.fromChars) [dir1,dir2]
1011− "These are two different ways of refering to the same directory:"
1012− , D.indent 4 $ D.dullyellow $ D.fromChars canonicalDir
1014− "Remove one of the redundant entries from your \"source-directories\" field."
1017− OutlineNoPkgCore ->
1018− Help.report "MISSING DEPENDENCY" (Just "elm.json")
1019− "I need to see an \"elm/core\" dependency your elm.json file. The default imports\
1020− \ of `List` and `Maybe` do not work without it."
1022− "If you modified your elm.json by hand, try to change it back! And if you are\
1023− \ having trouble getting back to a working elm.json, it may be easier to find a\
1024− \ working package and start fresh with their elm.json file."
1027− OutlineNoAppCore ->
1028− Help.report "MISSING DEPENDENCY" (Just "elm.json")
1029− "I need to see an \"elm/core\" dependency your elm.json file. The default imports\
1030− \ of `List` and `Maybe` do not work without it."
1032− "If you modified your elm.json by hand, try to change it back! And if you are\
1033− \ having trouble getting back to a working elm.json, it may be easier to delete it\
1034− \ and use `elm init` to start fresh."
1037− OutlineNoAppJson ->
1038− Help.report "MISSING DEPENDENCY" (Just "elm.json")
1039− "I need to see an \"elm/json\" dependency your elm.json file. It helps me handle\
1040− \ flags and ports."
1042− "If you modified your elm.json by hand, try to change it back! And if you are\
1043− \ having trouble getting back to a working elm.json, it may be easier to delete it\
1044− \ and use `elm init` to start fresh."
1048−toOutlineProblemReport :: FilePath -> Code.Source -> Json.Context -> A.Region -> OutlineProblem -> Help.Report
1049−toOutlineProblemReport path source _ region problem =
1051− toHighlight row col =
1052− Just $ A.Region (A.Position row col) (A.Position row col)
1054− toSnippet title highlight pair =
1055− Help.jsonReport title (Just path) $
1056− Code.toSnippet source region highlight pair
1060− toSnippet "UNEXPECTED TYPE" Nothing
1062− "I got stuck while reading your elm.json file. I cannot handle a \"type\" like this:"
1064− ["Try","changing","the","\"type\"","to"
1065− ,D.green "\"application\"","or",D.green "\"package\"","instead."
1069− OP_BadPkgName row col ->
1070− toSnippet "INVALID PACKAGE NAME" (toHighlight row col)
1072− "I got stuck while reading your elm.json file. I ran into trouble with the package name:"
1075− ["Package","names","are","always","written","as"
1076− ,D.green "\"author/project\""
1077− ,"so","I","am","expecting","to","see","something","like:"
1079− , D.dullyellow $ D.indent 4 $ D.vcat $
1080− [ "\"mdgriffith/elm-ui\""
1081− , "\"w0rm/elm-physics\""
1082− , "\"Microsoft/elm-json-tree-view\""
1083− , "\"FordLabs/elm-star-rating\""
1084− , "\"1602/json-schema\""
1087− "The author name should match your GitHub name exactly, and the project name\
1088− \ needs to follow these rules:"
1089− , D.indent 4 $ D.vcat $
1090− [ "+--------------------------------------+-----------+-----------+"
1091− , "| RULE | BAD | GOOD |"
1092− , "+--------------------------------------+-----------+-----------+"
1093− , "| only lower case, digits, and hyphens | elm-HTTP | elm-http |"
1094− , "| no leading digits | 3D | elm-3d |"
1095− , "| no non-ASCII characters | elm-bjørn | elm-bear |"
1096− , "| no underscores | elm_ui | elm-ui |"
1097− , "| no double hyphens | elm--hash | elm-hash |"
1098− , "| no starting or ending hyphen | -elm-tar- | elm-tar |"
1099− , "+--------------------------------------+-----------+-----------+"
1102− "These rules only apply to the project name, so you should never need\
1103− \ to change your GitHub name!"
1107− OP_BadVersion row col ->
1108− toSnippet "PROBLEM WITH VERSION" (toHighlight row col)
1110− "I got stuck while reading your elm.json file. I was expecting a version number here:"
1112− ["I","need","something","like",D.green "\"1.0.0\"","or",D.green "\"2.0.4\""
1113− ,"that","explicitly","states","all","three","numbers!"
1117− OP_BadConstraint constraintError ->
1118− case constraintError of
1119− C.BadFormat row col ->
1120− toSnippet "PROBLEM WITH CONSTRAINT" (toHighlight row col)
1122− "I got stuck while reading your elm.json file. I do not understand this version constraint:"
1125− ["I","need","something","like",D.green "\"1.0.0 <= v < 2.0.0\""
1126− ,"that","explicitly","lists","the","lower","and","upper","bounds."
1129− "The spaces in there are required! Taking them out will confuse me. Adding\
1130− \ extra spaces confuses me too. I recommend starting with a valid example\
1131− \ and just changing the version numbers."
1135− C.InvalidRange before after ->
1136− if before == after then
1137− toSnippet "PROBLEM WITH CONSTRAINT" Nothing
1139− "I got stuck while reading your elm.json file. I ran into an invalid version constraint:"
1141− ["Elm","checks","that","all","package","APIs","follow","semantic","versioning,"
1142− ,"so","it","is","best","to","use","wide","constraints.","I","recommend"
1143− ,D.green $ "\"" <> D.fromVersion before <> " <= v < " <> D.fromVersion (V.bumpMajor after) <> "\""
1144− ,"since","it","is","guaranteed","that","breaking","API","changes","cannot"
1145− ,"happen","in","any","of","the","versions","in","that","range."
1150− toSnippet "PROBLEM WITH CONSTRAINT" Nothing
1152− "I got stuck while reading your elm.json file. I ran into an invalid version constraint:"
1154− ["Maybe","you","want","something","like"
1155− ,D.green $ "\"" <> D.fromVersion before <> " <= v < " <> D.fromVersion (V.bumpMajor before) <> "\""
1156− ,"instead?","Elm","checks","that","all","package","APIs","follow","semantic"
1157− ,"versioning,","so","it","is","guaranteed","that","breaking","API","changes"
1158− ,"cannot","happen","in","any","of","the","versions","in","that","range."
1162− OP_BadModuleName row col ->
1163− toSnippet "PROBLEM WITH MODULE NAME" (toHighlight row col)
1165− "I got stuck while reading your elm.json file. I was expecting a module name here:"
1167− ["I","need","something","like",D.green "\"Html.Events\""
1168− ,"or",D.green "\"Browser.Navigation\""
1169− ,"where","each","segment","starts","with","a","capital"
1170− ,"letter","and","the","segments","are","separated","by","dots."
1174− OP_BadModuleHeaderTooLong ->
1175− toSnippet "HEADER TOO LONG" Nothing
1177− "I got stuck while reading your elm.json file. This section header is too long:"
1180− ["I","need","it","to","be"
1181− ,D.green "under",D.green "20",D.green "bytes"
1182− ,"so","it","renders","nicely","on","the","package","website!"
1185− "I count the length in bytes, so using non-ASCII characters costs extra.\
1186− \ Please report your case at https://github.com/elm/compiler/issues if this seems\
1187− \ overly restrictive for your needs."
1191− OP_BadDependencyName row col ->
1192− toSnippet "PROBLEM WITH DEPENDENCY NAME" (toHighlight row col)
1194− "I got stuck while reading your elm.json file. There is something wrong with this dependency name:"
1197− ["Package","names","always","include","the","name","of","the","author,"
1198− ,"so","I","am","expecting","to","see","dependencies","like"
1199− ,D.dullyellow "\"mdgriffith/elm-ui\"","and"
1200− ,D.dullyellow "\"Microsoft/elm-json-tree-view\"" <> "."
1203− ["I","generally","recommend","finding","the","package","you","want","on"
1204− ,"the","package","website,","and","installing","it","with","the"
1205− ,D.green "elm install","command!"
1210− OP_BadLicense _ suggestions ->
1211− toSnippet "UNKNOWN LICENSE" Nothing
1213− "I got stuck while reading your elm.json file. I do not know about this type of license:"
1217− ["Elm","packages","generally","use"
1218− ,D.green "\"BSD-3-Clause\"","or",D.green "\"MIT\"" <> ","
1219− ,"but","I","accept","any","OSI","approved","SPDX","license."
1220− ,"Here","some","that","seem","close","to","what","you","wrote:"
1222− , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromChars . Json.toChars) suggestions
1224− "Check out https://spdx.org/licenses/ for the full list of options."
1228− OP_BadSummaryTooLong ->
1229− toSnippet "SUMMARY TOO LONG" Nothing
1231− "I got stuck while reading your elm.json file. Your \"summary\" is too long:"
1234− ["I","need","it","to","be"
1235− ,D.green "under",D.green "80",D.green "bytes"
1236− ,"so","it","renders","nicely","on","the","package","website!"
1239− "I count the length in bytes, so using non-ASCII characters costs extra.\
1240− \ Please report your case at https://github.com/elm/compiler/issues if this seems\
1241− \ overly restrictive for your needs."
1246− toSnippet "NO SOURCE DIRECTORIES" Nothing
1248− "I got stuck while reading your elm.json file. You do not have any \"source-directories\" listed here:"
1250− ["I","need","something","like",D.green "[\"src\"]"
1251− ,"so","I","know","where","to","look","for","your","modules!"
1261− = DetailsNoSolution
1262− | DetailsNoOfflineSolution
1263− | DetailsSolverProblem Solver
1264− | DetailsBadElmInPkg C.Constraint
1265− | DetailsBadElmInAppOutline V.Version
1266− | DetailsHandEditedDependencies
1267− | DetailsBadOutline Outline
1268− | DetailsCannotGetRegistry RegistryProblem
1269− | DetailsBadDeps FilePath [DetailsBadDep]
1273− = BD_BadDownload Pkg.Name V.Version PackageProblem
1274− | BD_BadBuild Pkg.Name V.Version (Map.Map Pkg.Name V.Version)
1277−toDetailsReport :: Details -> Help.Report
672+detailsToReport :: Details -> Help.Report
1278−toDetailsReport details =
673+detailsToReport details =
1279 case details of
674 case details of
1280− DetailsNoSolution ->
675+ DetailsCorrupt ->
1281− Help.report "INCOMPATIBLE DEPENDENCIES" (Just "elm.json")
676+ error "TODO DetailsCorrupt"
1282− "The dependencies in your elm.json are not compatible."
1284− ["Did","you","change","them","by","hand?","Try","to","change","it","back!"
1285− ,"It","is","much","more","reliable","to","add","dependencies","with",D.green "elm install" <> "."
1288− "Please ask for help on the community forums if you try those paths and are still\
1289− \ having problems!"
1292− DetailsNoOfflineSolution ->
1293− Help.report "TROUBLE VERIFYING DEPENDENCIES" (Just "elm.json")
1294− "I could not connect to https://package.elm-lang.org to get the latest list of\
1295− \ packages, and I was unable to verify your dependencies with the information I\
1296− \ have cached locally."
1298− "Are you able to connect to the internet? These dependencies may work once you\
1299− \ get access to the registry!"
1301− ["If","you","changed","your","dependencies","by","hand,","try","to","change","them","back!"
1302− ,"It","is","much","more","reliable","to","add","dependencies","with",D.green "elm install" <> "."
1306− DetailsSolverProblem solver ->
1307− toSolverReport solver
1309 DetailsBadElmInPkg constraint ->
678 DetailsBadElmInPkg constraint ->
1310 Help.report "ELM VERSION MISMATCH" (Just "elm.json")
679 Help.report "ELM VERSION MISMATCH" (Just "elm.json")
1311 "Your elm.json says this package needs a version of Elm in this range:"
680 "Your elm.json says this package needs a version of Elm in this range:"
1312− [ D.indent 4 $ D.dullyellow $ D.fromChars $ C.toChars constraint
681+ [ D.indent 4 $ D.dullyellow $ D.fromUtf8 $ C.toString constraint
1313 , D.fillSep
682 , D.fillSep
1314 [ "But", "you", "are", "using", "Elm"
683 [ "But", "you", "are", "using", "Elm"
1315− , D.red (D.fromVersion V.compiler)
684+ , D.red (D.fromUtf8 (V.toString V.compiler))
1316 , "right", "now."
685 , "right", "now."
@@ -1322,286 +691,40 @@ toDetailsReport details =
1322 "Your elm.json says this application needs a different version of Elm."
691 "Your elm.json says this application needs a different version of Elm."
1323 [ D.fillSep
692 [ D.fillSep
1324 [ "It", "requires"
693 [ "It", "requires"
1325− , D.green (D.fromVersion version) <> ","
694+ , D.green (D.fromUtf8 (V.toString version)) <> ","
1326 , "but", "you", "are", "using"
695 , "but", "you", "are", "using"
1327− , D.red (D.fromVersion V.compiler)
696+ , D.red (D.fromUtf8 (V.toString V.compiler))
1328 , "right", "now."
697 , "right", "now."
1332 DetailsHandEditedDependencies ->
701 DetailsHandEditedDependencies ->
1333− Help.report "ERROR IN DEPENDENCIES" (Just "elm.json")
702+ error "TODO DetailsHandEditedDependencies"
1334− "It looks like the dependencies elm.json in were edited by hand (or by a 3rd\
1335− \ party tool) leaving them in an invalid state."
1337− ["Try","to","change","them","back","to","what","they","were","before!"
1338− ,"It","is","much","more","reliable","to","add","dependencies","with",D.green "elm install" <> "."
1341− "Please ask for help on the community forums if you try those paths and are still\
1342− \ having problems!"
1345− DetailsBadOutline outline ->
704+ DetailsBadOutline problem ->
1346− toOutlineReport outline
705+ error "TODO DetailsBadOutline" problem
1348 DetailsCannotGetRegistry problem ->
707 DetailsCannotGetRegistry problem ->
1349− toRegistryProblemReport "PROBLEM LOADING PACKAGE LIST" problem $
708+ error "TODO DetailsCannotGetRegistry" problem
1350− "I need the list of published packages to verify your dependencies"
1352− DetailsBadDeps cacheDir deps ->
1353− case List.sortOn toBadDepRank deps of
1355− Help.report "PROBLEM BUILDING DEPENDENCIES" Nothing
1356− "I am not sure what is going wrong though."
1358− "I would try deleting the " ++ cacheDir ++ " and elm-stuff/ directories, then\
1359− \ trying to build again. That will work if some cached files got corrupted\
1362− "If that does not work, go to https://elm-lang.org/community and ask for\
1363− \ help. This is a weird case!"
1368− BD_BadDownload pkg vsn packageProblem ->
1369− toPackageProblemReport pkg vsn packageProblem
1371− BD_BadBuild pkg vsn fingerprint ->
1372− Help.report "PROBLEM BUILDING DEPENDENCIES" Nothing
1373− "I ran into a compilation error when trying to build the following package:"
1374− [ D.indent 4 $ D.red $ D.fromChars $ Pkg.toChars pkg ++ " " ++ V.toChars vsn
1376− "This probably means it has package constraints that are too wide. It may be\
1377− \ possible to tweak your elm.json to avoid the root problem as a stopgap. Head\
1378− \ over to https://elm-lang.org/community to get help figuring out how to take\
1381− "To help with the root problem, please report this to the package author along\
1382− \ with the following information:"
1383− , D.indent 4 $ D.vcat $
1384− map (\(p,v) -> D.fromChars $ Pkg.toChars p ++ " " ++ V.toChars v) $
1385− Map.toList fingerprint
1387− "If you want to help out even more, try building the package locally. That should\
1388− \ give you much more specific information about why this package is failing to\
1389− \ build, which will in turn make it easier for the package author to fix it!"
1393−toBadDepRank :: DetailsBadDep -> Int -- lower is better
1394−toBadDepRank badDep =
1396− BD_BadDownload _ _ _ -> 0
1397− BD_BadBuild _ _ _ -> 1
710+ DetailsCannotBuildPackage name version problem ->
711+ error "TODO DetailsCannotBuildPackage" name version problem
1401−-- PACKAGE PROBLEM
713+ DetailsNoSolution ->
1402−
714+ error "TODO DetailsNoSolution"
1405− = PP_BadEndpointRequest Http.Error
1406− | PP_BadEndpointContent String
1407− | PP_BadArchiveRequest Http.Error
1408− | PP_BadArchiveContent String
1409− | PP_BadArchiveHash String String String
1412−toPackageProblemReport :: Pkg.Name -> V.Version -> PackageProblem -> Help.Report
1413−toPackageProblemReport pkg vsn problem =
1416− Pkg.toChars pkg ++ " " ++ V.toChars vsn
1419− PP_BadEndpointRequest httpError ->
1420− toHttpErrorReport "PROBLEM DOWNLOADING PACKAGE" httpError $
1421− "I need to find the latest download link for " ++ thePackage
1423− PP_BadEndpointContent url ->
1424− Help.report "PROBLEM DOWNLOADING PACKAGE" Nothing
1426− "I need to find the latest download link for " ++ thePackage ++ ", but I ran into corrupted information from:"
1428− [ D.indent 4 $ D.dullyellow $ D.fromChars url
1430− "Is something weird with your internet connection. We have gotten reports that\
1431− \ schools, businesses, airports, etc. sometimes intercept requests and add things\
1432− \ to the body or change its contents entirely. Could that be the problem?"
1435− PP_BadArchiveRequest httpError ->
1436− toHttpErrorReport "PROBLEM DOWNLOADING PACKAGE" httpError $
1437− "I was trying to download the source code for " ++ thePackage
1439− PP_BadArchiveContent url ->
1440− Help.report "PROBLEM DOWNLOADING PACKAGE" Nothing
1442− "I downloaded the source code for " ++ thePackage ++ " from:"
1444− [ D.indent 4 $ D.dullyellow $ D.fromChars url
1446− "But I was unable to unzip the data. Maybe there is something weird with\
1447− \ your internet connection. We have gotten reports that schools, businesses,\
1448− \ airports, etc. sometimes intercept requests and add things to the body or\
1449− \ change its contents entirely. Could that be the problem?"
1452− PP_BadArchiveHash url expectedHash actualHash ->
1453− Help.report "CORRUPT PACKAGE DATA" Nothing
1455− "I downloaded the source code for " ++ thePackage ++ " from:"
1457− [ D.indent 4 $ D.dullyellow $ D.fromChars url
1458− , D.reflow "But it looks like the hash of the archive has changed since publication:"
1459− , D.vcat $ map D.fromChars $
1460− [ " Expected: " ++ expectedHash
1461− , " Actual: " ++ actualHash
1464− "This usually means that the package author moved the version\
1465− \ tag, so report it to them and see if that is the issue. Folks\
1466− \ on Elm slack can probably help as well."
1474−data RegistryProblem
1475− = RP_Http Http.Error
1476− | RP_Data String BS.ByteString
1479−toRegistryProblemReport :: String -> RegistryProblem -> String -> Help.Report
1480−toRegistryProblemReport title problem context =
1483− toHttpErrorReport title err context
1485− RP_Data url body ->
1486− Help.report title Nothing (context ++ ", so I fetched:")
1487− [ D.indent 4 $ D.dullyellow $ D.fromChars url
1489− "I got the data back, but it was not what I was expecting. The response\
1490− \ body contains " ++ show (BS.length body) ++ " bytes. Here is the "
1491− ++ if BS.length body <= 76 then "whole thing:" else "beginning:"
1492− , D.indent 4 $ D.dullyellow $ D.fromChars $
1493− if BS.length body <= 76
1494− then BS_UTF8.toString body
1495− else take 73 (BS_UTF8.toString body) ++ "..."
1497− "Does this error keep showing up? Maybe there is something weird with your\
1498− \ internet connection. We have gotten reports that schools, businesses,\
1499− \ airports, etc. sometimes intercept requests and add things to the body\
1500− \ or change its contents entirely. Could that be the problem?"
1504−toHttpErrorReport :: String -> Http.Error -> String -> Help.Report
1505−toHttpErrorReport title err context =
1507− toHttpReport intro url details =
1508− Help.report title Nothing intro $
1509− D.indent 4 (D.dullyellow (D.fromChars url)) : details
1512− Http.BadUrl url reason ->
1513− toHttpReport (context ++ ", so I wanted to fetch:") url
1514− [ D.reflow $ "But my HTTP library is saying this is not a valid URL. It is saying:"
1515− , D.indent 4 $ D.fromChars reason
1517− "This may indicate that there is some problem in the compiler, so please open an\
1518− \ issue at https://github.com/elm/compiler/issues listing your operating system, Elm\
1519− \ version, the command you ran, the terminal output, and any additional information\
1520− \ that might help others reproduce the error."
1523− Http.BadHttp url httpExceptionContent ->
1524− case httpExceptionContent of
1525− HTTP.StatusCodeException response body ->
1527− (HTTP.Status code message) = HTTP.responseStatus response
1529− toHttpReport (context ++ ", so I tried to fetch:") url
1531− ["But","it","came","back","as",D.red (D.fromInt code)]
1532− ++ map D.fromChars (words (BS_UTF8.toString message))
1533− , D.indent 4 $ D.reflow $ BS_UTF8.toString body
1535− "This may mean some online endpoint changed in an unexpected way, so if does not\
1536− \ seem like something on your side is causing this (e.g. firewall) please report\
1537− \ this to https://github.com/elm/compiler/issues with your operating system, Elm\
1538− \ version, the command you ran, the terminal output, and any additional information\
1539− \ that can help others reproduce the error!"
1542− HTTP.TooManyRedirects responses ->
1543− toHttpReport (context ++ ", so I tried to fetch:") url
1544− [ D.reflow $ "But I gave up after following these " ++ show (length responses) ++ " redirects:"
1545− , D.indent 4 $ D.vcat $ map toRedirectDoc responses
1547− "Is it possible that your internet connection intercepts certain requests? That\
1548− \ sometimes causes problems for folks in schools, businesses, airports, hotels,\
1549− \ and certain countries. Try asking for help locally or in a community forum!"
1553− toHttpReport (context ++ ", so I tried to fetch:") url
1554− [ D.reflow $ "But my HTTP library is giving me the following error message:"
1555− , D.indent 4 $ D.fromChars (show otherException)
1557− "Are you somewhere with a slow internet connection? Or no internet?\
1558− \ Does the link I am trying to fetch work in your browser? Maybe the\
1559− \ site is down? Does your internet connection have a firewall that\
1560− \ blocks certain domains? It is usually something like that!"
1563− Http.BadMystery url someException ->
1564− toHttpReport (context ++ ", so I tried to fetch:") url
1565− [ D.reflow $ "But I ran into something weird! I was able to extract this error message:"
1566− , D.indent 4 $ D.fromChars (show someException)
1568− "Is it possible that your internet connection intercepts certain requests? That\
1569− \ sometimes causes problems for folks in schools, businesses, airports, hotels,\
1570− \ and certain countries. Try asking for help locally or in a community forum!"
1574−toRedirectDoc :: HTTP.Response body -> D.Doc
1575−toRedirectDoc response =
1577− (HTTP.Status code message) = HTTP.responseStatus response
1579− case List.lookup HTTP.hLocation (HTTP.responseHeaders response) of
1580− Just loc -> D.red (D.fromInt code) <> " - " <> D.fromChars (BS_UTF8.toString loc)
1581− Nothing -> D.red (D.fromInt code) <> " - " <> D.fromChars (BS_UTF8.toString message)
716+ DetailsNoOfflineSolution ->
717+ error "TODO DetailsNoOfflineSolution"
719+ DetailsSolverProblem _ ->
720+ error "TODO DetailsSolverProblem"
1590− | MakeCannotOptimizeAndDebug
1591− | MakeBadDetails Details
1592− | MakeAppNeedsFileNames
1593− | MakePkgNeedsExposing
1594− | MakeMultipleFilesIntoHtml
1596− | MakeNonMainFilesIntoJavaScript ModuleName.Raw [ModuleName.Raw]
1597− | MakeCannotBuild BuildProblem
1598− | MakeBadGenerate Generate
1601makeToReport :: Make -> Help.Report
724makeToReport :: Make -> Help.Report
1602makeToReport make =
725makeToReport make =
1603 case make of
726 case make of
1604− MakeNoOutline ->
727+ MakeNeedsOutline ->
1605 Help.report "NO elm.json FILE" Nothing
728 Help.report "NO elm.json FILE" Nothing
1606 "It looks like you are starting a new Elm project. Very exciting! Try running:"
729 "It looks like you are starting a new Elm project. Very exciting! Try running:"
1607 [ D.indent 4 $ D.green $ "elm init"
730 [ D.indent 4 $ D.green $ "elm init"
@@ -1622,344 +745,27 @@ makeToReport make =
1622 \ at once though! Pick just one of those flags and it should work!"
745 \ at once though! Pick just one of those flags and it should work!"
1625− MakeBadDetails detailsProblem ->
748+ MakeBlockedByDetailsProblem detailsProblem ->
1626− toDetailsReport detailsProblem
749+ detailsToReport detailsProblem
1628 MakeAppNeedsFileNames ->
751 MakeAppNeedsFileNames ->
1629 Help.report "NO INPUT" Nothing
752 Help.report "NO INPUT" Nothing
1630− "What should I make though? I need specific files like:"
753+ "What should I make though? I need a specific file like this:"
1631− [ D.vcat
754+ [ D.indent 4 $ D.green "elm make src/Main.elm"
1632− [ D.indent 4 $ D.green "elm make src/Main.elm"
755+ , D.reflow
1633− , D.indent 4 $ D.green "elm make src/This.elm src/That.elm"
756+ "However many files you give, I will create one JS file out of them."
1636− "I recommend reading through https://guide.elm-lang.org for guidance on what to\
1637− \ actually put in those files!"
1640 MakePkgNeedsExposing ->
759 MakePkgNeedsExposing ->
1641− Help.report "NO INPUT" Nothing
760+ error "TODO MakePkgNeedsExposing"
1642− "What should I make though? I need specific files like:"
1644− [ D.indent 4 $ D.green "elm make src/Main.elm"
1645− , D.indent 4 $ D.green "elm make src/This.elm src/That.elm"
1648− "You can also entries to the \"exposed-modules\" list in your elm.json file, and\
1649− \ I will try to compile the relevant files."
1652 MakeMultipleFilesIntoHtml ->
762 MakeMultipleFilesIntoHtml ->
1653− Help.report "TOO MANY FILES" Nothing
763+ error "TODO MakeMultipleFilesIntoHtml"
1655− "When producing an HTML file, I can only handle one file."
1658− ["Switch","to",D.dullyellow "--output=/dev/null","if","you","just","want"
1659− ,"to","get","compile","errors.","This","skips","the","code","gen","phase,"
1660− ,"so","it","can","be","a","bit","faster","than","other","options","sometimes."
1663− ["Switch","to",D.dullyellow "--output=elm.js","if","you","want","multiple"
1664− ,"`main`","values","available","in","a","single","JavaScript","file.","Then"
1665− ,"you","can","make","your","own","customized","HTML","file","that","embeds"
1666− ,"multiple","Elm","nodes.","The","generated","JavaScript","also","shares"
1667− ,"dependencies","between","modules,","so","it","should","be","smaller","than"
1668− ,"compiling","each","module","separately."
1672− MakeNoMain ->
765+ MakeNonMainFilesIntoJavaScript _ _ ->
1673− Help.report "NO MAIN" Nothing
766+ error "TODO MakeNonMainFilesIntoJavaScript"
1675− "When producing an HTML file, I require that the given file has a `main` value.\
1676− \ That way I have something to show on screen!"
1679− "Try adding a `main` value to your file? Or if you just want to verify that this\
1680− \ module compiles, switch to --output=/dev/null to skip the code gen phase\
1683− "Adding a `main` value can be as brief as adding something like this:"
1685− [ D.fillSep [D.cyan "import","Html"]
1687− , D.fillSep [D.green "main","="]
1688− , D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text",D.dullyellow "\"Hello!\""]
1691− "From there I can create an HTML file that says \"Hello!\" on screen. I recommend\
1692− \ looking through https://guide.elm-lang.org for more guidance on how to fill in\
1693− \ the `main` value."
1696− MakeNonMainFilesIntoJavaScript m ms ->
1699− Help.report "NO MAIN" Nothing
1701− "When producing a JS file, I require that the given file has a `main` value. That\
1702− \ way Elm." ++ ModuleName.toChars m ++ ".init() is definitely defined in the\
1706− "Try adding a `main` value to your file? Or if you just want to verify that this\
1707− \ module compiles, switch to --output=/dev/null to skip the code gen phase\
1710− "Adding a `main` value can be as brief as adding something like this:"
1712− [ D.fillSep [D.cyan "import","Html"]
1714− , D.fillSep [D.green "main","="]
1715− , D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text",D.dullyellow "\"Hello!\""]
1718− "Or use https://package.elm-lang.org/packages/elm/core/latest/Platform#worker to\
1719− \ make a `main` with no user interface."
1723− Help.report "NO MAIN" Nothing
1725− "When producing a JS file, I require that given files all have `main` values.\
1726− \ That way functions like Elm." ++ ModuleName.toChars m ++ ".init() are\
1727− \ definitely defined in the resulting file. I am missing `main` values in:"
1729− [ D.indent 4 $ D.red $ D.vcat $ map D.fromName (m:ms)
1731− "Try adding a `main` value to them? Or if you just want to verify that these\
1732− \ modules compile, switch to --output=/dev/null to skip the code gen phase\
1735− "Adding a `main` value can be as brief as adding something like this:"
1737− [ D.fillSep [D.cyan "import","Html"]
1739− , D.fillSep [D.green "main","="]
1740− , D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text",D.dullyellow "\"Hello!\""]
1743− "Or use https://package.elm-lang.org/packages/elm/core/latest/Platform#worker to\
1744− \ make a `main` with no user interface."
1747− MakeCannotBuild buildProblem ->
1748− toBuildProblemReport buildProblem
1750− MakeBadGenerate generateProblem ->
1751− toGenerateReport generateProblem
1759− = BuildBadModules FilePath Error.Module [Error.Module]
1760− | BuildProjectProblem BuildProjectProblem
1763−data BuildProjectProblem
1764− = BP_PathUnknown FilePath
1765− | BP_WithBadExtension FilePath
1766− | BP_WithAmbiguousSrcDir FilePath FilePath FilePath
1767− | BP_MainPathDuplicate FilePath FilePath
1768− | BP_RootNameDuplicate ModuleName.Raw FilePath FilePath
1769− | BP_RootNameInvalid FilePath FilePath [String]
1770− | BP_CannotLoadDependencies
1771− | BP_Cycle ModuleName.Raw [ModuleName.Raw]
1772− | BP_MissingExposed (NE.List (ModuleName.Raw, Import.Problem))
1775−toBuildProblemReport :: BuildProblem -> Help.Report
1776−toBuildProblemReport problem =
1778− BuildBadModules root e es ->
1779− Help.compilerReport root e es
1781− BuildProjectProblem projectProblem ->
1782− toProjectProblemReport projectProblem
1785−toProjectProblemReport :: BuildProjectProblem -> Help.Report
1786−toProjectProblemReport projectProblem =
1787− case projectProblem of
1788− BP_PathUnknown path ->
1789− Help.report "FILE NOT FOUND" Nothing
1790− "I cannot find this file:"
1791− [ D.indent 4 $ D.red $ D.fromChars path
1792− , D.reflow $ "Is there a typo?"
1794− "If you are just getting started, try working through the examples in the\
1795− \ official guide https://guide.elm-lang.org to get an idea of the kinds of things\
1796− \ that typically go in a src/Main.elm file."
1799− BP_WithBadExtension path ->
1800− Help.report "UNEXPECTED FILE EXTENSION" Nothing
1801− "I can only compile Elm files (with a .elm extension) but you want me to compile:"
1802− [ D.indent 4 $ D.red $ D.fromChars path
1803− , D.reflow $ "Is there a typo? Can the file extension be changed?"
1806− BP_WithAmbiguousSrcDir path srcDir1 srcDir2 ->
1807− Help.report "CONFUSING FILE" Nothing
1808− "I am getting confused when I try to compile this file:"
1809− [ D.indent 4 $ D.red $ D.fromChars path
1811− "I always check if files appear in any of the \"source-directories\" listed in\
1812− \ your elm.json to see if there might be some cached information about them. That\
1813− \ can help me compile faster! But in this case, it looks like this file may be in\
1814− \ either of these directories:"
1815− , D.indent 4 $ D.red $ D.vcat $ map D.fromChars [srcDir1,srcDir2]
1817− "Try to make it so no source directory contains another source directory!"
1820− BP_MainPathDuplicate path1 path2 ->
1821− Help.report "CONFUSING FILES" Nothing
1822− "You are telling me to compile these two files:"
1823− [ D.indent 4 $ D.red $ D.vcat $ map D.fromChars [ path1, path2 ]
1825− if path1 == path2 then
1826− "Why are you telling me twice? Is something weird going on with a script?\
1827− \ I figured I would let you know about it just in case something is wrong.\
1828− \ Only list it once and you should be all set!"
1830− "But seem to be the same file though... It makes me think something tricky is\
1831− \ going on with symlinks in your project, so I figured I would let you know\
1832− \ about it just in case. Remove one of these files from your command to get\
1836− BP_RootNameDuplicate name outsidePath otherPath ->
1837− Help.report "MODULE NAME CLASH" Nothing
1838− "These two files are causing a module name clash:"
1839− [ D.indent 4 $ D.red $ D.vcat $ map D.fromChars [ outsidePath, otherPath ]
1841− "They both say `module " ++ ModuleName.toChars name ++ " exposing (..)` up\
1842− \ at the top, but they cannot have the same name!"
1844− "Try changing to a different module name in one of them!"
1847− BP_RootNameInvalid givenPath srcDir _ ->
1848− Help.report "UNEXPECTED FILE NAME" Nothing
1849− "I am having trouble with this file name:"
1850− [ D.indent 4 $ D.red $ D.fromChars givenPath
1852− "I found it in your " ++ FP.addTrailingPathSeparator srcDir ++ " directory\
1853− \ which is good, but I expect all of the files in there to use the following\
1854− \ module naming convention:"
1855− , toModuleNameConventionTable srcDir [ "Main", "HomePage", "Http.Helpers" ]
1857− "Notice that the names always start with capital letters! Can you make your file\
1858− \ use this naming convention?"
1860− "Having a strict naming convention like this makes it a lot easier to find\
1861− \ things in large projects. If you see a module imported, you know where to look\
1862− \ for the corresponding file every time!"
1865− BP_CannotLoadDependencies ->
768+ MakeCannotOptimizeDebugValues m ms ->
1868− BP_Cycle name names ->
1869− Help.report "IMPORT CYCLE" Nothing
1870− "Your module imports form a cycle:"
1871− [ D.cycle 4 name names
1873− "Learn more about why this is disallowed and how to break cycles here:"
1874− ++ D.makeLink "import-cycles"
1877− BP_MissingExposed (NE.List (name, problem) _) ->
1880− Help.report "MISSING MODULE" (Just "elm.json")
1881− "The \"exposed-modules\" of your elm.json lists the following module:"
1882− [ D.indent 4 $ D.red $ D.fromName name
1884− "But I cannot find it in your src/ directory. Is there a typo? Was it renamed?"
1887− Import.Ambiguous _ _ pkg _ ->
1888− Help.report "AMBIGUOUS MODULE NAME" (Just "elm.json")
1889− "The \"exposed-modules\" of your elm.json lists the following module:"
1890− [ D.indent 4 $ D.red $ D.fromName name
1892− "But a module from " ++ Pkg.toChars pkg ++ " already uses that name. Try\
1893− \ choosing a different name for your local file."
1896− Import.AmbiguousLocal path1 path2 paths ->
1897− Help.report "AMBIGUOUS MODULE NAME" (Just "elm.json")
1898− "The \"exposed-modules\" of your elm.json lists the following module:"
1899− [ D.indent 4 $ D.red $ D.fromName name
1901− "But I found multiple files with that name:"
1902− , D.dullyellow $ D.indent 4 $ D.vcat $
1903− map D.fromChars (path1:path2:paths)
1905− "Change the module names to be distinct!"
1908− Import.AmbiguousForeign _ _ _ ->
1909− Help.report "MISSING MODULE" (Just "elm.json")
1910− "The \"exposed-modules\" of your elm.json lists the following module:"
1911− [ D.indent 4 $ D.red $ D.fromName name
1913− "But I cannot find it in your src/ directory. Is there a typo? Was it renamed?"
1915− "It is not possible to \"re-export\" modules from other packages. You can only\
1916− \ expose modules that you define in your own code."
1920−toModuleNameConventionTable :: FilePath -> [String] -> D.Doc
1921−toModuleNameConventionTable srcDir names =
1925− , srcDir </> map (\c -> if c == '.' then FP.pathSeparator else c) name <.> "elm"
1928− namePairs = map toPair names
1929− nameWidth = maximum (11 : map (length . fst) namePairs)
1930− pathWidth = maximum ( 9 : map (length . snd) namePairs)
1933− str ++ replicate (width - length str) ' '
1935− toRow (name, path) =
1937− "| " ++ padded nameWidth name ++ " | " ++ padded pathWidth path ++ " |"
1941− "+-" ++ replicate nameWidth '-' ++ "-+-" ++ replicate pathWidth '-' ++ "-+"
1943− D.indent 4 $ D.vcat $
1944− [ bar, toRow ("Module Name", "File Path"), bar ] ++ map toRow namePairs ++ [ bar ]
1952− = GenerateCannotLoadArtifacts
1953− | GenerateCannotOptimizeDebugValues ModuleName.Raw [ModuleName.Raw]
1956−toGenerateReport :: Generate -> Help.Report
1957−toGenerateReport problem =
1959− GenerateCannotLoadArtifacts ->
1962− GenerateCannotOptimizeDebugValues m ms ->
1963 Help.report "DEBUG REMNANTS" Nothing
769 Help.report "DEBUG REMNANTS" Nothing
1964 "There are uses of the `Debug` module in the following modules:"
770 "There are uses of the `Debug` module in the following modules:"
1965 [ D.indent 4 $ D.red $ D.vcat $ map (D.fromChars . ModuleName.toChars) (m:ms)
771 [ D.indent 4 $ D.red $ D.vcat $ map (D.fromChars . ModuleName.toChars) (m:ms)
@@ -1968,7 +774,7 @@ toGenerateReport problem =
1968 "The issue is that --optimize strips out info needed by `Debug` functions.\
774 "The issue is that --optimize strips out info needed by `Debug` functions.\
1969 \ Here are two examples:"
775 \ Here are two examples:"
1970 , D.indent 4 $ D.reflow $
776 , D.indent 4 $ D.reflow $
1971− "(1) It shortens record field names. This makes the generated JavaScript\
777+ "(1) It shortens record field names. This makes the generated JavaScript is\
1972 \ smaller, but `Debug.toString` cannot know the real field names anymore."
778 \ smaller, but `Debug.toString` cannot know the real field names anymore."
1973 , D.indent 4 $ D.reflow $
779 , D.indent 4 $ D.reflow $
1974 "(2) Values like `type Height = Height Float` are unboxed. This reduces\
780 "(2) Values like `type Height = Height Float` are unboxed. This reduces\
@@ -1981,89 +787,42 @@ toGenerateReport problem =
1981 \ exists!"
787 \ exists!"
790+ MakeCannotBuild buildProblem ->
791+ case buildProblem of
792+ BuildProjectProblem bp ->
795+ error "TODO BP_PathUnknown"
797+ BP_WithBadExtension _ ->
798+ error "TODO BP_WithBadExtension"
1986−-- CORRUPT CACHE
800+ BP_WithAmbiguousSrcDir _ _ ->
1987−
801+ error "TODO BP_WithAmbiguousSrcDir"
1989−corruptCacheReport :: Help.Report
1990−corruptCacheReport =
1991− Help.report "CORRUPT CACHE" Nothing
1992− "It looks like some of the information cached in elm-stuff/ has been corrupted."
1994− "Try deleting your elm-stuff/ directory to get unstuck."
1996− "This almost certainly means that a 3rd party tool (or editor plugin) is\
1997− \ causing problems your the elm-stuff/ directory. Try disabling 3rd party tools\
1998− \ one by one until you figure out which it is!"
2008− | ReactorBadDetails Details
2009− | ReactorBadBuild BuildProblem
2010− | ReactorBadGenerate Generate
2013−reactorToReport :: Reactor -> Help.Report
2014−reactorToReport problem =
2016− ReactorNoOutline ->
2017− Help.report "NEW PROJECT?" Nothing
2018− "Are you trying to start a new project? Try this command in the terminal:"
2019− [ D.indent 4 $ D.green "elm init"
2020− , D.reflow "It will help you get started!"
2023− ReactorBadDetails details ->
2024− toDetailsReport details
2026− ReactorBadBuild buildProblem ->
2027− toBuildProblemReport buildProblem
2029− ReactorBadGenerate generate ->
2030− toGenerateReport generate
2038− = ReplBadDetails Details
2039− | ReplBadInput BS.ByteString Error.Error
2040− | ReplBadLocalDeps FilePath Error.Module [Error.Module]
2041− | ReplProjectProblem BuildProjectProblem
2042− | ReplBadGenerate Generate
2047−replToReport :: Repl -> Help.Report
803+ BP_MainPathDuplicate _ _ ->
2048−replToReport problem =
804+ error "TODO BP_MainPathDuplicate"
2050− ReplBadDetails details ->
2051− toDetailsReport details
2053− ReplBadInput source err ->
806+ BP_MainNameDuplicate _ _ _ ->
2054− Help.compilerReport "/" (Error.Module N.replModule "REPL" File.zeroTime source err) []
807+ error "TODO BP_MainNameDuplicate"
2056− ReplBadLocalDeps root e es ->
809+ BP_CannotLoadDependencies ->
2057− Help.compilerReport root e es
810+ error "TODO BP_CannotLoadDependencies"
2059− ReplProjectProblem projectProblem ->
812+ BP_Cycle name names ->
2060− toProjectProblemReport projectProblem
813+ Help.report "IMPORT CYCLE" Nothing
814+ "Your module imports form a cycle:"
815+ [ D.cycle 4 name names
817+ "Learn more about why this is disallowed and how to break cycles here:"
818+ ++ D.makeLink "import-cycles"
2062− ReplBadGenerate generate ->
821+ BP_MissingExposed _ ->
2063− toGenerateReport generate
822+ error "TODO BP_MissingExposed"
2065− ReplBadCache ->
824+ BuildModuleProblems p ps ->
2066− corruptCacheReport
825+ Help.compilerReport p ps
2068− ReplBlocked ->
827+ MakeCannotLoadArtifacts ->
2069− corruptCacheReport
828+ error "TODO MakeCannotLoadArtifacts"