Template Haskell disallows use of promoted data constructor in same splice
The following code fails to compile under GHC 7.5.20120413:
{-# LANGUAGE TemplateHaskell, DataKinds, PolyKinds #-}
$( [d|
data Nat = Zero | Succ Nat
data Proxy a = Proxy
foo :: Proxy Zero
foo = Proxy
|])
The error is:
The exact Name `Zero_a3N3' is not in scope
Probable cause: you used a unique name (NameU), perhaps via newName,
in Template Haskell, but did not bind it
If that's it, then -ddump-splices might be useful
Using -ddump-splices shows that the same internal name is used for the data constructor at declaration and usage.
The problem seems to be that a data constructor declared within a splice cannot be used as a promoted type in that same splice. Separating the splices works.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.5 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |