@@ -2683,22 +2683,26 @@ toOperatorReport source context operator row col =
2684 Report.Report "UNEXPECTED ARROW" region [] $
2684 Report.Report "UNEXPECTED ARROW" region [] $
2685 Code.toSnippet source region Nothing $
2685 Code.toSnippet source region Nothing $
2686− if isWithin NBranch context then
2686+ if isWithin NCase context then
2688 D.reflow $
2688 D.reflow $
2689− "I was not expecting to see an arrow here:"
2689+ "I am parsing a `case` expression right now, but this arrow is confusing me:"
2692− [
2692+ [ D.reflow "Maybe the `of` keyword is missing on a previous line?"
2697+ else if isWithin NBranch context then
2693− D.reflow $
2699+ D.reflow $
2694− "I think I am parsing a `case` expression right now, so it makes sense to\
2700+ "I am parsing a `case` expression right now, but this arrow is confusing me:"
2695− \ see arrows around here. This one is confusing me though!"
2701+ ,
2697− D.toSimpleHint $
2703+ [ D.reflow $
2698− "I may be getting confused by the indentation. Every pattern in a `case` must be\
2704+ "It makes sense to see arrows around here, so I suspect it is something earlier."
2699− \ exactly aligned (with exactly the same amount of indentation) so maybe this arrow\
2705+ , noteForCaseIndentError
2700− \ appears after the next `case` pattern (correctly!) but the pattern itself is\
2701− \ indented too far?"
@@ -3290,9 +3294,10 @@ toCaseReport source context case_ startRow startCol =
3290 D.reflow $
3294 D.reflow $
3291 "I am partway through parsing a `case` expression, but I got stuck here:"
3295 "I am partway through parsing a `case` expression, but I got stuck here:"
3293− addNoteForCaseIndentError $
3297+ D.stack
3295− "I was expecting to see an arrow next."
3298+ [ D.reflow "I was expecting to see an arrow next."
3299+ , noteForCaseIndentError
3298 CaseExpr expr row col ->
3303 CaseExpr expr row col ->
@@ -3346,28 +3351,33 @@ toUnfinishCaseReport source row col startRow startCol message =
3348 [ message
3353 [ message
3349− , D.toSimpleNote $
3354+ , noteForCaseError
3350− "Here is an example of a valid `case` expression for reference."
3352− [ D.indent 4 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
3353− , D.indent 6 $ D.fillSep [D.blue "Just","width","->"]
3354− , D.indent 8 $ D.fillSep ["width","+",D.dullyellow "200"]
3356− , D.indent 6 $ D.fillSep [D.blue "Nothing","->"]
3357− , D.indent 8 $ D.fillSep [D.dullyellow "400"]
3360− "Notice the indentation. Each pattern is aligned, and each branch is indented\
3361− \ a bit more than the corresponding pattern. That is important!"
3366−addNoteForCaseIndentError :: D.Doc -> D.Doc
3359+noteForCaseError :: D.Doc
3367−addNoteForCaseIndentError message =
3360+noteForCaseError =
3368− D.stack $
3361+ D.stack
3369− message
3362+ [ D.toSimpleNote $
3370− :
3363+ "Here is an example of a valid `case` expression for reference."
3365+ [ D.indent 4 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
3366+ , D.indent 6 $ D.fillSep [D.blue "Just","width","->"]
3367+ , D.indent 8 $ D.fillSep ["width","+",D.dullyellow "200"]
3369+ , D.indent 6 $ D.fillSep [D.blue "Nothing","->"]
3370+ , D.indent 8 $ D.fillSep [D.dullyellow "400"]
3373+ "Notice the indentation. Each pattern is aligned, and each branch is indented\
3374+ \ a bit more than the corresponding pattern. That is important!"
3378+noteForCaseIndentError :: D.Doc
3379+noteForCaseIndentError =
3371 [ D.toSimpleNote $
3381 [ D.toSimpleNote $
3372 "Sometimes I get confused by indentation, so try to make your `case` look\
3382 "Sometimes I get confused by indentation, so try to make your `case` look\
3373 \ something like this:"
3383 \ something like this:"