+lookupTvOcc :: Name -> DsM (Core TH.Name)
+-- Type variables can't be staged and are not lexically scoped in TH
+lookupTvOcc n
+ = do { mb_val <- dsLookupMetaEnv n ;
+ case mb_val of
+ Just (Bound x) -> return (coreVar x)
+ other -> failWithDs msg
+ }
+ where
+ msg = vcat [ ptext SLIT("Illegal lexically-scoped type variable") <+> quotes (ppr n)
+ , ptext SLIT("Lexically scoped type variables are not supported by Template Haskell") ]
+