@@ -1,37 +1,24 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2module Reporting.Exit
2module Reporting.Exit
4− , initToReport
3+ ( Init(..), initToReport
7− , diffToReport
4+ , Diff(..), diffToReport
8− --
5+ , Make(..), makeToReport
10− , bumpToReport
6+ , Bump(..), bumpToReport
7+ , Publish(..), publishToReport
8+ , Install(..), installToReport
9+ , Reactor(..), reactorToReport
11 , newPackageOverview
10 , newPackageOverview
19 , Solver(..)
12 , Solver(..)
21 , Outline(..)
13 , Outline(..)
22 , OutlineProblem(..)
14 , OutlineProblem(..)
24 , Details(..)
15 , Details(..)
25 , PackageProblem(..)
16 , PackageProblem(..)
27 , RegistryProblem(..)
17 , RegistryProblem(..)
30 , BuildProblem(..)
18 , BuildProblem(..)
31 , BuildProjectProblem(..)
19 , BuildProjectProblem(..)
34 , DocsProblem(..)
20 , DocsProblem(..)
36 , toString
23 , toString
37 , toStderr
24 , toStderr
@@ -69,6 +56,25 @@ import qualified Reporting.Render.Code as Code
62+toString :: Help.Report -> String
64+ Help.toString (Help.reportToDoc report)
67+toStderr :: Help.Report -> IO ()
69+ Help.toStderr (Help.reportToDoc report)
72+toJson :: Help.Report -> Encode.Value
74+ Help.reportToJson report
@@ -96,10 +102,15 @@ initToReport exit =
97 InitNoOfflineSolution pkgs ->
103 InitNoOfflineSolution pkgs ->
98 Help.report "NO OFFLINE SOLUTION" Nothing
104 Help.report "NO OFFLINE SOLUTION" Nothing
99− (error "TODO InitNoOfflineSolution" pkgs)
105+ "I tried to create an elm.json with the following direct dependencies:"
100− (error "TODO InitNoOfflineSolution" pkgs)
106+ [ D.indent 4 $ D.vcat $
101− -- note about Russia IP addresses?
107+ map (D.dullyellow . D.fromChars . Pkg.toChars) pkgs
102− -- ask if they are on a plane or train
108+ , D.reflow $
109+ "I could not find compatible versions though, but that may be because I could not\
110+ \ connect to https://package.elm-lang.org to get the latest list of packages. Are\
111+ \ you able to connect to the internet? Please ask around one of the community\
112+ \ forums at https://elm-lang.org/community for help!"
104 InitSolverProblem solver ->
115 InitSolverProblem solver ->
105 error "TODO InitSolverProblem" solver
116 error "TODO InitSolverProblem" solver
@@ -159,11 +170,13 @@ diffToReport diff =
159 , D.indent 4 $ D.dullyellow $ "elm diff elm/http 1.0.0 2.0.0"
170 , D.indent 4 $ D.dullyellow $ "elm diff elm/http 1.0.0 2.0.0"
162− DiffNoExposed pkg ->
173+ DiffNoExposed _ ->
163 Help.report "NO EXPOSED MODULES" (Just "elm.json")
174 Help.report "NO EXPOSED MODULES" (Just "elm.json")
164 "Your elm.json has no \"exposed-modules\" which means there is no public API at\
175 "Your elm.json has no \"exposed-modules\" which means there is no public API at\
176+ \ all right now! What am I supposed to diff?"
165− \ all right now! Try adding some modules back to this field."
178+ "Try adding some modules back to the \"exposed-modules\" field."
168 DiffUnpublished ->
181 DiffUnpublished ->
169 Help.report "UNPUBLISHED" Nothing
182 Help.report "UNPUBLISHED" Nothing
@@ -320,7 +333,7 @@ data Publish
320 | PublishCannotGetTag V.Version Http.Error
333 | PublishCannotGetTag V.Version Http.Error
321 | PublishCannotGetTagData V.Version String BS.ByteString
334 | PublishCannotGetTagData V.Version String BS.ByteString
322 | PublishCannotGetZip Http.Error
335 | PublishCannotGetZip Http.Error
323− | PublishCannotDecodeZip
336+ | PublishCannotDecodeZip String
324 | PublishCannotGetDocs V.Version V.Version DocsProblem
337 | PublishCannotGetDocs V.Version V.Version DocsProblem
325 | PublishCannotRegister Http.Error
338 | PublishCannotRegister Http.Error
326 | PublishNoGit
339 | PublishNoGit
@@ -544,10 +557,20 @@ publishToReport publish =
545 PublishCannotGetZip httpError ->
558 PublishCannotGetZip httpError ->
546 toHttpErrorReport "PROBLEM DOWNLOADING CODE" httpError $
559 toHttpErrorReport "PROBLEM DOWNLOADING CODE" httpError $
547− "I need to check that folks can download and build the source code when they install this package"
560+ "I need to check that folks can download and build the source code when they\
561+ \ install this package"
549− PublishCannotDecodeZip ->
563+ PublishCannotDecodeZip url ->
550− error "TODO PublishCannotDecodeZip"
564+ Help.report "PROBLEM DOWNLOADING CODE" Nothing
565+ "I need to check that folks can download and build the source code when they\
566+ \ install this package, so I downloaded the code from:"
567+ [ D.indent 4 $ D.dullyellow $ D.fromChars url
569+ "I was unable to unzip the archive though. Maybe there is something weird with\
570+ \ your internet connection. We have gotten reports that schools, businesses,\
571+ \ airports, etc. sometimes intercept requests and add things to the body or\
572+ \ change its contents entirely. Could that be the problem?"
552 PublishCannotGetDocs old new docsProblem ->
575 PublishCannotGetDocs old new docsProblem ->
553 toDocsProblemReport docsProblem $
576 toDocsProblemReport docsProblem $
@@ -818,205 +841,276 @@ data OutlineProblem
818 | OP_NoSrcDirs
841 | OP_NoSrcDirs
821−
844+toOutlineReport :: Outline -> Help.Report
822−-- DETAILS
845+toOutlineReport problem =
828− | DetailsNoOfflineSolution
829− | DetailsSolverProblem Solver
830− | DetailsBadElmInPkg C.Constraint
831− | DetailsBadElmInAppOutline V.Version
832− | DetailsHandEditedDependencies
833− | DetailsBadOutline Outline
834− | DetailsCannotGetRegistry RegistryProblem
835− | DetailsCannotBuildPackage Pkg.Name V.Version PackageProblem
839− = PP_BadEndpointRequest Http.Error
840− | PP_BadEndpointContent
841− | PP_BadArchiveRequest Http.Error
842− | PP_BadArchiveContent
843− | PP_BadArchiveHash String String
851− = RP_Http Http.Error
852− | RP_Data String BS.ByteString
855−toRegistryProblemReport :: String -> RegistryProblem -> String -> Help.Report
856−toRegistryProblemReport title problem context =
857 case problem of
846 case problem of
858− RP_Http err ->
847+ OutlineHasBadStructure decodeError ->
859− toHttpErrorReport title err context
848+ Json.toReport "elm.json" (Json.FailureToReport toOutlineProblemReport) decodeError $
860−
849+ Json.ExplicitReason "I ran into a problem with your elm.json file."
862− Help.report title Nothing (context ++ ", so I fetched:")
863− [ D.indent 4 $ D.dullyellow $ D.fromChars url
865− "I got the data back, but it was not what I was expecting. The response\
866− \ body contains " ++ show (BS.length body) ++ " bytes. Here is the "
867− ++ if BS.length body <= 76 then "whole thing:" else "beginning:"
868− , D.indent 4 $ D.dullyellow $ D.fromChars $
869− if BS.length body <= 76
870− then BS_UTF8.toString body
871− else take 73 (BS_UTF8.toString body) ++ "..."
873− "Does this error keep showing up? Maybe there is something weird with your\
874− \ internet connection. We have gotten reports that schools, businesses,\
875− \ airports, etc. sometimes intercept requests and add things to the body\
876− \ or change its contents entirely. Could that be the problem?"
880−toHttpErrorReport :: String -> Http.Error -> String -> Help.Report
881−toHttpErrorReport title err context =
883− toHttpReport intro url details =
884− Help.report title Nothing intro $
885− D.indent 4 (D.dullyellow (D.fromChars url)) : details
888− Http.BadUrl url reason ->
889− toHttpReport (context ++ ", so I wanted to fetch:") url
890− [ D.reflow $ "But my HTTP library is saying this is not a valid URL. It is saying:"
891− , D.indent 4 $ D.fromChars reason
893− "This may indicate that there is some problem in the compiler, so please open an\
894− \ issue at https://github.com/elm/compiler/issues listing your operating system, Elm\
895− \ version, the command you ran, the terminal output, and any additional information\
896− \ that might help others reproduce the error."
899− Http.BadHttp url httpExceptionContent ->
900− case httpExceptionContent of
901− HTTP.StatusCodeException response _ ->
903− (HTTP.Status code message) = HTTP.responseStatus response
905− toHttpReport (context ++ ", so I tried to fetch:") url
907− ["But","it","came","back","as",D.red (D.fromInt code)]
908− ++ map D.fromChars (words (BS_UTF8.toString message))
910− "This may mean some online endpoint changed in an unexpected way, so if does not\
911− \ seem like something on your side is causing this (e.g. firewall) please report\
912− \ this to https://github.com/elm/compiler/issues with your operating system, Elm\
913− \ version, the command you ran, the terminal output, and any additional information\
914− \ that can help others reproduce the error!"
917− HTTP.TooManyRedirects responses ->
851+ OutlineHasBadSrcDirs dir dirs ->
918− toHttpReport (context ++ ", so I tried to fetch:") url
852+ case dirs of
919− [ D.reflow $ "But I gave up after following these " ++ show (length responses) ++ " redirects:"
853+ [] ->
920− , D.indent 4 $ D.vcat $ map toRedirectDoc responses
854+ Help.report "MISSING SOURCE DIRECTORY" (Just "elm.json")
855+ "I need a valid elm.json file, but the \"source-directories\" field lists the following directory:"
856+ [ D.indent 4 $ D.dullyellow $ D.fromChars dir
921 , D.reflow $
857 , D.reflow $
922− "Is it possible that your internet connection intercepts certain requests? That\
858+ "I cannot find it though. Is it missing? Is there a typo?"
923− \ sometimes causes problems for folks in schools, businesses, airports, hotels,\
924− \ and certain countries. Try asking for help locally or in a community forum!"
927− otherException ->
861+ _:_ ->
928− toHttpReport (context ++ ", so I tried to fetch:") url
862+ Help.report "MISSING SOURCE DIRECTORIES" (Just "elm.json")
929− [ D.reflow $ "But my HTTP library is giving me the following error message:"
863+ "I need a valid elm.json file, but the \"source-directories\" field lists the following directories:"
930− , D.indent 4 $ D.fromChars (show otherException)
864+ [ D.indent 4 $ D.dullyellow $ D.fromChars dir
931 , D.reflow $
865 , D.reflow $
932− "Are you somewhere with a slow internet connection? Or no internet?\
866+ "I cannot find them though. Are they missing? Are there typos?"
933− \ Does the link I am trying to fetch work in your browser? Maybe the\
934− \ site is down? Does your internet connection have a firewall that\
935− \ blocks certain domains? It is usually something like that!"
938− Http.BadMystery url someException ->
869+ OutlineNoPkgCore ->
939− toHttpReport (context ++ ", so I tried to fetch:") url
870+ Help.report "MISSING DEPENDENCY" (Just "elm.json")
940− [ D.reflow $ "But I ran into something weird! I was able to extract this error message:"
871+ "I need a valid elm.json file, so I need to see an \"elm/core\" dependency in there. Try running:"
941− , D.indent 4 $ D.fromChars (show someException)
872+ [ D.indent 4 $ D.green $ "elm install elm/core"
942− , D.reflow $
873+ , D.reflow "I need it for the default imports that make `List` and `Maybe` available."
943− "Is it possible that your internet connection intercepts certain requests? That\
944− \ sometimes causes problems for folks in schools, businesses, airports, hotels,\
945− \ and certain countries. Try asking for help locally or in a community forum!"
877+ Help.report "MISSING DEPENDENCY" (Just "elm.json")
878+ "I need a valid elm.json file, so I need to see an \"elm/core\" dependency in there. Try running:"
879+ [ D.indent 4 $ D.green $ "elm install elm/core"
880+ , D.reflow "It has some supporting code that is needed by every Elm application!"
949−toRedirectDoc :: HTTP.Response body -> D.Doc
883+ OutlineNoAppJson ->
950−toRedirectDoc response =
884+ Help.report "MISSING DEPENDENCY" (Just "elm.json")
951− let
885+ "I need a valid elm.json file, so I need to see an \"elm/json\" dependency in there. Try running:"
952− (HTTP.Status code message) = HTTP.responseStatus response
886+ [ D.indent 4 $ D.green $ "elm install elm/json"
953− in
887+ , D.reflow "It helps me handle flags and ports."
954− case List.lookup HTTP.hLocation (HTTP.responseHeaders response) of
888+ ]
955− Just loc -> D.red (D.fromInt code) <> " - " <> D.fromChars (BS_UTF8.toString loc)
956− Nothing -> D.red (D.fromInt code) <> " - " <> D.fromChars (BS_UTF8.toString message)
891+toOutlineProblemReport :: FilePath -> Code.Source -> Json.Context -> A.Region -> OutlineProblem -> Help.Report
892+toOutlineProblemReport path source _ region problem =
894+ toHighlight row col =
895+ Just $ A.Region (A.Position row col) (A.Position row col)
960−-- MAKE
897+ toSnippet title highlight pair =
898+ Help.jsonReport title (Just path) $
899+ Code.toSnippet source region highlight pair
903+ toSnippet "UNEXPECTED TYPE" Nothing
905+ "I got stuck while reading your elm.json file. I cannot handle a \"type\" like this:"
907+ ["Try","changing","the","\"type\"","to"
908+ ,D.green "\"application\"","or",D.green "\"package\"","instead."
912+ OP_BadPkgName row col ->
913+ toSnippet "INVALID PACKAGE NAME" (toHighlight row col)
915+ "I got stuck while reading your elm.json file. I ran into trouble with the package name:"
918+ ["Package","names","are","always","written","as"
919+ ,D.green "\"author/project\""
920+ ,"so","I","am","expecting","to","see","something","like:"
922+ , D.dullyellow $ D.indent 4 $ D.vcat $
923+ [ "\"mdgriffith/elm-ui\""
924+ , "\"w0rm/elm-physics\""
925+ , "\"Microsoft/elm-json-tree-view\""
926+ , "\"FordLabs/elm-star-rating\""
927+ , "\"1602/json-schema\""
930+ "The author name should match your GitHub name exactly, and the project name\
931+ \ needs to follow these rules:"
932+ , D.indent 4 $ D.vcat $
933+ [ "+--------------------------------------+-----------+-----------+"
934+ , "| RULE | BAD | GOOD |"
935+ , "+--------------------------------------+-----------+-----------+"
936+ , "| only lower case, digits, and hyphens | elm-HTTP | elm-http |"
937+ , "| no leading digits | 3D | elm-3d |"
938+ , "| no non-ASCII characters | elm-bjørn | elm-bear |"
939+ , "| no underscores | elm_ui | elm-ui |"
940+ , "| no double hyphens | elm--hash | elm-hash |"
941+ , "| no starting or ending hyphen | -elm-tar- | elm-tar |"
942+ , "+--------------------------------------+-----------+-----------+"
945+ "These rules only apply to the project name, so you should never need\
946+ \ to change your GitHub name!"
963−data Make
950+ OP_BadVersion row col ->
964− = MakeNeedsOutline
951+ toSnippet "PROBLEM WITH VERSION" (toHighlight row col)
965− | MakeCannotOptimizeAndDebug
952+ ( D.reflow $
966− | MakeBlockedByDetailsProblem Details
953+ "I got stuck while reading your elm.json file. I was expecting a version number here:"
967− | MakeAppNeedsFileNames
954+ , D.fillSep
968− | MakePkgNeedsExposing
955+ ["I","need","something","like",D.green "\"1.0.0\"","or",D.green "\"2.0.4\""
969− | MakeMultipleFilesIntoHtml
956+ ,"that","explicitly","states","all","three","numbers!"
970− | MakeNonMainFilesIntoJavaScript ModuleName.Raw [ModuleName.Raw]
957+ ]
971− | MakeCannotOptimizeDebugValues ModuleName.Raw [ModuleName.Raw]
958+ )
972− | MakeCannotBuild BuildProblem
973− | MakeCannotLoadArtifacts
960+ OP_BadConstraint constraintError ->
961+ case constraintError of
962+ C.BadFormat row col ->
963+ toSnippet "PROBLEM WITH CONSTRAINT" (toHighlight row col)
965+ "I got stuck while reading your elm.json file. I do not understand this version constraint:"
968+ ["I","need","something","like",D.green "\"1.0.0 <= v < 2.0.0\""
969+ ,"that","explicitly","lists","the","lower","and","upper","bounds."
972+ "The spaces in there are required! Taking them out will confuse me. Adding\
973+ \ extra spaces confuses me too. I recommend starting with a valid example\
974+ \ and just changing the version numbers."
976−data BuildProblem
978+ C.InvalidRange before after ->
977− = BuildModuleProblems Error.Module [Error.Module]
979+ if before == after then
978− | BuildProjectProblem BuildProjectProblem
980+ toSnippet "PROBLEM WITH CONSTRAINT" Nothing
982+ "I got stuck while reading your elm.json file. I ran into an invalid version constraint:"
984+ ["Elm","checks","that","all","package","APIs","follow","semantic","versioning,"
985+ ,"so","it","is","best","to","use","wide","constraints.","I","recommend"
986+ ,D.green $ "\"" <> D.fromVersion before <> " <= v < " <> D.fromVersion (V.bumpMajor after) <> "\""
987+ ,"since","it","is","guaranteed","that","breaking","API","changes","cannot"
988+ ,"happen","in","any","of","the","versions","in","that","range."
993+ toSnippet "PROBLEM WITH CONSTRAINT" Nothing
995+ "I got stuck while reading your elm.json file. I ran into an invalid version constraint:"
997+ ["Maybe","you","want","something","like"
998+ ,D.green $ "\"" <> D.fromVersion before <> " <= v < " <> D.fromVersion (V.bumpMajor before) <> "\""
999+ ,"instead?","Elm","checks","that","all","package","APIs","follow","semantic"
1000+ ,"versioning,","so","it","is","guaranteed","that","breaking","API","changes"
1001+ ,"cannot","happen","in","any","of","the","versions","in","that","range."
981−data BuildProjectProblem
1005+ OP_BadModuleName row col ->
982− = BP_PathUnknown FilePath
1006+ toSnippet "PROBLEM WITH MODULE NAME" (toHighlight row col)
983− | BP_WithBadExtension FilePath
1007+ ( D.reflow $
984− | BP_WithAmbiguousSrcDir FilePath FilePath
1008+ "I got stuck while reading your elm.json file. I was expecting a module name here:"
985− | BP_MainPathDuplicate FilePath FilePath
1009+ , D.fillSep
986− | BP_MainNameDuplicate ModuleName.Raw FilePath FilePath
1010+ ["I","need","something","like",D.green "\"Html.Events\""
987− | BP_CannotLoadDependencies
1011+ ,"or",D.green "\"Browser.Navigation\""
988− | BP_Cycle ModuleName.Raw [ModuleName.Raw]
1012+ ,"where","each","segment","starts","with","a","capital"
989− | BP_MissingExposed (NE.List (ModuleName.Raw, Import.Problem))
1013+ ,"letter","and","the","segments","are","separated","by","dots."
1017+ OP_BadModuleHeaderTooLong ->
1018+ toSnippet "HEADER TOO LONG" Nothing
1020+ "I got stuck while reading your elm.json file. This section header is too long:"
1022+ ["I","need","it","to","be"
1023+ ,D.green "under",D.green "20",D.green "characters"
1024+ ,"so","it","renders","nicely","on","the","package","website!"
1028+ OP_BadDependencyName row col ->
1029+ toSnippet "PROBLEM WITH DEPENDENCY NAME" (toHighlight row col)
1031+ "I got stuck while reading your elm.json file. There is something wrong with this dependency name:"
1034+ ["Package","names","always","include","the","name","of","the","author,"
1035+ ,"so","I","am","expecting","to","see","dependencies","like"
1036+ ,D.dullyellow "\"mdgriffith/elm-ui\"","and"
1037+ ,D.dullyellow "\"Microsoft/elm-json-tree-view\"" <> "."
1040+ ["I","generally","recommend","finding","the","package","you","want","on"
1041+ ,"the","package","website,","and","installing","it","with","the"
1042+ ,D.green "elm install","command!"
993−-- RENDERERS
1047+ OP_BadLicense _ suggestions ->
1048+ toSnippet "UNKNOWN LICENSE" Nothing
1050+ "I got stuck while reading your elm.json file. I do not know about this type of license:"
1054+ ["Elm","packages","generally","use"
1055+ ,D.green "\"BSD-3-Clause\"","or",D.green "\"MIT\"" <> ","
1056+ ,"but","I","accept","any","OSI","approved","SPDX","license."
1057+ ,"Here","some","that","seem","close","to","what","you","wrote:"
1059+ , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromChars . Json.toChars) suggestions
1061+ "Check out https://spdx.org/licenses/ for the full list of options."
1065+ OP_BadSummaryTooLong ->
1066+ toSnippet "SUMMARY TOO LONG" Nothing
1068+ "I got stuck while reading your elm.json file. Your \"summary\" is too long:"
1070+ ["I","need","it","to","be"
1071+ ,D.green "under",D.green "80",D.green "characters"
1072+ ,"so","it","renders","nicely","on","the","package","website!"
996−toString :: Help.Report -> String
1076+ OP_NoSrcDirs ->
997−toString report =
1077+ toSnippet "NO SOURCE DIRECTORIES" Nothing
998− Help.toString (Help.reportToDoc report)
1078+ ( D.reflow $
1079+ "I got stuck while reading your elm.json file. You do not have any \"source-directories\" listed here:"
1081+ ["I","need","something","like",D.green "[\"src\"]"
1082+ ,"so","I","know","where","to","look","for","your","modules!"
1001−toStderr :: Help.Report -> IO ()
1003− Help.toStderr (Help.reportToDoc report)
1006−toJson :: Help.Report -> Encode.Value
1008− Help.reportToJson report
1092+ = DetailsNoSolution
1093+ | DetailsNoOfflineSolution
1094+ | DetailsSolverProblem Solver
1095+ | DetailsBadElmInPkg C.Constraint
1096+ | DetailsBadElmInAppOutline V.Version
1097+ | DetailsHandEditedDependencies
1098+ | DetailsBadOutline Outline
1099+ | DetailsCannotGetRegistry RegistryProblem
1100+ | DetailsCannotBuildPackage Pkg.Name V.Version PackageProblem
1012−-- DETAILS TO REPORT
1103+toDetailsReport :: Details -> Help.Report
1104+toDetailsReport details =
1106+ DetailsNoSolution ->
1107+ error "TODO DetailsNoSolution"
1109+ DetailsNoOfflineSolution ->
1110+ error "TODO DetailsNoOfflineSolution"
1015−detailsToReport :: Details -> Help.Report
1112+ DetailsSolverProblem _ ->
1016−detailsToReport details =
1113+ error "TODO DetailsSolverProblem"
1019− error "TODO DetailsCorrupt"
1021 DetailsBadElmInPkg constraint ->
1115 DetailsBadElmInPkg constraint ->
1022 Help.report "ELM VERSION MISMATCH" (Just "elm.json")
1116 Help.report "ELM VERSION MISMATCH" (Just "elm.json")
@@ -1054,366 +1148,379 @@ detailsToReport details =
1054 DetailsCannotBuildPackage name version problem ->
1148 DetailsCannotBuildPackage name version problem ->
1055 error "TODO DetailsCannotBuildPackage" name version problem
1149 error "TODO DetailsCannotBuildPackage" name version problem
1057− DetailsNoSolution ->
1058− error "TODO DetailsNoSolution"
1060− DetailsNoOfflineSolution ->
1061− error "TODO DetailsNoOfflineSolution"
1063− DetailsSolverProblem _ ->
1153+-- PACKAGE PROBLEM
1064− error "TODO DetailsSolverProblem"
1157+ = PP_BadEndpointRequest Http.Error
1158+ | PP_BadEndpointContent
1159+ | PP_BadArchiveRequest Http.Error
1160+ | PP_BadArchiveContent
1161+ | PP_BadArchiveHash String String
1068−makeToReport :: Make -> Help.Report
1071− MakeNeedsOutline ->
1072− Help.report "NO elm.json FILE" Nothing
1073− "It looks like you are starting a new Elm project. Very exciting! Try running:"
1074− [ D.indent 4 $ D.green $ "elm init"
1076− "It will help you get set up. It is really simple!"
1079− MakeCannotOptimizeAndDebug ->
1080− Help.docReport "CLASHING FLAGS" Nothing
1082− ["I","cannot","compile","with",D.red "--optimize","and"
1083− ,D.red "--debug","at","the","same","time."
1087− "I need to take away information to optimize things, and I need to\
1088− \ add information to add the debugger. It is impossible to do both\
1089− \ at once though! Pick just one of those flags and it should work!"
1092− MakeBlockedByDetailsProblem detailsProblem ->
1165+-- REGISTRY PROBLEM
1093− detailsToReport detailsProblem
1095− MakeAppNeedsFileNames ->
1096− Help.report "NO INPUT" Nothing
1097− "What should I make though? I need a specific file like this:"
1098− [ D.indent 4 $ D.green "elm make src/Main.elm"
1100− "However many files you give, I will create one JS file out of them."
1103− MakePkgNeedsExposing ->
1168+data RegistryProblem
1104− error "TODO MakePkgNeedsExposing"
1169+ = RP_Http Http.Error
1170+ | RP_Data String BS.ByteString
1106− MakeMultipleFilesIntoHtml ->
1107− error "TODO MakeMultipleFilesIntoHtml"
1109− MakeNonMainFilesIntoJavaScript _ _ ->
1173+toRegistryProblemReport :: String -> RegistryProblem -> String -> Help.Report
1110− error "TODO MakeNonMainFilesIntoJavaScript"
1174+toRegistryProblemReport title problem context =
1177+ toHttpErrorReport title err context
1112− MakeCannotOptimizeDebugValues m ms ->
1179+ RP_Data url body ->
1113− Help.report "DEBUG REMNANTS" Nothing
1180+ Help.report title Nothing (context ++ ", so I fetched:")
1114− "There are uses of the `Debug` module in the following modules:"
1115− [ D.indent 4 $ D.red $ D.vcat $ map (D.fromChars . ModuleName.toChars) (m:ms)
1181+ [ D.indent 4 $ D.dullyellow $ D.fromChars url
1116− , D.reflow "But the --optimize flag only works if all `Debug` functions are removed!"
1118− "The issue is that --optimize strips out info needed by `Debug` functions.\
1119− \ Here are two examples:"
1120− , D.indent 4 $ D.reflow $
1121− "(1) It shortens record field names. This makes the generated JavaScript is\
1122− \ smaller, but `Debug.toString` cannot know the real field names anymore."
1123− , D.indent 4 $ D.reflow $
1124− "(2) Values like `type Height = Height Float` are unboxed. This reduces\
1125− \ allocation, but it also means that `Debug.toString` cannot tell if it is\
1126− \ looking at a `Height` or `Float` value."
1127 , D.reflow $
1182 , D.reflow $
1128− "There are a few other cases like that, and it will be much worse once we start\
1183+ "I got the data back, but it was not what I was expecting. The response\
1129− \ inlining code. That optimization could move `Debug.log` and `Debug.todo` calls,\
1184+ \ body contains " ++ show (BS.length body) ++ " bytes. Here is the "
1130− \ resulting in unpredictable behavior. I hope that clarifies why this restriction\
1185+ ++ if BS.length body <= 76 then "whole thing:" else "beginning:"
1131− \ exists!"
1186+ , D.indent 4 $ D.dullyellow $ D.fromChars $
1132− ]
1187+ if BS.length body <= 76
1133−
1188+ then BS_UTF8.toString body
1134− MakeCannotBuild buildProblem ->
1189+ else take 73 (BS_UTF8.toString body) ++ "..."
1135− case buildProblem of
1136− BuildProjectProblem bp ->
1138− BP_PathUnknown _ ->
1139− error "TODO BP_PathUnknown"
1141− BP_WithBadExtension _ ->
1142− error "TODO BP_WithBadExtension"
1144− BP_WithAmbiguousSrcDir _ _ ->
1145− error "TODO BP_WithAmbiguousSrcDir"
1147− BP_MainPathDuplicate _ _ ->
1148− error "TODO BP_MainPathDuplicate"
1150− BP_MainNameDuplicate _ _ _ ->
1151− error "TODO BP_MainNameDuplicate"
1153− BP_CannotLoadDependencies ->
1154− error "TODO BP_CannotLoadDependencies"
1156− BP_Cycle name names ->
1157− Help.report "IMPORT CYCLE" Nothing
1158− "Your module imports form a cycle:"
1159− [ D.cycle 4 name names
1160− , D.reflow $
1190+ , D.reflow $
1161− "Learn more about why this is disallowed and how to break cycles here:"
1191+ "Does this error keep showing up? Maybe there is something weird with your\
1162− ++ D.makeLink "import-cycles"
1192+ \ internet connection. We have gotten reports that schools, businesses,\
1163− ]
1193+ \ airports, etc. sometimes intercept requests and add things to the body\
1164−
1194+ \ or change its contents entirely. Could that be the problem?"
1165− BP_MissingExposed _ ->
1195+ ]
1166− error "TODO BP_MissingExposed"
1168− BuildModuleProblems p ps ->
1169− Help.compilerReport p ps
1171− MakeCannotLoadArtifacts ->
1172− error "TODO MakeCannotLoadArtifacts"
1198+toHttpErrorReport :: String -> Http.Error -> String -> Help.Report
1199+toHttpErrorReport title err context =
1201+ toHttpReport intro url details =
1202+ Help.report title Nothing intro $
1203+ D.indent 4 (D.dullyellow (D.fromChars url)) : details
1206+ Http.BadUrl url reason ->
1207+ toHttpReport (context ++ ", so I wanted to fetch:") url
1208+ [ D.reflow $ "But my HTTP library is saying this is not a valid URL. It is saying:"
1209+ , D.indent 4 $ D.fromChars reason
1211+ "This may indicate that there is some problem in the compiler, so please open an\
1212+ \ issue at https://github.com/elm/compiler/issues listing your operating system, Elm\
1213+ \ version, the command you ran, the terminal output, and any additional information\
1214+ \ that might help others reproduce the error."
1179−toOutlineReport :: Outline -> Help.Report
1217+ Http.BadHttp url httpExceptionContent ->
1180−toOutlineReport problem =
1218+ case httpExceptionContent of
1181− case problem of
1219+ HTTP.StatusCodeException response _ ->
1182− OutlineHasBadStructure decodeError ->
1220+ let
1183− Json.toReport "elm.json" (Json.FailureToReport toOutlineProblemReport) decodeError $
1221+ (HTTP.Status code message) = HTTP.responseStatus response
1184− Json.ExplicitReason "I ran into a problem with your elm.json file."
1222+ in
1223+ toHttpReport (context ++ ", so I tried to fetch:") url
1225+ ["But","it","came","back","as",D.red (D.fromInt code)]
1226+ ++ map D.fromChars (words (BS_UTF8.toString message))
1228+ "This may mean some online endpoint changed in an unexpected way, so if does not\
1229+ \ seem like something on your side is causing this (e.g. firewall) please report\
1230+ \ this to https://github.com/elm/compiler/issues with your operating system, Elm\
1231+ \ version, the command you ran, the terminal output, and any additional information\
1232+ \ that can help others reproduce the error!"
1186− OutlineHasBadSrcDirs dir dirs ->
1235+ HTTP.TooManyRedirects responses ->
1187− case dirs of
1236+ toHttpReport (context ++ ", so I tried to fetch:") url
1188− [] ->
1237+ [ D.reflow $ "But I gave up after following these " ++ show (length responses) ++ " redirects:"
1189− Help.report "MISSING SOURCE DIRECTORY" (Just "elm.json")
1238+ , D.indent 4 $ D.vcat $ map toRedirectDoc responses
1190− "I need a valid elm.json file, but the \"source-directories\" field lists the following directory:"
1191− [ D.indent 4 $ D.dullyellow $ D.fromChars dir
1192 , D.reflow $
1239 , D.reflow $
1193− "I cannot find it though. Is it missing? Is there a typo?"
1240+ "Is it possible that your internet connection intercepts certain requests? That\
1241+ \ sometimes causes problems for folks in schools, businesses, airports, hotels,\
1242+ \ and certain countries. Try asking for help locally or in a community forum!"
1196− _:_ ->
1245+ otherException ->
1197− Help.report "MISSING SOURCE DIRECTORIES" (Just "elm.json")
1246+ toHttpReport (context ++ ", so I tried to fetch:") url
1198− "I need a valid elm.json file, but the \"source-directories\" field lists the following directories:"
1247+ [ D.reflow $ "But my HTTP library is giving me the following error message:"
1199− [ D.indent 4 $ D.dullyellow $ D.fromChars dir
1248+ , D.indent 4 $ D.fromChars (show otherException)
1200 , D.reflow $
1249 , D.reflow $
1201− "I cannot find them though. Are they missing? Are there typos?"
1250+ "Are you somewhere with a slow internet connection? Or no internet?\
1251+ \ Does the link I am trying to fetch work in your browser? Maybe the\
1252+ \ site is down? Does your internet connection have a firewall that\
1253+ \ blocks certain domains? It is usually something like that!"
1204− OutlineNoPkgCore ->
1256+ Http.BadMystery url someException ->
1205− Help.report "MISSING DEPENDENCY" (Just "elm.json")
1257+ toHttpReport (context ++ ", so I tried to fetch:") url
1206− "I need a valid elm.json file, so I need to see an \"elm/core\" dependency in there. Try running:"
1258+ [ D.reflow $ "But I ran into something weird! I was able to extract this error message:"
1207− [ D.indent 4 $ D.green $ "elm install elm/core"
1259+ , D.indent 4 $ D.fromChars (show someException)
1208− , D.reflow "I need it for the default imports that make `List` and `Maybe` available."
1260+ , D.reflow $
1261+ "Is it possible that your internet connection intercepts certain requests? That\
1262+ \ sometimes causes problems for folks in schools, businesses, airports, hotels,\
1263+ \ and certain countries. Try asking for help locally or in a community forum!"
1211− OutlineNoAppCore ->
1212− Help.report "MISSING DEPENDENCY" (Just "elm.json")
1213− "I need a valid elm.json file, so I need to see an \"elm/core\" dependency in there. Try running:"
1214− [ D.indent 4 $ D.green $ "elm install elm/core"
1215− , D.reflow "It has some supporting code that is needed by every Elm application!"
1218− OutlineNoAppJson ->
1267+toRedirectDoc :: HTTP.Response body -> D.Doc
1219− Help.report "MISSING DEPENDENCY" (Just "elm.json")
1268+toRedirectDoc response =
1220− "I need a valid elm.json file, so I need to see an \"elm/json\" dependency in there. Try running:"
1269+ let
1221− [ D.indent 4 $ D.green $ "elm install elm/json"
1270+ (HTTP.Status code message) = HTTP.responseStatus response
1222− , D.reflow "It helps me handle flags and ports."
1271+ in
1223− ]
1272+ case List.lookup HTTP.hLocation (HTTP.responseHeaders response) of
1273+ Just loc -> D.red (D.fromInt code) <> " - " <> D.fromChars (BS_UTF8.toString loc)
1274+ Nothing -> D.red (D.fromInt code) <> " - " <> D.fromChars (BS_UTF8.toString message)
1226−toOutlineProblemReport :: FilePath -> Code.Source -> Json.Context -> A.Region -> OutlineProblem -> Help.Report
1227−toOutlineProblemReport path source _ region problem =
1229− toHighlight row col =
1230− Just $ A.Region (A.Position row col) (A.Position row col)
1232− toSnippet title highlight pair =
1278+-- MAKE
1233− Help.jsonReport title (Just path) $
1234− Code.toSnippet source region highlight pair
1238− toSnippet "UNEXPECTED TYPE" Nothing
1240− "I got stuck while reading your elm.json file. I cannot handle a \"type\" like this:"
1242− ["Try","changing","the","\"type\"","to"
1243− ,D.green "\"application\"","or",D.green "\"package\"","instead."
1247− OP_BadPkgName row col ->
1248− toSnippet "INVALID PACKAGE NAME" (toHighlight row col)
1250− "I got stuck while reading your elm.json file. I ran into trouble with the package name:"
1253− ["Package","names","are","always","written","as"
1254− ,D.green "\"author/project\""
1255− ,"so","I","am","expecting","to","see","something","like:"
1257− , D.dullyellow $ D.indent 4 $ D.vcat $
1258− [ "\"mdgriffith/elm-ui\""
1259− , "\"w0rm/elm-physics\""
1260− , "\"Microsoft/elm-json-tree-view\""
1261− , "\"FordLabs/elm-star-rating\""
1262− , "\"1602/json-schema\""
1265− "The author name should match your GitHub name exactly, and the project name\
1266− \ needs to follow these rules:"
1267− , D.indent 4 $ D.vcat $
1268− [ "+--------------------------------------+-----------+-----------+"
1269− , "| RULE | BAD | GOOD |"
1270− , "+--------------------------------------+-----------+-----------+"
1271− , "| only lower case, digits, and hyphens | elm-HTTP | elm-http |"
1272− , "| no leading digits | 3D | elm-3d |"
1273− , "| no non-ASCII characters | elm-bjørn | elm-bear |"
1274− , "| no underscores | elm_ui | elm-ui |"
1275− , "| no double hyphens | elm--hash | elm-hash |"
1276− , "| no starting or ending hyphen | -elm-tar- | elm-tar |"
1277− , "+--------------------------------------+-----------+-----------+"
1280− "These rules only apply to the project name, so you should never need\
1281− \ to change your GitHub name!"
1285− OP_BadVersion row col ->
1281+data Make
1286− toSnippet "PROBLEM WITH VERSION" (toHighlight row col)
1282+ = MakeNoOutline
1287− ( D.reflow $
1283+ | MakeCannotOptimizeAndDebug
1288− "I got stuck while reading your elm.json file. I was expecting a version number here:"
1284+ | MakeBlockedByDetailsProblem Details
1285+ | MakeAppNeedsFileNames
1286+ | MakePkgNeedsExposing
1287+ | MakeMultipleFilesIntoHtml
1288+ | MakeNonMainFilesIntoJavaScript ModuleName.Raw [ModuleName.Raw]
1289+ | MakeCannotBuild BuildProblem
1290+ | MakeBadGenerate Generate
1293+makeToReport :: Make -> Help.Report
1297+ Help.report "NO elm.json FILE" Nothing
1298+ "It looks like you are starting a new Elm project. Very exciting! Try running:"
1299+ [ D.indent 4 $ D.green $ "elm init"
1301+ "It will help you get set up. It is really simple!"
1304+ MakeCannotOptimizeAndDebug ->
1305+ Help.docReport "CLASHING FLAGS" Nothing
1289− , D.fillSep
1306+ ( D.fillSep
1290− ["I","need","something","like",D.green "\"1.0.0\"","or",D.green "\"2.0.4\""
1307+ ["I","cannot","compile","with",D.red "--optimize","and"
1291− ,"that","explicitly","states","all","three","numbers!"
1308+ ,D.red "--debug","at","the","same","time."
1312+ "I need to take away information to optimize things, and I need to\
1313+ \ add information to add the debugger. It is impossible to do both\
1314+ \ at once though! Pick just one of those flags and it should work!"
1295− OP_BadConstraint constraintError ->
1317+ MakeBlockedByDetailsProblem detailsProblem ->
1296− case constraintError of
1318+ toDetailsReport detailsProblem
1297− C.BadFormat row col ->
1298− toSnippet "PROBLEM WITH CONSTRAINT" (toHighlight row col)
1300− "I got stuck while reading your elm.json file. I do not understand this version constraint:"
1303− ["I","need","something","like",D.green "\"1.0.0 <= v < 2.0.0\""
1304− ,"that","explicitly","lists","the","lower","and","upper","bounds."
1307− "The spaces in there are required! Taking them out will confuse me. Adding\
1308− \ extra spaces confuses me too. I recommend starting with a valid example\
1309− \ and just changing the version numbers."
1313− C.InvalidRange before after ->
1320+ MakeAppNeedsFileNames ->
1314− if before == after then
1321+ Help.report "NO INPUT" Nothing
1315− toSnippet "PROBLEM WITH CONSTRAINT" Nothing
1322+ "What should I make though? I need a specific file like this:"
1316− ( D.reflow $
1323+ [ D.indent 4 $ D.green "elm make src/Main.elm"
1317− "I got stuck while reading your elm.json file. I ran into an invalid version constraint:"
1324+ , D.reflow
1318− , D.fillSep
1325+ "However many files you give, I will create one JS file out of them."
1319− ["Elm","checks","that","all","package","APIs","follow","semantic","versioning,"
1320− ,"so","it","is","best","to","use","wide","constraints.","I","recommend"
1321− ,D.green $ "\"" <> D.fromVersion before <> " <= v < " <> D.fromVersion (V.bumpMajor after) <> "\""
1322− ,"since","it","is","guaranteed","that","breaking","API","changes","cannot"
1323− ,"happen","in","any","of","the","versions","in","that","range."
1327− else
1328+ MakePkgNeedsExposing ->
1328− toSnippet "PROBLEM WITH CONSTRAINT" Nothing
1329+ error "TODO MakePkgNeedsExposing"
1330− "I got stuck while reading your elm.json file. I ran into an invalid version constraint:"
1332− ["Maybe","you","want","something","like"
1333− ,D.green $ "\"" <> D.fromVersion before <> " <= v < " <> D.fromVersion (V.bumpMajor before) <> "\""
1334− ,"instead?","Elm","checks","that","all","package","APIs","follow","semantic"
1335− ,"versioning,","so","it","is","guaranteed","that","breaking","API","changes"
1336− ,"cannot","happen","in","any","of","the","versions","in","that","range."
1340− OP_BadModuleName row col ->
1331+ MakeMultipleFilesIntoHtml ->
1341− toSnippet "PROBLEM WITH MODULE NAME" (toHighlight row col)
1332+ error "TODO MakeMultipleFilesIntoHtml"
1343− "I got stuck while reading your elm.json file. I was expecting a module name here:"
1334+ MakeNonMainFilesIntoJavaScript _ _ ->
1344− , D.fillSep
1335+ error "TODO MakeNonMainFilesIntoJavaScript"
1345− ["I","need","something","like",D.green "\"Html.Events\""
1336+
1346− ,"or",D.green "\"Browser.Navigation\""
1337+ MakeCannotBuild buildProblem ->
1347− ,"where","each","segment","starts","with","a","capital"
1338+ toBuildProblemReport buildProblem
1348− ,"letter","and","the","segments","are","separated","by","dots."
1339+
1340+ MakeBadGenerate generateProblem ->
1341+ toGenerateReport generateProblem
1349+ = BuildModuleProblems Error.Module [Error.Module]
1350+ | BuildProjectProblem BuildProjectProblem
1353+data BuildProjectProblem
1354+ = BP_PathUnknown FilePath
1355+ | BP_WithBadExtension FilePath
1356+ | BP_WithAmbiguousSrcDir FilePath FilePath FilePath
1357+ | BP_MainPathDuplicate FilePath FilePath
1358+ | BP_MainNameDuplicate ModuleName.Raw FilePath FilePath
1359+ | BP_CannotLoadDependencies
1360+ | BP_Cycle ModuleName.Raw [ModuleName.Raw]
1361+ | BP_MissingExposed (NE.List (ModuleName.Raw, Import.Problem))
1364+toBuildProblemReport :: BuildProblem -> Help.Report
1365+toBuildProblemReport problem =
1367+ BuildModuleProblems p ps ->
1368+ Help.compilerReport p ps
1370+ BuildProjectProblem projectProblem ->
1371+ case projectProblem of
1372+ BP_PathUnknown path ->
1373+ Help.report "FILE NOT FOUND" Nothing
1374+ "I cannot find this file:"
1375+ [ D.indent 4 $ D.red $ D.fromChars path
1376+ , D.reflow $ "Is there a typo?"
1378+ "If you are just getting started, try working through the examples in the\
1379+ \ official guide https://guide.elm-lang.org to get an idea of the kinds of things\
1380+ \ that typically go in a src/Main.elm file."
1352− OP_BadModuleHeaderTooLong ->
1383+ BP_WithBadExtension path ->
1353− toSnippet "HEADER TOO LONG" Nothing
1384+ Help.report "UNEXPECTED FILE EXTENSION" Nothing
1354− ( D.reflow $
1385+ "I can only compile Elm files (with a .elm extension) but you want me to compile:"
1355− "I got stuck while reading your elm.json file. This section header is too long:"
1386+ [ D.indent 4 $ D.red $ D.fromChars path
1356− , D.fillSep
1387+ , D.reflow $ "Is there a typo? Can the file extension be changed?"
1357− ["I","need","it","to","be"
1358− ,D.green "under",D.green "20",D.green "characters"
1359− ,"so","it","renders","nicely","on","the","package","website!"
1363− OP_BadDependencyName row col ->
1390+ BP_WithAmbiguousSrcDir path srcDir1 srcDir2 ->
1364− toSnippet "PROBLEM WITH DEPENDENCY NAME" (toHighlight row col)
1391+ Help.report "CONFUSING FILE" Nothing
1392+ "I am getting confused when I try to compile this file:"
1393+ [ D.indent 4 $ D.red $ D.fromChars path
1365− ( D.reflow $
1394+ , D.reflow $
1366− "I got stuck while reading your elm.json file. There is something wrong with this dependency name:"
1395+ "I always check if files appear in any of the \"source-directories\" listed in\
1367− , D.stack
1396+ \ your elm.json to see if there might be some cached information about them. That\
1368− [ D.fillSep
1397+ \ can help me compile faster! But in this case, it looks like this file may be in\
1369− ["Package","names","always","include","the","name","of","the","author,"
1398+ \ either of these directories:"
1370− ,"so","I","am","expecting","to","see","dependencies","like"
1399+ , D.indent 4 $ D.red $ D.vcat $ map D.fromChars [srcDir1,srcDir2]
1371− ,D.dullyellow "\"mdgriffith/elm-ui\"","and"
1400+ , D.reflow $
1372− ,D.dullyellow "\"Microsoft/elm-json-tree-view\"" <> "."
1401+ "Try to make it so no source directory contains another source directory!"
1375− ["I","generally","recommend","finding","the","package","you","want","on"
1376− ,"the","package","website,","and","installing","it","with","the"
1377− ,D.green "elm install","command!"
1382− OP_BadLicense _ suggestions ->
1404+ BP_MainPathDuplicate path1 path2 ->
1383− toSnippet "UNKNOWN LICENSE" Nothing
1405+ Help.report "CONFUSING FILES" Nothing
1384− ( D.reflow $
1406+ "You are telling me to compile these two files:"
1385− "I got stuck while reading your elm.json file. I do not know about this type of license:"
1389− ["Elm","packages","generally","use"
1390− ,D.green "\"BSD-3-Clause\"","or",D.green "\"MIT\"" <> ","
1391− ,"but","I","accept","any","OSI","approved","SPDX","license."
1392− ,"Here","some","that","seem","close","to","what","you","wrote:"
1394− , D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromChars . Json.toChars) suggestions
1407+ [ D.indent 4 $ D.red $ D.vcat $ map D.fromChars [ path1, path2 ]
1395 , D.reflow $
1408 , D.reflow $
1396− "Check out https://spdx.org/licenses/ for the full list of options."
1409+ if path1 == path2 then
1410+ "Why are you telling me twice? Is something weird going on with a script?\
1411+ \ I figured I would let you know about it just in case something is wrong.\
1412+ \ Only list it once and you should be all set!"
1414+ "But seem to be the same file though... It makes me think something tricky is\
1415+ \ going on with symlinks in your project, so I figured I would let you know\
1416+ \ about it just in case. Remove one of these files from your command to get\
1400− OP_BadSummaryTooLong ->
1420+ BP_MainNameDuplicate name outsidePath otherPath ->
1401− toSnippet "SUMMARY TOO LONG" Nothing
1421+ Help.report "MODULE NAME CLASH" Nothing
1402− ( D.reflow $
1422+ "These two files are causing a module name clash:"
1403− "I got stuck while reading your elm.json file. Your \"summary\" is too long:"
1423+ [ D.indent 4 $ D.red $ D.vcat $ map D.fromChars [ outsidePath, otherPath ]
1404− , D.fillSep
1424+ , D.reflow $
1405− ["I","need","it","to","be"
1425+ "They both say `module " ++ ModuleName.toChars name ++ " exposing (..)` up\
1406− ,D.green "under",D.green "80",D.green "characters"
1426+ \ at the top, but they cannot have the same name!"
1407− ,"so","it","renders","nicely","on","the","package","website!"
1427+ , D.reflow $
1428+ "Try changing to a different module name in one of them!"
1411− OP_NoSrcDirs ->
1431+ BP_CannotLoadDependencies ->
1412− toSnippet "NO SOURCE DIRECTORIES" Nothing
1432+ corruptCacheReport
1434+ BP_Cycle name names ->
1435+ Help.report "IMPORT CYCLE" Nothing
1436+ "Your module imports form a cycle:"
1437+ [ D.cycle 4 name names
1413− ( D.reflow $
1438+ , D.reflow $
1414− "I got stuck while reading your elm.json file. You do not have any \"source-directories\" listed here:"
1439+ "Learn more about why this is disallowed and how to break cycles here:"
1415− , D.fillSep
1440+ ++ D.makeLink "import-cycles"
1416− ["I","need","something","like",D.green "[\"src\"]"
1417− ,"so","I","know","where","to","look","for","your","modules!"
1443+ BP_MissingExposed _ ->
1444+ error "TODO BP_MissingExposed"
1452+ = GenerateCannotLoadArtifacts
1453+ | GenerateCannotOptimizeDebugValues ModuleName.Raw [ModuleName.Raw]
1456+toGenerateReport :: Generate -> Help.Report
1457+toGenerateReport problem =
1459+ GenerateCannotLoadArtifacts ->
1462+ GenerateCannotOptimizeDebugValues m ms ->
1463+ Help.report "DEBUG REMNANTS" Nothing
1464+ "There are uses of the `Debug` module in the following modules:"
1465+ [ D.indent 4 $ D.red $ D.vcat $ map (D.fromChars . ModuleName.toChars) (m:ms)
1466+ , D.reflow "But the --optimize flag only works if all `Debug` functions are removed!"
1468+ "The issue is that --optimize strips out info needed by `Debug` functions.\
1469+ \ Here are two examples:"
1470+ , D.indent 4 $ D.reflow $
1471+ "(1) It shortens record field names. This makes the generated JavaScript is\
1472+ \ smaller, but `Debug.toString` cannot know the real field names anymore."
1473+ , D.indent 4 $ D.reflow $
1474+ "(2) Values like `type Height = Height Float` are unboxed. This reduces\
1475+ \ allocation, but it also means that `Debug.toString` cannot tell if it is\
1476+ \ looking at a `Height` or `Float` value."
1478+ "There are a few other cases like that, and it will be much worse once we start\
1479+ \ inlining code. That optimization could move `Debug.log` and `Debug.todo` calls,\
1480+ \ resulting in unpredictable behavior. I hope that clarifies why this restriction\
1489+corruptCacheReport :: Help.Report
1490+corruptCacheReport =
1491+ Help.report "CORRUPT CACHE" Nothing
1492+ "It looks like some of the information cached in elm-stuff/ has been corrupted."
1494+ "Try deleting your elm-stuff/ directory to get unstuck."
1496+ "This almost certainly means that a 3rd party tool (or editor plugin) is\
1497+ \ causing problems your the elm-stuff/ directory. Try disabling 3rd party tools\
1498+ \ one by one until you figure out which it is!"
1508+ | ReactorBadDetails Details
1509+ | ReactorBadBuild BuildProblem
1510+ | ReactorBadGenerate Generate
1513+reactorToReport :: Reactor -> Help.Report
1514+reactorToReport problem =
1516+ ReactorNoOutline ->
1517+ error "TODO ReactorNoOutline"
1519+ ReactorBadDetails details ->
1520+ error "TODO ReactorBadDetails" details
1522+ ReactorBadBuild buildProblem ->
1523+ error "TODO ReactorBadBuild" buildProblem
1525+ ReactorBadGenerate generate ->
1526+ toGenerateReport generate