where
msg = ptext SLIT("Cannot desugar this Template Haskell declaration:")
-repInstD' (L loc (InstDecl ty binds _))
- -- Ignore user pragmas for now
- = do { cxt1 <- repContext cxt
- ; inst_ty1 <- repPred (HsClassP cls tys)
- ; ss <- mkGenSyms (collectHsBindBinders binds)
- ; binds1 <- addBinds ss (rep_binds binds)
- ; decls1 <- coreList decQTyConName binds1
- ; decls2 <- wrapNongenSyms ss decls1
- -- wrapNonGenSyms: do not clone the class op names!
- -- They must be called 'op' etc, not 'op34'
- ; i <- repInst cxt1 inst_ty1 decls2
+repInstD' (L loc (InstDecl ty binds _)) -- Ignore user pragmas for now
+ = do { i <- addTyVarBinds tvs $ \tv_bndrs ->
+ -- We must bring the type variables into scope, so their occurrences
+ -- don't fail, even though the binders don't appear in the resulting
+ -- data structure
+ do { cxt1 <- repContext cxt
+ ; inst_ty1 <- repPred (HsClassP cls tys)
+ ; ss <- mkGenSyms (collectHsBindBinders binds)
+ ; binds1 <- addBinds ss (rep_binds binds)
+ ; decls1 <- coreList decQTyConName binds1
+ ; decls2 <- wrapNongenSyms ss decls1
+ -- wrapNonGenSyms: do not clone the class op names!
+ -- They must be called 'op' etc, not 'op34'
+ ; repInst cxt1 inst_ty1 decls2 }
+
; return (loc, i)}
where
- (_, cxt, cls, tys) = splitHsInstDeclTy (unLoc ty)
+ (tvs, cxt, cls, tys) = splitHsInstDeclTy (unLoc ty)
-------------------------------------------------------
-- Constructors
repOverloadedLiteral (HsIntegral i _) = do { lit <- mk_integer i; repLiteral lit }
repOverloadedLiteral (HsFractional f _) = do { lit <- mk_rational f; repLiteral lit }
-- The type Rational will be in the environment, becuase
- -- the smart constructor 'THSyntax.rationalL' uses it in its type,
+ -- the smart constructor 'TH.Syntax.rationalL' uses it in its type,
-- and rationalL is sucked in when any TH stuff is used
--------------- Miscellaneous -------------------
varStrictTypeQTyConName, typeQTyConName, expTyConName, decTyConName,
typeTyConName, matchTyConName, clauseTyConName]
-tH_SYN_Name = mkModuleName "Language.Haskell.TH.THSyntax"
-tH_LIB_Name = mkModuleName "Language.Haskell.TH.THLib"
+tH_SYN_Name = mkModuleName "Language.Haskell.TH.Syntax"
+tH_LIB_Name = mkModuleName "Language.Haskell.TH.Lib"
thSyn :: Module
--- NB: the THSyntax module comes from the "haskell-src" package
+-- NB: the TH.Syntax module comes from the "haskell-src" package
thSyn = mkModule thPackage tH_SYN_Name
thLib = mkModule thPackage tH_LIB_Name
thFun = mk_known_key_name thSyn OccName.varName
thTc = mk_known_key_name thSyn OccName.tcName
--------------------- THSyntax -----------------------
+-------------------- TH.Syntax -----------------------
qTyConName = thTc FSLIT("Q") qTyConKey
nameTyConName = thTc FSLIT("Name") nameTyConKey
fieldExpTyConName = thTc FSLIT("FieldExp") fieldExpTyConKey
mkNameUName = thFun FSLIT("mkNameU") mkNameUIdKey
--------------------- THLib -----------------------
+-------------------- TH.Lib -----------------------
-- data Lit = ...
charLName = libFun FSLIT("charL") charLIdKey
stringLName = libFun FSLIT("stringL") stringLIdKey