GHC rejects instance quotations with splices in the instance head
I think the following code should be accepted.
{-# LANGUAGE TemplateHaskell #-}
class Storable a where
data X = X
[d| instance Storable $( [t| X |] ) where |]
GHC disagrees, saying:
test.hs:4:4:
Illegal instance declaration for `Storable t_aKj'
(All instance types must be of the form (T a1 ... an)
where a1 ... an are type *variables*,
and each type variable appears at most once in the instance head.
Use -XFlexibleInstances if you want to disable this.)
In the instance declaration for `Storable $[t| X |]'
In the Template Haskell quotation
[d|
instance Storable $[t| X |] where |]
In the expression:
[d|
instance Storable $[t| X |] where |]
This checking seems inappropriate before the type is actually spliced in!
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.12.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |