TH can sneak in TypeApplications without enabling the extension
This program compiles:
{-# LANGUAGE TemplateHaskell #-}
module Bug1 where
import Language.Haskell.TH
$([d| f :: Int
f = $(varE 'id `appTypeE` conT ''Int `appE` litE (integerL 42)) |])
But it shouldn't: this splices in code that uses TypeApplications, but the language extension isn't enabled! What's worse, this is inconsistent with visible kind applications, since the following code //is// rejected:
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TemplateHaskell #-}
module Bug2 where
import Data.Kind
import Language.Haskell.TH hiding (Type)
data P (a :: k) = MkP
$([d| type P' = $(conT ''P `appKindT` conT ''Type) |])
$ ~/Software/ghc4/inplace/bin/ghc-stage2 Bug2.hs
[1 of 1] Compiling Bug2 ( Bug2.hs, Bug2.o )
Bug2.hs:10:3: error:
Illegal visible kind application ‘Type’
Perhaps you intended to use TypeApplications
|
10 | $([d| type P' = $(conT ''P `appKindT` conT ''Type) |])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Let's bring the two into harmony. Patch incoming.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.6.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |