1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
|
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE GADTs #-}
module GHC.Parser.Errors.Ppr
( pprWarning
, pprError
)
where
import GHC.Prelude
import GHC.Driver.Flags
import GHC.Parser.Errors
import GHC.Parser.Types
import GHC.Types.Basic
import GHC.Types.SrcLoc
import GHC.Types.Name.Reader (starInfo, rdrNameOcc, opIsAt, mkUnqual)
import GHC.Types.Name.Occurrence (isSymOcc, occNameFS, varName)
import GHC.Utils.Error
import GHC.Utils.Outputable
import GHC.Utils.Misc
import GHC.Data.FastString
import GHC.Hs.Expr (prependQualified,HsExpr(..))
import GHC.Hs.Type (pprLHsContext)
import GHC.Builtin.Names (allNameStrings)
import GHC.Builtin.Types (filterCTuple)
mkParserErr :: SrcSpan -> SDoc -> ErrMsg
mkParserErr span doc = ErrMsg
{ errMsgSpan = span
, errMsgContext = alwaysQualify
, errMsgDoc = ErrDoc [doc] [] []
, errMsgSeverity = SevError
, errMsgReason = NoReason
}
mkParserWarn :: WarningFlag -> SrcSpan -> SDoc -> ErrMsg
mkParserWarn flag span doc = ErrMsg
{ errMsgSpan = span
, errMsgContext = alwaysQualify
, errMsgDoc = ErrDoc [doc] [] []
, errMsgSeverity = SevWarning
, errMsgReason = Reason flag
}
pprWarning :: PsWarning -> ErrMsg
pprWarning = \case
PsWarnTab loc tc
-> mkParserWarn Opt_WarnTabs loc $
text "Tab character found here"
<> (if tc == 1
then text ""
else text ", and in" <+> speakNOf (fromIntegral (tc - 1)) (text "further location"))
<> text "."
$+$ text "Please use spaces instead."
PsWarnTransitionalLayout loc reason
-> mkParserWarn Opt_WarnAlternativeLayoutRuleTransitional loc $
text "transitional layout will not be accepted in the future:"
$$ text (case reason of
TransLayout_Where -> "`where' clause at the same depth as implicit layout block"
TransLayout_Pipe -> "`|' at the same depth as implicit layout block"
)
PsWarnUnrecognisedPragma loc
-> mkParserWarn Opt_WarnUnrecognisedPragmas loc $
text "Unrecognised pragma"
PsWarnHaddockInvalidPos loc
-> mkParserWarn Opt_WarnInvalidHaddock loc $
text "A Haddock comment cannot appear in this position and will be ignored."
PsWarnHaddockIgnoreMulti loc
-> mkParserWarn Opt_WarnInvalidHaddock loc $
text "Multiple Haddock comments for a single entity are not allowed." $$
text "The extraneous comment will be ignored."
PsWarnStarBinder loc
-> mkParserWarn Opt_WarnStarBinder loc $
text "Found binding occurrence of" <+> quotes (text "*")
<+> text "yet StarIsType is enabled."
$$ text "NB. To use (or export) this operator in"
<+> text "modules with StarIsType,"
$$ text " including the definition module, you must qualify it."
PsWarnStarIsType loc
-> mkParserWarn Opt_WarnStarIsType loc $
text "Using" <+> quotes (text "*")
<+> text "(or its Unicode variant) to mean"
<+> quotes (text "Data.Kind.Type")
$$ text "relies on the StarIsType extension, which will become"
$$ text "deprecated in the future."
$$ text "Suggested fix: use" <+> quotes (text "Type")
<+> text "from" <+> quotes (text "Data.Kind") <+> text "instead."
PsWarnImportPreQualified loc
-> mkParserWarn Opt_WarnPrepositiveQualifiedModule loc $
text "Found" <+> quotes (text "qualified")
<+> text "in prepositive position"
$$ text "Suggested fix: place " <+> quotes (text "qualified")
<+> text "after the module name instead."
$$ text "To allow this, enable language extension 'ImportQualifiedPost'"
PsWarnOperatorWhitespaceExtConflict loc sym
-> mkParserWarn Opt_WarnOperatorWhitespaceExtConflict loc $
let mk_prefix_msg operator_symbol extension_name syntax_meaning =
text "The prefix use of a" <+> quotes (text operator_symbol)
<+> text "would denote" <+> text syntax_meaning
$$ nest 2 (text "were the" <+> text extension_name <+> text "extension enabled.")
$$ text "Suggested fix: add whitespace after the"
<+> quotes (text operator_symbol) <> char '.'
in
case sym of
OperatorWhitespaceSymbol_PrefixPercent -> mk_prefix_msg "%" "LinearTypes" "a multiplicity annotation"
OperatorWhitespaceSymbol_PrefixDollar -> mk_prefix_msg "$" "TemplateHaskell" "an untyped splice"
OperatorWhitespaceSymbol_PrefixDollarDollar -> mk_prefix_msg "$$" "TemplateHaskell" "a typed splice"
PsWarnOperatorWhitespace loc sym occ_type
-> mkParserWarn Opt_WarnOperatorWhitespace loc $
let mk_msg occ_type_str =
text "The" <+> text occ_type_str <+> text "use of a" <+> quotes (ftext sym)
<+> text "might be repurposed as special syntax"
$$ nest 2 (text "by a future language extension.")
$$ text "Suggested fix: add whitespace around it."
in
case occ_type of
OperatorWhitespaceOccurrence_Prefix -> mk_msg "prefix"
OperatorWhitespaceOccurrence_Suffix -> mk_msg "suffix"
OperatorWhitespaceOccurrence_TightInfix -> mk_msg "tight infix"
pprError :: PsError -> ErrMsg
pprError err = mkParserErr (errLoc err) $ vcat
(pp_err (errDesc err) : map pp_hint (errHints err))
pp_err :: PsErrorDesc -> SDoc
pp_err = \case
PsErrLambdaCase
-> text "Illegal lambda-case (use LambdaCase)"
PsErrNumUnderscores reason
-> text $ case reason of
NumUnderscore_Integral -> "Use NumericUnderscores to allow underscores in integer literals"
NumUnderscore_Float -> "Use NumericUnderscores to allow underscores in floating literals"
PsErrPrimStringInvalidChar
-> text "primitive string literal must contain only characters <= \'\\xFF\'"
PsErrMissingBlock
-> text "Missing block"
PsErrLexer err kind
-> hcat
[ text $ case err of
LexError -> "lexical error"
LexUnknownPragma -> "unknown pragma"
LexErrorInPragma -> "lexical error in pragma"
LexNumEscapeRange -> "numeric escape sequence out of range"
LexStringCharLit -> "lexical error in string/character literal"
LexStringCharLitEOF -> "unexpected end-of-file in string/character literal"
LexUnterminatedComment -> "unterminated `{-'"
LexUnterminatedOptions -> "unterminated OPTIONS pragma"
LexUnterminatedQQ -> "unterminated quasiquotation"
, text $ case kind of
LexErrKind_EOF -> " at end of input"
LexErrKind_UTF8 -> " (UTF-8 decoding error)"
LexErrKind_Char c -> " at character " ++ show c
]
PsErrSuffixAT
-> text "Suffix occurrence of @. For an as-pattern, remove the leading whitespace."
PsErrParse token
| null token
-> text "parse error (possibly incorrect indentation or mismatched brackets)"
| otherwise
-> text "parse error on input" <+> quotes (text token)
PsErrCmmLexer
-> text "Cmm lexical error"
PsErrUnsupportedBoxedSumExpr s
-> hang (text "Boxed sums not supported:") 2
(pprSumOrTuple Boxed s)
PsErrUnsupportedBoxedSumPat s
-> hang (text "Boxed sums not supported:") 2
(pprSumOrTuple Boxed s)
PsErrUnexpectedQualifiedConstructor v
-> hang (text "Expected an unqualified type constructor:") 2
(ppr v)
PsErrTupleSectionInPat
-> text "Tuple section in pattern context"
PsErrIllegalBangPattern e
-> text "Illegal bang-pattern (use BangPatterns):" $$ ppr e
PsErrOpFewArgs (StarIsType star_is_type) op
-> text "Operator applied to too few arguments:" <+> ppr op
$$ starInfo star_is_type op
PsErrImportQualifiedTwice
-> text "Multiple occurrences of 'qualified'"
PsErrImportPostQualified
-> text "Found" <+> quotes (text "qualified")
<+> text "in postpositive position. "
$$ text "To allow this, enable language extension 'ImportQualifiedPost'"
PsErrIllegalExplicitNamespace
-> text "Illegal keyword 'type' (use ExplicitNamespaces to enable)"
PsErrVarForTyCon name
-> text "Expecting a type constructor but found a variable,"
<+> quotes (ppr name) <> text "."
$$ if isSymOcc $ rdrNameOcc name
then text "If" <+> quotes (ppr name) <+> text "is a type constructor"
<+> text "then enable ExplicitNamespaces and use the 'type' keyword."
else empty
PsErrIllegalPatSynExport
-> text "Illegal export form (use PatternSynonyms to enable)"
PsErrMalformedEntityString
-> text "Malformed entity string"
PsErrDotsInRecordUpdate
-> text "You cannot use `..' in a record update"
PsErrPrecedenceOutOfRange i
-> text "Precedence out of range: " <> int i
PsErrInvalidDataCon t
-> hang (text "Cannot parse data constructor in a data/newtype declaration:") 2
(ppr t)
PsErrInvalidInfixDataCon lhs tc rhs
-> hang (text "Cannot parse an infix data constructor in a data/newtype declaration:")
2 (ppr lhs <+> ppr tc <+> ppr rhs)
PsErrUnpackDataCon
-> text "{-# UNPACK #-} cannot be applied to a data constructor."
PsErrUnexpectedKindAppInDataCon lhs ki
-> hang (text "Unexpected kind application in a data/newtype declaration:") 2
(ppr lhs <+> text "@" <> ppr ki)
PsErrInvalidRecordCon p
-> text "Not a record constructor:" <+> ppr p
PsErrIllegalUnboxedStringInPat lit
-> text "Illegal unboxed string literal in pattern:" $$ ppr lit
PsErrDoNotationInPat
-> text "do-notation in pattern"
PsErrIfTheElseInPat
-> text "(if ... then ... else ...)-syntax in pattern"
PsErrLambdaCaseInPat
-> text "(\\case ...)-syntax in pattern"
PsErrCaseInPat
-> text "(case ... of ...)-syntax in pattern"
PsErrLetInPat
-> text "(let ... in ...)-syntax in pattern"
PsErrLambdaInPat
-> text "Lambda-syntax in pattern."
$$ text "Pattern matching on functions is not possible."
PsErrArrowExprInPat e
-> text "Expression syntax in pattern:" <+> ppr e
PsErrArrowCmdInPat c
-> text "Command syntax in pattern:" <+> ppr c
PsErrArrowCmdInExpr c
-> vcat
[ text "Arrow command found where an expression was expected:"
, nest 2 (ppr c)
]
PsErrViewPatInExpr a b
-> sep [ text "View pattern in expression context:"
, nest 4 (ppr a <+> text "->" <+> ppr b)
]
PsErrTypeAppWithoutSpace v e
-> sep [ text "@-pattern in expression context:"
, nest 4 (pprPrefixOcc v <> text "@" <> ppr e)
]
$$ text "Type application syntax requires a space before '@'"
PsErrLazyPatWithoutSpace e
-> sep [ text "Lazy pattern in expression context:"
, nest 4 (text "~" <> ppr e)
]
$$ text "Did you mean to add a space after the '~'?"
PsErrBangPatWithoutSpace e
-> sep [ text "Bang pattern in expression context:"
, nest 4 (text "!" <> ppr e)
]
$$ text "Did you mean to add a space after the '!'?"
PsErrUnallowedPragma prag
-> hang (text "A pragma is not allowed in this position:") 2
(ppr prag)
PsErrQualifiedDoInCmd m
-> hang (text "Parse error in command:") 2 $
text "Found a qualified" <+> ppr m <> text ".do block in a command, but"
$$ text "qualified 'do' is not supported in commands."
PsErrParseErrorInCmd s
-> hang (text "Parse error in command:") 2 s
PsErrParseErrorInPat s
-> text "Parse error in pattern:" <+> s
PsErrInvalidInfixHole
-> text "Invalid infix hole, expected an infix operator"
PsErrSemiColonsInCondExpr c st t se e
-> text "Unexpected semi-colons in conditional:"
$$ nest 4 expr
$$ text "Perhaps you meant to use DoAndIfThenElse?"
where
pprOptSemi True = semi
pprOptSemi False = empty
expr = text "if" <+> ppr c <> pprOptSemi st <+>
text "then" <+> ppr t <> pprOptSemi se <+>
text "else" <+> ppr e
PsErrSemiColonsInCondCmd c st t se e
-> text "Unexpected semi-colons in conditional:"
$$ nest 4 expr
$$ text "Perhaps you meant to use DoAndIfThenElse?"
where
pprOptSemi True = semi
pprOptSemi False = empty
expr = text "if" <+> ppr c <> pprOptSemi st <+>
text "then" <+> ppr t <> pprOptSemi se <+>
text "else" <+> ppr e
PsErrAtInPatPos
-> text "Found a binding for the"
<+> quotes (text "@")
<+> text "operator in a pattern position."
$$ perhaps_as_pat
PsErrLambdaCmdInFunAppCmd a
-> pp_unexpected_fun_app (text "lambda command") a
PsErrCaseCmdInFunAppCmd a
-> pp_unexpected_fun_app (text "case command") a
PsErrIfCmdInFunAppCmd a
-> pp_unexpected_fun_app (text "if command") a
PsErrLetCmdInFunAppCmd a
-> pp_unexpected_fun_app (text "let command") a
PsErrDoCmdInFunAppCmd a
-> pp_unexpected_fun_app (text "do command") a
PsErrDoInFunAppExpr m a
-> pp_unexpected_fun_app (prependQualified m (text "do block")) a
PsErrMDoInFunAppExpr m a
-> pp_unexpected_fun_app (prependQualified m (text "mdo block")) a
PsErrLambdaInFunAppExpr a
-> pp_unexpected_fun_app (text "lambda expression") a
PsErrCaseInFunAppExpr a
-> pp_unexpected_fun_app (text "case expression") a
PsErrLambdaCaseInFunAppExpr a
-> pp_unexpected_fun_app (text "lambda-case expression") a
PsErrLetInFunAppExpr a
-> pp_unexpected_fun_app (text "let expression") a
PsErrIfInFunAppExpr a
-> pp_unexpected_fun_app (text "if expression") a
PsErrProcInFunAppExpr a
-> pp_unexpected_fun_app (text "proc expression") a
PsErrMalformedTyOrClDecl ty
-> text "Malformed head of type or class declaration:"
<+> ppr ty
PsErrIllegalWhereInDataDecl
-> vcat
[ text "Illegal keyword 'where' in data declaration"
, text "Perhaps you intended to use GADTs or a similar language"
, text "extension to enable syntax: data T where"
]
PsErrIllegalTraditionalRecordSyntax s
-> text "Illegal record syntax (use TraditionalRecordSyntax):"
<+> s
PsErrParseErrorOnInput occ
-> text "parse error on input" <+> ftext (occNameFS occ)
PsErrIllegalDataTypeContext c
-> text "Illegal datatype context (use DatatypeContexts):"
<+> pprLHsContext c
PsErrMalformedDecl what for
-> text "Malformed" <+> what
<+> text "declaration for" <+> quotes (ppr for)
PsErrUnexpectedTypeAppInDecl ki what for
-> vcat [ text "Unexpected type application"
<+> text "@" <> ppr ki
, text "In the" <+> what
<+> text "declaration for"
<+> quotes (ppr for)
]
PsErrNotADataCon name
-> text "Not a data constructor:" <+> quotes (ppr name)
PsErrRecordSyntaxInPatSynDecl pat
-> text "record syntax not supported for pattern synonym declarations:"
$$ ppr pat
PsErrEmptyWhereInPatSynDecl patsyn_name
-> text "pattern synonym 'where' clause cannot be empty"
$$ text "In the pattern synonym declaration for: "
<+> ppr (patsyn_name)
PsErrInvalidWhereBindInPatSynDecl patsyn_name decl
-> text "pattern synonym 'where' clause must bind the pattern synonym's name"
<+> quotes (ppr patsyn_name) $$ ppr decl
PsErrNoSingleWhereBindInPatSynDecl _patsyn_name decl
-> text "pattern synonym 'where' clause must contain a single binding:"
$$ ppr decl
PsErrDeclSpliceNotAtTopLevel d
-> hang (text "Declaration splices are allowed only"
<+> text "at the top level:")
2 (ppr d)
PsErrInferredTypeVarNotAllowed
-> text "Inferred type variables are not allowed here"
PsErrIllegalRoleName role nearby
-> text "Illegal role name" <+> quotes (ppr role)
$$ case nearby of
[] -> empty
[r] -> text "Perhaps you meant" <+> quotes (ppr r)
-- will this last case ever happen??
_ -> hang (text "Perhaps you meant one of these:")
2 (pprWithCommas (quotes . ppr) nearby)
PsErrMultipleNamesInStandaloneKindSignature vs
-> vcat [ hang (text "Standalone kind signatures do not support multiple names at the moment:")
2 (pprWithCommas ppr vs)
, text "See https://gitlab.haskell.org/ghc/ghc/issues/16754 for details."
]
PsErrIllegalImportBundleForm
-> text "Illegal import form, this syntax can only be used to bundle"
$+$ text "pattern synonyms with types in module exports."
PsErrInvalidTypeSignature lhs
-> text "Invalid type signature:"
<+> ppr lhs
<+> text ":: ..."
$$ text hint
where
hint | foreign_RDR `looks_like` lhs
= "Perhaps you meant to use ForeignFunctionInterface?"
| default_RDR `looks_like` lhs
= "Perhaps you meant to use DefaultSignatures?"
| pattern_RDR `looks_like` lhs
= "Perhaps you meant to use PatternSynonyms?"
| otherwise
= "Should be of form <variable> :: <type>"
-- A common error is to forget the ForeignFunctionInterface flag
-- so check for that, and suggest. cf #3805
-- Sadly 'foreign import' still barfs 'parse error' because
-- 'import' is a keyword
looks_like s (L _ (HsVar _ (L _ v))) = v == s
looks_like s (L _ (HsApp _ lhs _)) = looks_like s lhs
looks_like _ _ = False
foreign_RDR = mkUnqual varName (fsLit "foreign")
default_RDR = mkUnqual varName (fsLit "default")
pattern_RDR = mkUnqual varName (fsLit "pattern")
PsErrUnexpectedTypeInDecl t what tc tparms equals_or_where
-> vcat [ text "Unexpected type" <+> quotes (ppr t)
, text "In the" <+> what
<+> ptext (sLit "declaration for") <+> quotes tc'
, vcat[ (text "A" <+> what
<+> ptext (sLit "declaration should have form"))
, nest 2
(what
<+> tc'
<+> hsep (map text (takeList tparms allNameStrings))
<+> equals_or_where) ] ]
where
-- Avoid printing a constraint tuple in the error message. Print
-- a plain old tuple instead (since that's what the user probably
-- wrote). See #14907
tc' = ppr $ filterCTuple tc
PsErrCmmParser cmm_err -> case cmm_err of
CmmUnknownPrimitive name -> text "unknown primitive" <+> ftext name
CmmUnknownMacro fun -> text "unknown macro" <+> ftext fun
CmmUnknownCConv cconv -> text "unknown calling convention:" <+> text cconv
CmmUnrecognisedSafety safety -> text "unrecognised safety" <+> text safety
CmmUnrecognisedHint hint -> text "unrecognised hint:" <+> text hint
PsErrExpectedHyphen
-> text "Expected a hyphen"
PsErrSpaceInSCC
-> text "Spaces are not allowed in SCCs"
PsErrEmptyDoubleQuotes th_on
-> if th_on then vcat (msg ++ th_msg) else vcat msg
where
msg = [ text "Parser error on `''`"
, text "Character literals may not be empty"
]
th_msg = [ text "Or perhaps you intended to use quotation syntax of TemplateHaskell,"
, text "but the type variable or constructor is missing"
]
PsErrInvalidPackageName pkg
-> vcat
[ text "Parse error" <> colon <+> quotes (ftext pkg)
, text "Version number or non-alphanumeric" <+>
text "character in package name"
]
PsErrInvalidRuleActivationMarker
-> text "Invalid rule activation marker"
PsErrLinearFunction
-> text "Enable LinearTypes to allow linear functions"
PsErrMultiWayIf
-> text "Multi-way if-expressions need MultiWayIf turned on"
PsErrExplicitForall is_unicode
-> vcat
[ text "Illegal symbol" <+> quotes (forallSym is_unicode) <+> text "in type"
, text "Perhaps you intended to use RankNTypes or a similar language"
, text "extension to enable explicit-forall syntax:" <+>
forallSym is_unicode <+> text "<tvs>. <type>"
]
where
forallSym True = text "∀"
forallSym False = text "forall"
PsErrIllegalQualifiedDo qdoDoc
-> vcat
[ text "Illegal qualified" <+> quotes qdoDoc <+> text "block"
, text "Perhaps you intended to use QualifiedDo"
]
pp_unexpected_fun_app :: Outputable a => SDoc -> a -> SDoc
pp_unexpected_fun_app e a =
text "Unexpected " <> e <> text " in function application:"
$$ nest 4 (ppr a)
$$ text "You could write it with parentheses"
$$ text "Or perhaps you meant to enable BlockArguments?"
pp_hint :: Hint -> SDoc
pp_hint = \case
SuggestTH -> text "Perhaps you intended to use TemplateHaskell"
SuggestDo -> text "Perhaps this statement should be within a 'do' block?"
SuggestMissingDo -> text "Possibly caused by a missing 'do'?"
SuggestRecursiveDo -> text "Perhaps you intended to use RecursiveDo"
SuggestLetInDo -> text "Perhaps you need a 'let' in a 'do' block?"
$$ text "e.g. 'let x = 5' instead of 'x = 5'"
SuggestPatternSynonyms -> text "Perhaps you intended to use PatternSynonyms"
SuggestInfixBindMaybeAtPat fun
-> text "In a function binding for the"
<+> quotes (ppr fun)
<+> text "operator."
$$ if opIsAt fun
then perhaps_as_pat
else empty
TypeApplicationsInPatternsOnlyDataCons ->
text "Type applications in patterns are only allowed on data constructors."
perhaps_as_pat :: SDoc
perhaps_as_pat = text "Perhaps you meant an as-pattern, which must not be surrounded by whitespace"
|