Skip to content

Commit 302b060

Browse files
committed
cosmetic: switch to D.stack format for notes on record types
1 parent 6fd0035 commit 302b060

File tree

1 file changed

+52
-42
lines changed

1 file changed

+52
-42
lines changed

compiler/src/Reporting/Error/Syntax.hs

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3881,7 +3881,7 @@ toRecordReport source context record startRow startCol =
38813881
Code.toSnippet source surroundings (Just region)
38823882
(
38833883
D.reflow $
3884-
"I am partway through parsing a record, but I got stuck after that last comma:"
3884+
"I am partway through parsing a record, but I got stuck here:"
38853885
,
38863886
D.stack
38873887
[ D.reflow $
@@ -5248,11 +5248,13 @@ toTRecordReport source context record startRow startCol =
52485248
D.reflow $
52495249
"I am partway through parsing a record type, but I got stuck after that last comma:"
52505250
,
5251-
addNoteForRecordTypeError $
5252-
D.reflow $
5253-
"Trailing commas are not allowed in records, so I was expecting to see another\
5254-
\ record field defined next. If you are done defining the record, the fix may\
5255-
\ be to delete that last comma?"
5251+
D.stack
5252+
[ D.reflow $
5253+
"Trailing commas are not allowed in records, so I was expecting to see another\
5254+
\ record field defined next. If you are done defining the record, the fix may\
5255+
\ be to delete that last comma?"
5256+
, noteForRecordTypeError
5257+
]
52565258
)
52575259

52585260
TRecordColon row col ->
@@ -5266,11 +5268,13 @@ toTRecordReport source context record startRow startCol =
52665268
D.reflow $
52675269
"I am partway through parsing a record type, but I got stuck here:"
52685270
,
5269-
addNoteForRecordTypeError $
5270-
D.fillSep $
5271-
["I","just","saw","a","field","name,","so","I","was","expecting","to","see"
5272-
,"a","colon","next.","So","try","putting","an",D.green ":","sign","here?"
5273-
]
5271+
D.stack
5272+
[ D.fillSep $
5273+
["I","just","saw","a","field","name,","so","I","was","expecting","to","see"
5274+
,"a","colon","next.","So","try","putting","an",D.green ":","sign","here?"
5275+
]
5276+
, noteForRecordTypeError
5277+
]
52745278
)
52755279

52765280
TRecordType tipe row col ->
@@ -5290,11 +5294,13 @@ toTRecordReport source context record startRow startCol =
52905294
D.reflow $
52915295
"I just saw the opening curly brace of a record type, but then I got stuck here:"
52925296
,
5293-
addNoteForRecordTypeIndentError $
5294-
D.fillSep $
5295-
["I","am","expecting","a","record","like",D.dullyellow "{ name : String, age : Int }","here."
5296-
,"Try","defining","some","fields","of","your","own?"
5297-
]
5297+
D.stack
5298+
[ D.fillSep $
5299+
["I","am","expecting","a","record","like",D.dullyellow "{ name : String, age : Int }","here."
5300+
,"Try","defining","some","fields","of","your","own?"
5301+
]
5302+
, noteForRecordTypeIndentError
5303+
]
52985304
)
52995305

53005306
TRecordIndentEnd row col ->
@@ -5308,10 +5314,12 @@ toTRecordReport source context record startRow startCol =
53085314
D.reflow $
53095315
"I was expecting to see a closing curly brace next:"
53105316
,
5311-
addNoteForRecordTypeIndentError $
5312-
D.fillSep $
5313-
["Try","putting","an",D.green "}","and","see","if","that","helps?"
5314-
]
5317+
D.stack
5318+
[ D.fillSep $
5319+
["Try","putting","an",D.green "}","and","see","if","that","helps?"
5320+
]
5321+
, noteForRecordTypeIndentError
5322+
]
53155323
)
53165324

53175325
TRecordIndentField row col ->
@@ -5325,11 +5333,13 @@ toTRecordReport source context record startRow startCol =
53255333
D.reflow $
53265334
"I am partway through parsing a record type, but I got stuck after that last comma:"
53275335
,
5328-
addNoteForRecordTypeIndentError $
5329-
D.reflow $
5330-
"Trailing commas are not allowed in record types, so the fix may be to\
5331-
\ delete that last comma? Or maybe you were in the middle of defining\
5332-
\ an additional field?"
5336+
D.stack
5337+
[ D.reflow $
5338+
"Trailing commas are not allowed in record types, so the fix may be to\
5339+
\ delete that last comma? Or maybe you were in the middle of defining\
5340+
\ an additional field?"
5341+
, noteForRecordTypeIndentError
5342+
]
53335343
)
53345344

53355345
TRecordIndentColon row col ->
@@ -5344,10 +5354,12 @@ toTRecordReport source context record startRow startCol =
53445354
"I am partway through parsing a record type. I just saw a record\
53455355
\ field, so I was expecting to see a colon next:"
53465356
,
5347-
addNoteForRecordTypeIndentError $
5348-
D.fillSep $
5349-
["Try","putting","an",D.green ":","followed","by","a","type?"
5350-
]
5357+
D.stack
5358+
[ D.fillSep $
5359+
["Try","putting","an",D.green ":","followed","by","a","type?"
5360+
]
5361+
, noteForRecordTypeIndentError
5362+
]
53515363
)
53525364

53535365
TRecordIndentType row col ->
@@ -5361,19 +5373,19 @@ toTRecordReport source context record startRow startCol =
53615373
D.reflow $
53625374
"I am partway through parsing a record type, and I was expecting to run into a type next:"
53635375
,
5364-
addNoteForRecordTypeIndentError $
5365-
D.fillSep $
5366-
["Try","putting","something","like"
5367-
,D.dullyellow "Int","or",D.dullyellow "String","for","now?"
5368-
]
5376+
D.stack
5377+
[ D.fillSep $
5378+
["Try","putting","something","like"
5379+
,D.dullyellow "Int","or",D.dullyellow "String","for","now?"
5380+
]
5381+
, noteForRecordTypeIndentError
5382+
]
53695383
)
53705384

53715385

5372-
addNoteForRecordTypeError :: D.Doc -> D.Doc
5373-
addNoteForRecordTypeError normalRecommendation =
5386+
noteForRecordTypeError :: D.Doc
5387+
noteForRecordTypeError =
53745388
D.stack $
5375-
normalRecommendation
5376-
:
53775389
[ D.toSimpleNote
53785390
"If you are trying to define a record type across multiple lines, I recommend using this format:"
53795391
, D.indent 4 $ D.vcat $
@@ -5389,11 +5401,9 @@ addNoteForRecordTypeError normalRecommendation =
53895401
]
53905402

53915403

5392-
addNoteForRecordTypeIndentError :: D.Doc -> D.Doc
5393-
addNoteForRecordTypeIndentError normalRecommendation =
5404+
noteForRecordTypeIndentError :: D.Doc
5405+
noteForRecordTypeIndentError =
53945406
D.stack $
5395-
normalRecommendation
5396-
:
53975407
[ D.toSimpleNote
53985408
"I may be confused by indentation. For example, if you are trying to define\
53995409
\ a record type across multiple lines, I recommend using this format:"

0 commit comments

Comments
 (0)