@@ -78,19 +78,16 @@ data Error
7878data Module
7979 = ModuleSpace Space Row Col
8080 | ModuleEndOfFile Row Col
81− | Module Row Col
81+ --
82+ | ModuleProblem Row Col
8283 | ModuleName Row Col
83− | ModuleExposing Row Col
84− | ModuleExposingList Exposing Row Col
84+ | ModuleExposing Exposing Row Col
8585 --
86− | ModulePortModule Row Col
87− | ModuleEffect Row Col
86+ | PortModuleProblem Row Col
87+ | PortModuleName Row Col
88+ | PortModuleExposing Exposing Row Col
8889 --
89− | ModuleIndentStart Row Col
90− | ModuleIndentName Row Col
91− | ModuleIndentExposing Row Col
92− | ModuleIndentExposingList Row Col
93− | ModuleIndentPortModule Row Col
90+ | Effect Row Col
9491 --
9592 | FreshLineModuleStart Row Col
9693 | FreshLineAfterModuleLine Row Col
@@ -577,38 +574,118 @@ toParseErrorReport source modul =
577574 \ left to see, so whatever I am running into is confusing me a lot!"
578575 )
579576
580− Module row col ->
581− error "TODO Module" row col
577+ ModuleProblem row col ->
578+ let
579+ region = toRegion row col
580+ in
581+ Report.Report "UNFINISHED MODULE DECLARATION" region [] $
582+ Code.toSnippet source region Nothing
583+ (
584+ D.reflow $
585+ "I am parsing an `module` declaration, but I got stuck here:"
586+ ,
587+ D.stack
588+ [ D.reflow $
589+ "Here are some examples of valid `module` declarations:"
590+ , D.indent 4 $ D.vcat $
591+ [ D.fillSep [D.blue "module","Main",D.blue "exposing","(..)"]
592+ , D.fillSep [D.blue "module","Dict",D.blue "exposing","(Dict, empty, get)"]
593+ ]
594+ , D.reflow $
595+ "I generally recommend using an explicit exposing list. I can skip compiling a bunch\
596+ \ of files when the public interface of a module stays the same, so exposing fewer\
597+ \ values can help improve compile times!"
598+ ]
599+ )
582600
583601 ModuleName row col ->
584− error "TODO ModuleName" row col
585−
586− ModuleExposing row col ->
587− error "TODO ModuleExposing" row col
588−
589− ModuleExposingList exposing row col ->
590− error "TODO ModuleExposingList" exposing row col
591−
592− ModulePortModule row col ->
593− error "TODO ModulePortModule" row col
594−
595− ModuleEffect row col ->
596− error "TODO ModuleEffect" row col
602+ let
603+ region = toRegion row col
604+ in
605+ Report.Report "EXPECTING MODULE NAME" region [] $
606+ Code.toSnippet source region Nothing
607+ (
608+ D.reflow $
609+ "I was parsing an `module` declaration until I got stuck here:"
610+ ,
611+ D.stack
612+ [ D.reflow $
613+ "I was expecting to see the module name next, like in these examples:"
614+ , D.indent 4 $ D.vcat $
615+ [ D.fillSep [D.blue "module","Dict",D.blue "exposing","(..)"]
616+ , D.fillSep [D.blue "module","Maybe",D.blue "exposing","(..)"]
617+ , D.fillSep [D.blue "module","Html.Attributes",D.blue "exposing","(..)"]
618+ , D.fillSep [D.blue "module","Json.Decode",D.blue "exposing","(..)"]
619+ ]
620+ , D.reflow $
621+ "Notice that the module names all start with capital letters. That is required!"
622+ ]
623+ )
597624
598− ModuleIndentStart row col ->
599− error "TODO ModuleIndentStart" row col
625+ ModuleExposing exposing row col ->
626+ error "TODO ModuleExposing" exposing row col
600627
601− ModuleIndentName row col ->
602− error "TODO ModuleIndentName" row col
628+ PortModuleProblem row col ->
629+ let
630+ region = toRegion row col
631+ in
632+ Report.Report "UNFINISHED PORT MODULE DECLARATION" region [] $
633+ Code.toSnippet source region Nothing
634+ (
635+ D.reflow $
636+ "I am parsing an `port module` declaration, but I got stuck here:"
637+ ,
638+ D.stack
639+ [ D.reflow $
640+ "Here are some examples of valid `port module` declarations:"
641+ , D.indent 4 $ D.vcat $
642+ [ D.fillSep [D.blue "port",D.blue "module","WebSockets",D.blue "exposing","(send, listen, keepAlive)"]
643+ , D.fillSep [D.blue "port",D.blue "module","Maps",D.blue "exposing","(Location, goto)"]
644+ ]
645+ , D.reflow $
646+ "Go to the section in https://guide.elm-lang.org on ports for more information!"
647+ ]
648+ )
603649
604− ModuleIndentExposing row col ->
605− error "TODO ModuleIndentExposing" row col
650+ PortModuleName row col ->
651+ let
652+ region = toRegion row col
653+ in
654+ Report.Report "EXPECTING MODULE NAME" region [] $
655+ Code.toSnippet source region Nothing
656+ (
657+ D.reflow $
658+ "I was parsing an `module` declaration until I got stuck here:"
659+ ,
660+ D.stack
661+ [ D.reflow $
662+ "I was expecting to see the module name next, like in these examples:"
663+ , D.indent 4 $ D.vcat $
664+ [ D.fillSep [D.blue "port",D.blue "module","WebSockets",D.blue "exposing","(send, listen, keepAlive)"]
665+ , D.fillSep [D.blue "port",D.blue "module","Maps",D.blue "exposing","(Location, goto)"]
666+ ]
667+ , D.reflow $
668+ "Notice that the module names start with capital letters. That is required!"
669+ ]
670+ )
606671
607− ModuleIndentExposingList row col ->
608− error "TODO ModuleIndentExposingList" row col
672+ PortModuleExposing exposing row col ->
673+ error "TODO PortModuleExposing" exposing row col
609674
610− ModuleIndentPortModule row col ->
611− error "TODO ModuleIndentPortModule" row col
675+ Effect row col ->
676+ let
677+ region = toRegion row col
678+ in
679+ Report.Report "BAD MODULE DECLARATION" region [] $
680+ Code.toSnippet source region Nothing
681+ (
682+ D.reflow $
683+ "I cannot parse this module declaration:"
684+ ,
685+ D.reflow $
686+ "This type of module is reserved for the @elm organization. It is used to\
687+ \ define certain effects, avoiding building them into the compiler."
688+ )
612689
613690 FreshLineModuleStart row col ->
614691 error "TODO FreshLineModuleStart" row col