@@ -2683,22 +2683,26 @@ toOperatorReport source context operator row col =
26832683 in
26842684 Report.Report "UNEXPECTED ARROW" region [] $
26852685 Code.toSnippet source region Nothing $
2686− if isWithin NBranch context then
2686+ if isWithin NCase context then
26872687 (
26882688 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:"
26902690 ,
26912691 D.stack
2692− [
2693− D.reflow $
2694− "I think I am parsing a `case` expression right now, so it makes sense to\
2695− \ see arrows around here. This one is confusing me though!"
2696− ,
2697− D.toSimpleHint $
2698− "I may be getting confused by the indentation. Every pattern in a `case` must be\
2699− \ exactly aligned (with exactly the same amount of indentation) so maybe this arrow\
2700− \ appears after the next `case` pattern (correctly!) but the pattern itself is\
2701− \ indented too far?"
2692+ [ D.reflow "Maybe the `of` keyword is missing on a previous line?"
2693+ , noteForCaseError
2694+ ]
2695+ )
2696+
2697+ else if isWithin NBranch context then
2698+ (
2699+ D.reflow $
2700+ "I am parsing a `case` expression right now, but this arrow is confusing me:"
2701+ ,
2702+ D.stack
2703+ [ D.reflow $
2704+ "It makes sense to see arrows around here, so I suspect it is something earlier."
2705+ , noteForCaseIndentError
27022706 ]
27032707 )
27042708
@@ -3290,9 +3294,10 @@ toCaseReport source context case_ startRow startCol =
32903294 D.reflow $
32913295 "I am partway through parsing a `case` expression, but I got stuck here:"
32923296 ,
3293− addNoteForCaseIndentError $
3294− D.reflow $
3295− "I was expecting to see an arrow next."
3297+ D.stack
3298+ [ D.reflow "I was expecting to see an arrow next."
3299+ , noteForCaseIndentError
3300+ ]
32963301 )
32973302
32983303 CaseExpr expr row col ->
@@ -3346,28 +3351,33 @@ toUnfinishCaseReport source row col startRow startCol message =
33463351 ,
33473352 D.stack
33483353 [ message
3349− , D.toSimpleNote $
3350− "Here is an example of a valid `case` expression for reference."
3351− , D.vcat $
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"]
3355− , ""
3356− , D.indent 6 $ D.fillSep [D.blue "Nothing","->"]
3357− , D.indent 8 $ D.fillSep [D.dullyellow "400"]
3358− ]
3359− , D.reflow $
3360− "Notice the indentation. Each pattern is aligned, and each branch is indented\
3361− \ a bit more than the corresponding pattern. That is important!"
3354+ , noteForCaseError
33623355 ]
33633356 )
33643357
33653358
3366−addNoteForCaseIndentError :: D.Doc -> D.Doc
3367−addNoteForCaseIndentError message =
3368− D.stack $
3369− message
3370− :
3359+noteForCaseError :: D.Doc
3360+noteForCaseError =
3361+ D.stack
3362+ [ D.toSimpleNote $
3363+ "Here is an example of a valid `case` expression for reference."
3364+ , D.vcat $
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"]
3368+ , ""
3369+ , D.indent 6 $ D.fillSep [D.blue "Nothing","->"]
3370+ , D.indent 8 $ D.fillSep [D.dullyellow "400"]
3371+ ]
3372+ , D.reflow $
3373+ "Notice the indentation. Each pattern is aligned, and each branch is indented\
3374+ \ a bit more than the corresponding pattern. That is important!"
3375+ ]
3376+
3377+
3378+noteForCaseIndentError :: D.Doc
3379+noteForCaseIndentError =
3380+ D.stack
33713381 [ D.toSimpleNote $
33723382 "Sometimes I get confused by indentation, so try to make your `case` look\
33733383 \ something like this:"