@@ -115,18 +115,11 @@ data Exposing
115 | ExposingOperator Row Col
115 | ExposingOperator Row Col
116 | ExposingOperatorReserved BadOperator Row Col
116 | ExposingOperatorReserved BadOperator Row Col
117 | ExposingOperatorRightParen Row Col
117 | ExposingOperatorRightParen Row Col
118− | ExposingEnd Row Col
120 | ExposingTypePrivacy Row Col
118 | ExposingTypePrivacy Row Col
121− | ExposingTypePrivacyDots Row Col
119+ | ExposingEnd Row Col
122− | ExposingTypePrivacyEnd Row Col
124 | ExposingIndentEnd Row Col
121 | ExposingIndentEnd Row Col
125 | ExposingIndentValue Row Col
122 | ExposingIndentValue Row Col
126− | ExposingIndentValueEnd Row Col
127− | ExposingIndentTypePrivacy Row Col
128− | ExposingIndentTypePrivacyDots Row Col
129− | ExposingIndentTypePrivacyEnd Row Col
@@ -689,7 +682,7 @@ toParseErrorReport source modul =
691 ModuleExposing exposing row col ->
684 ModuleExposing exposing row col ->
692− error "TODO ModuleExposing" exposing row col
685+ toExposingReport source exposing row col
694 PortModuleProblem row col ->
687 PortModuleProblem row col ->
@@ -735,7 +728,7 @@ toParseErrorReport source modul =
737 PortModuleExposing exposing row col ->
730 PortModuleExposing exposing row col ->
738− error "TODO PortModuleExposing" exposing row col
731+ toExposingReport source exposing row col
740 Effect row col ->
733 Effect row col ->
@@ -855,7 +848,7 @@ toParseErrorReport source modul =
855 toImportReport source row col
848 toImportReport source row col
857 ImportExposingList exposing row col ->
850 ImportExposingList exposing row col ->
858− error "TODO ImportExposingList" exposing row col
851+ toExposingReport source exposing row col
860 ImportEnd row col ->
853 ImportEnd row col ->
861 toImportReport source row col
854 toImportReport source row col
@@ -940,6 +933,237 @@ toImportReport source row col =
939+toExposingReport :: Code.Source -> Exposing -> Row -> Col -> Report.Report
940+toExposingReport source exposing startRow startCol =
942+ ExposingSpace space row col ->
943+ toSpaceReport source space row col
945+ ExposingStart row col ->
947+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
948+ region = toRegion row col
950+ Report.Report "PROBLEM IN EXPOSING" region [] $
951+ Code.toSnippet source surroundings (Just region)
954+ "I want to parse exposed values, but I am getting stuck here:"
958+ ["Exposed","values","are","always","surrounded","by","parentheses."
959+ ,"So","try","adding","a",D.green "(","here?"
961+ , D.toSimpleNote "Here are some valid examples of `exposing` for reference:"
962+ , D.indent 4 $ D.vcat $
963+ [ D.fillSep [D.cyan "import","Html",D.cyan "exposing","(..)"]
964+ , D.fillSep [D.cyan "import","Html",D.cyan "exposing","(Html, div, text)"]
967+ "If you are getting tripped up, you can just expose everything for now. It should\
968+ \ get easier to make an explicit exposing list as you see more examples in the wild."
972+ ExposingValue row col ->
973+ case Code.whatIsNext source row col of
974+ Code.Keyword keyword ->
976+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
977+ region = toKeywordRegion row col keyword
979+ Report.Report "RESERVED WORD" region [] $
980+ Code.toSnippet source surroundings (Just region)
983+ "I got stuck on this reserved word:"
986+ "It looks like you are trying to expose `" ++ keyword ++ "` but that is a reserved word. Is there a typo?"
991+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
992+ region = toKeywordRegion row col op
994+ Report.Report "UNEXPECTED SYMBOL" region [] $
995+ Code.toSnippet source surroundings (Just region)
998+ "I got stuck on this symbol:"
1002+ "If you are trying to expose an operator, add parentheses around it like this:"
1003+ , D.indent 4 $ D.dullyellow (D.fromChars op) <> " -> " <> D.green ("(" <> D.fromChars op <> ")")
1009+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1010+ region = toRegion row col
1012+ Report.Report "PROBLEM IN EXPOSING" region [] $
1013+ Code.toSnippet source surroundings (Just region)
1016+ "I got stuck while parsing these exposed values:"
1020+ "I do not have an exact recommendation, so here are some valid examples\
1021+ \ of `exposing` for reference:"
1022+ , D.indent 4 $ D.vcat $
1023+ [ D.fillSep [D.cyan "import","Html",D.cyan "exposing","(..)"]
1024+ , D.fillSep [D.cyan "import","Basics",D.cyan "exposing","(Int, Float, Bool(..), (+), not, sqrt)"]
1027+ "These examples show how to expose types, variants, operators, and functions. Everything\
1028+ \ should be some permutation of these examples, just with different names."
1032+ ExposingOperator row col ->
1034+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1035+ region = toRegion row col
1037+ Report.Report "PROBLEM IN EXPOSING" region [] $
1038+ Code.toSnippet source surroundings (Just region)
1041+ "I just saw an open parenthesis, so I was expecting an operator next:"
1044+ ["It","is","possible","to","expose","operators,","so","I","was","expecting"
1045+ ,"to","see","something","like",D.dullyellow "(+)","or",D.dullyellow "(|=)"
1046+ ,"or",D.dullyellow "(||)","after","I","saw","that","open","parenthesis."
1050+ ExposingOperatorReserved op row col ->
1052+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1053+ region = toRegion row col
1055+ Report.Report "RESERVED SYMBOL" region [] $
1056+ Code.toSnippet source surroundings (Just region)
1059+ "I cannot expose this as an operator:"
1062+ BadDot -> D.reflow "Try getting rid of this entry? Maybe I can give you a better hint after that?"
1063+ BadPipe -> D.fillSep ["Maybe","you","want",D.dullyellow "(||)","instead?"]
1064+ BadArrow -> D.reflow "Try getting rid of this entry? Maybe I can give you a better hint after that?"
1065+ BadEquals -> D.fillSep ["Maybe","you","want",D.dullyellow "(==)","instead?"]
1066+ BadHasType -> D.fillSep ["Maybe","you","want",D.dullyellow "(::)","instead?"]
1069+ ExposingOperatorRightParen row col ->
1071+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1072+ region = toRegion row col
1074+ Report.Report "PROBLEM IN EXPOSING" region [] $
1075+ Code.toSnippet source surroundings (Just region)
1078+ "It looks like you are exposing an operator, but I got stuck here:"
1081+ ["I","was","expecting","to","see","the","closing","parenthesis","immediately"
1082+ ,"after","the","operator.","Try","adding","a",D.green ")","right","here?"
1086+ ExposingEnd row col ->
1088+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1089+ region = toRegion row col
1091+ Report.Report "UNFINISHED EXPOSING" region [] $
1092+ Code.toSnippet source surroundings (Just region)
1095+ "I was partway through parsing exposed values, but I got stuck here:"
1098+ "Maybe there is a comma missing before this?"
1101+ ExposingTypePrivacy row col ->
1103+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1104+ region = toRegion row col
1106+ Report.Report "PROBLEM EXPOSING CUSTOM TYPE VARIANTS" region [] $
1107+ Code.toSnippet source surroundings (Just region)
1110+ "It looks like you are trying to expose the variants of a custom type:"
1114+ ["You","need","to","write","something","like"
1115+ ,D.dullyellow "Status(..)","or",D.dullyellow "Entity(..)"
1116+ ,"though.","It","is","all","or","nothing,","otherwise","`case`"
1117+ ,"expressions","could","miss","a","variant","and","crash!"
1120+ "It is often best to keep the variants hidden! If someone pattern matches on\
1121+ \ the variants, it is a MAJOR change if any new variants are added. Suddenly\
1122+ \ their `case` expressions do not cover all variants! So if you do not need\
1123+ \ people to pattern match, keep the variants hidden and expose functions to\
1124+ \ construct values of this type. This way you can add new variants as a MINOR change!"
1128+ ExposingIndentEnd row col ->
1130+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1131+ region = toRegion row col
1133+ Report.Report "UNFINISHED EXPOSING" region [] $
1134+ Code.toSnippet source surroundings (Just region)
1137+ "I was partway through parsing exposed values, but I got stuck here:"
1141+ ["I","was","expecting","a","closing","parenthesis."
1142+ ,"Try","adding","a",D.green ")","right","here?"
1145+ "I can get confused when there is not enough indentation, so if you already\
1146+ \ have a closing parenthesis, it probably just needs some spaces in front of it."
1150+ ExposingIndentValue row col ->
1152+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1153+ region = toRegion row col
1155+ Report.Report "UNFINISHED EXPOSING" region [] $
1156+ Code.toSnippet source surroundings (Just region)
1159+ "I was partway through parsing exposed values, but I got stuck here:"
1162+ "I was expecting another value to expose."
943-- SPACES
1167-- SPACES