Suggest PatternSynonyms when appropriate
If I try to define a pattern synonym when PatternSynonyms
is disabled, I get a lot of confusing "not in scope" errors, presumably because pattern
is a quasi-keyword and GHC interprets it as a function definition. It would be nice if the error message suggested enabling PatternSynonyms
.
$ ghci-8.10.2
GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
Prelude> pattern MkPair{x,y} = (x, y)
<interactive>:1:9: error: Not in scope: data constructor ‘MkPair’
<interactive>:1:9: error:
Illegal use of punning for field ‘x’
Use NamedFieldPuns to permit this
<interactive>:1:9: error:
Illegal use of punning for field ‘y’
Use NamedFieldPuns to permit this
<interactive>:1:16: error: Not in scope: ‘x’
<interactive>:1:18: error: Not in scope: ‘y’
Prelude> :set -XPatternSynonyms
Prelude> pattern MkPair{x,y} = (x, y)
Prelude>