#4128: Can't capture classes inside a template haskell type quotation
---------------------------------+------------------------------------------
Reporter: lilac | Owner:
Type: feature request | Status: new
Priority: normal | Component: Template Haskell
Version: 6.12.1 | Keywords:
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
GHC rejects the following:
{{{
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH
class C a where
data X = X
fmap return $ instanceD (cxt []) [t| C $(conT ''X) |] []
}}}
with the error:
{{{
test.hs:5:23:
Class `C' used as a type
In the Template Haskell quotation [t| C $(conT 'X) |]
In the second argument of `instanceD', namely `[t| C $(conT 'X) |]'
In the expression: instanceD (cxt []) [t| C $(conT 'X) |] []
}}}
This is frustrating, since that quotation would have resulted in exactly
the TH AST fragment I wanted, had the error not occurred. Instead I must
resort to:
{{{
instanceD (cxt []) (appT (conT ''Storable) (conT ''X)) []
}}}
Incidentally, the error message produced is wrong: The error says 'X
whereas I wrote ''X.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4128>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs