Template Haskell prohibits negative numbers in patterns in quotation brackets
Summary
Negative numbers cannot be used in patterns in TH quotation brackets ([d|
, [|
). The following error is reported:
Negative overloaded patterns not (yet) handled by Template Haskell
This however seems strange in absence of any enabled extensions that would manipulate handling of patterns. Specifying the -NoOverloaded*
extensions does not change this behaviour.
Steps to reproduce
In GHCi:
- start
ghci -XTemplateHaskell
- try evaluating
[d| f (-1) = () |]
You get the following error message:
ghci> [d| f (-1) = () |]
<interactive>:1:1: error:
Negative overloaded patterns not (yet) handled by Template Haskell
-1
The same for the following expressions:
[| let f (-1) = () in () |]
[| case x of { -1 -> () } |]
It also fails in a file.
Expected behavior
Produce TH AST of the declaration, is a similar way as [d| f (1) = () |]
would do (which works).
Environment
- GHC version used: 9.0.1
- same for older GHC versions I have (8.4–8.10; with
runQ (show <$> [| case x of { -1 -> () } |])
)
- same for older GHC versions I have (8.4–8.10; with
Optional:
- Operating System: Archlinux, Debian 11
- System Architecture: x86-64