TH quotes and TypeAbstractions don't work together
See also
{-# LANGUAGE TemplateHaskellQuotes #-}
{-# LANGUAGE ImpredicativeTypes #-}
{-# LANGUAGE TypeAbstractions #-}
module TH where
import Language.Haskell.TH
codeId :: Code Q (forall a. a -> a)
codeId = [|| \ @a x -> x :: a ||]
listId :: [forall a. a -> a]
listId = [ \ @a x -> x :: a ]
fails to compile with
TH.hs:10:16: error: [GHC-14964]
• Invisible type pattern a has no associated forall
• In the Template Haskell quotation [|| \ @a x -> x :: a ||]
In the expression: [|| \ @a x -> x :: a ||]
In an equation for ‘codeId’: codeId = [|| \ @a x -> x :: a ||]
|
10 | codeId = [|| \ @a x -> x :: a ||]
| ^^
Note, the listId
is fine, if codeId
is commented out, the module compiles fine.
Tested with GHC-9.10 release candidate: The Glorious Glasgow Haskell Compilation System, version 9.10.0.20240426
Edited by Simon Peyton Jones