@@ -4,6 +4,7 @@ module Reporting.Exit
4 , Diff(..), diffToReport
4 , Diff(..), diffToReport
5 , Make(..), makeToReport
5 , Make(..), makeToReport
6 , Bump(..), bumpToReport
6 , Bump(..), bumpToReport
7+ , Repl(..), replToReport
7 , Publish(..), publishToReport
8 , Publish(..), publishToReport
8 , Install(..), installToReport
9 , Install(..), installToReport
9 , Reactor(..), reactorToReport
10 , Reactor(..), reactorToReport
@@ -30,6 +31,7 @@ module Reporting.Exit
30import qualified Data.ByteString as BS
31import qualified Data.ByteString as BS
31import qualified Data.ByteString.UTF8 as BS_UTF8
32import qualified Data.ByteString.UTF8 as BS_UTF8
32import qualified Data.List as List
33import qualified Data.List as List
34+import qualified Data.Name as N
33import qualified Data.NonEmptyList as NE
35import qualified Data.NonEmptyList as NE
34import qualified Network.HTTP.Client as HTTP
36import qualified Network.HTTP.Client as HTTP
35import qualified Network.HTTP.Types.Header as HTTP
37import qualified Network.HTTP.Types.Header as HTTP
@@ -40,6 +42,7 @@ import qualified Elm.Magnitude as M
40import qualified Elm.ModuleName as ModuleName
42import qualified Elm.ModuleName as ModuleName
41import qualified Elm.Package as Pkg
43import qualified Elm.Package as Pkg
42import qualified Elm.Version as V
44import qualified Elm.Version as V
43import qualified Http
46import qualified Http
44import qualified Json.Decode as Decode
47import qualified Json.Decode as Decode
45import qualified Json.Encode as Encode
48import qualified Json.Encode as Encode
@@ -1480,7 +1483,7 @@ makeToReport make =
1482data BuildProblem
1485data BuildProblem
1483− = BuildModuleProblems Error.Module [Error.Module]
1486+ = BuildBadModules Error.Module [Error.Module]
1484 | BuildProjectProblem BuildProjectProblem
1487 | BuildProjectProblem BuildProjectProblem
@@ -1498,84 +1501,89 @@ data BuildProjectProblem
1498toBuildProblemReport :: BuildProblem -> Help.Report
1501toBuildProblemReport :: BuildProblem -> Help.Report
1499toBuildProblemReport problem =
1502toBuildProblemReport problem =
1500 case problem of
1503 case problem of
1501− BuildModuleProblems p ps ->
1504+ BuildBadModules e es ->
1502− Help.compilerReport p ps
1505+ Help.compilerReport e es
1504 BuildProjectProblem projectProblem ->
1507 BuildProjectProblem projectProblem ->
1505− case projectProblem of
1508+ toProjectProblemReport projectProblem
1506− BP_PathUnknown path ->
1507− Help.report "FILE NOT FOUND" Nothing
1508− "I cannot find this file:"
1509− [ D.indent 4 $ D.red $ D.fromChars path
1510− , D.reflow $ "Is there a typo?"
1512− "If you are just getting started, try working through the examples in the\
1513− \ official guide https://guide.elm-lang.org to get an idea of the kinds of things\
1514− \ that typically go in a src/Main.elm file."
1517− BP_WithBadExtension path ->
1518− Help.report "UNEXPECTED FILE EXTENSION" Nothing
1519− "I can only compile Elm files (with a .elm extension) but you want me to compile:"
1520− [ D.indent 4 $ D.red $ D.fromChars path
1521− , D.reflow $ "Is there a typo? Can the file extension be changed?"
1524− BP_WithAmbiguousSrcDir path srcDir1 srcDir2 ->
1511+toProjectProblemReport :: BuildProjectProblem -> Help.Report
1512+toProjectProblemReport projectProblem =
1513+ case projectProblem of
1514+ BP_PathUnknown path ->
1525− Help.report "CONFUSING FILE" Nothing
1515+ Help.report "FILE NOT FOUND" Nothing
1526− "I am getting confused when I try to compile this file:"
1516+ "I cannot find this file:"
1527− [ D.indent 4 $ D.red $ D.fromChars path
1517+ [ D.indent 4 $ D.red $ D.fromChars path
1528− , D.reflow $
1518+ , D.reflow $ "Is there a typo?"
1529− "I always check if files appear in any of the \"source-directories\" listed in\
1519+ , D.toSimpleNote $
1530− \ your elm.json to see if there might be some cached information about them. That\
1520+ "If you are just getting started, try working through the examples in the\
1531− \ can help me compile faster! But in this case, it looks like this file may be in\
1521+ \ official guide https://guide.elm-lang.org to get an idea of the kinds of things\
1532− \ either of these directories:"
1522+ \ that typically go in a src/Main.elm file."
1533− , D.indent 4 $ D.red $ D.vcat $ map D.fromChars [srcDir1,srcDir2]
1535− "Try to make it so no source directory contains another source directory!"
1538− BP_MainPathDuplicate path1 path2 ->
1525+ BP_WithBadExtension path ->
1539− Help.report "CONFUSING FILES" Nothing
1526+ Help.report "UNEXPECTED FILE EXTENSION" Nothing
1540− "You are telling me to compile these two files:"
1527+ "I can only compile Elm files (with a .elm extension) but you want me to compile:"
1541− [ D.indent 4 $ D.red $ D.vcat $ map D.fromChars [ path1, path2 ]
1528+ [ D.indent 4 $ D.red $ D.fromChars path
1542− , D.reflow $
1529+ , D.reflow $ "Is there a typo? Can the file extension be changed?"
1543− if path1 == path2 then
1544− "Why are you telling me twice? Is something weird going on with a script?\
1545− \ I figured I would let you know about it just in case something is wrong.\
1546− \ Only list it once and you should be all set!"
1548− "But seem to be the same file though... It makes me think something tricky is\
1549− \ going on with symlinks in your project, so I figured I would let you know\
1550− \ about it just in case. Remove one of these files from your command to get\
1554− BP_MainNameDuplicate name outsidePath otherPath ->
1532+ BP_WithAmbiguousSrcDir path srcDir1 srcDir2 ->
1555− Help.report "MODULE NAME CLASH" Nothing
1533+ Help.report "CONFUSING FILE" Nothing
1556− "These two files are causing a module name clash:"
1534+ "I am getting confused when I try to compile this file:"
1535+ [ D.indent 4 $ D.red $ D.fromChars path
1537+ "I always check if files appear in any of the \"source-directories\" listed in\
1538+ \ your elm.json to see if there might be some cached information about them. That\
1539+ \ can help me compile faster! But in this case, it looks like this file may be in\
1540+ \ either of these directories:"
1557− [ D.indent 4 $ D.red $ D.vcat $ map D.fromChars [ outsidePath, otherPath ]
1541+ , D.indent 4 $ D.red $ D.vcat $ map D.fromChars [srcDir1,srcDir2]
1558− , D.reflow $
1542+ , D.reflow $
1559− "They both say `module " ++ ModuleName.toChars name ++ " exposing (..)` up\
1543+ "Try to make it so no source directory contains another source directory!"
1560− \ at the top, but they cannot have the same name!"
1562− "Try changing to a different module name in one of them!"
1565− BP_CannotLoadDependencies ->
1546+ BP_MainPathDuplicate path1 path2 ->
1566− corruptCacheReport
1547+ Help.report "CONFUSING FILES" Nothing
1548+ "You are telling me to compile these two files:"
1549+ [ D.indent 4 $ D.red $ D.vcat $ map D.fromChars [ path1, path2 ]
1551+ if path1 == path2 then
1552+ "Why are you telling me twice? Is something weird going on with a script?\
1553+ \ I figured I would let you know about it just in case something is wrong.\
1554+ \ Only list it once and you should be all set!"
1556+ "But seem to be the same file though... It makes me think something tricky is\
1557+ \ going on with symlinks in your project, so I figured I would let you know\
1558+ \ about it just in case. Remove one of these files from your command to get\
1562+ BP_MainNameDuplicate name outsidePath otherPath ->
1563+ Help.report "MODULE NAME CLASH" Nothing
1564+ "These two files are causing a module name clash:"
1565+ [ D.indent 4 $ D.red $ D.vcat $ map D.fromChars [ outsidePath, otherPath ]
1567+ "They both say `module " ++ ModuleName.toChars name ++ " exposing (..)` up\
1568+ \ at the top, but they cannot have the same name!"
1570+ "Try changing to a different module name in one of them!"
1573+ BP_CannotLoadDependencies ->
1568− BP_Cycle name names ->
1576+ BP_Cycle name names ->
1569− Help.report "IMPORT CYCLE" Nothing
1577+ Help.report "IMPORT CYCLE" Nothing
1570− "Your module imports form a cycle:"
1578+ "Your module imports form a cycle:"
1571− [ D.cycle 4 name names
1579+ [ D.cycle 4 name names
1572− , D.reflow $
1580+ , D.reflow $
1573− "Learn more about why this is disallowed and how to break cycles here:"
1581+ "Learn more about why this is disallowed and how to break cycles here:"
1574− ++ D.makeLink "import-cycles"
1582+ ++ D.makeLink "import-cycles"
1577− BP_MissingExposed _ ->
1585+ BP_MissingExposed _ ->
1578− error "TODO BP_MissingExposed"
1586+ error "TODO BP_MissingExposed"
@@ -1662,3 +1670,42 @@ reactorToReport problem =
1663 ReactorBadGenerate generate ->
1671 ReactorBadGenerate generate ->
1664 toGenerateReport generate
1672 toGenerateReport generate
1680+ = ReplBadDetails Details
1681+ | ReplBadInput BS.ByteString Error.Error
1682+ | ReplBadLocalDeps Error.Module [Error.Module]
1683+ | ReplProjectProblem BuildProjectProblem
1684+ | ReplBadGenerate Generate
1689+replToReport :: Repl -> Help.Report
1690+replToReport problem =
1692+ ReplBadDetails details ->
1693+ toDetailsReport details
1695+ ReplBadInput source err ->
1696+ Help.compilerReport (Error.Module N.replModule "REPL" File.zeroTime source err) []
1698+ ReplBadLocalDeps e es ->
1699+ Help.compilerReport e es
1701+ ReplProjectProblem projectProblem ->
1702+ toProjectProblemReport projectProblem
1704+ ReplBadGenerate generate ->
1705+ toGenerateReport generate
1711+ error "TODO ReplBlocked"