Template Haskell: Pattern quote should suggest to turn on -XTemplateHaskell
Consider
{-# LANGUAGE ViewPatterns #-}
module Lib where
import Language.Haskell.TH.Syntax
foo :: Q Pat
foo = [p| (id -> False) |]
I would expect this to compile and produce a quote that builds a ViewP
.
Alas, GHC HEAD reports two strange errors instead:
[1 of 1] Compiling Lib ( test.hs, test.o )
test.hs:8:12: error: [GHC-66228]
View pattern in expression context: id -> False
|
8 | foo = [p| (id -> False) |]
| ^^^^^^^^^^^
test.hs:8:25: error: [GHC-58481]
parse error on input ‘|]’
|
8 | foo = [p| (id -> False) |]
| ^^
FYI, this is the parser production for pattern quotes:
...
| '[p|' infixexp '|]' {% (checkPattern <=< runPV) (unECP $2) ...
...
It should do all the right things for patterns. I'm not sure why we get "View pattern in expression context".