2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[RnSource]{Main pass of renamer}
7 #include "HsVersions.h"
9 module RnSource ( rnDecl, rnHsType ) where
12 IMPORT_DELOOPER(RnLoop) -- *check* the RnPass/RnExpr/RnBinds loop-breaking
15 import HsDecls ( HsIdInfo(..) )
17 import HsTypes ( getTyVarName )
21 import CmdLineOpts ( opt_IgnoreIfacePragmas )
23 import RnBinds ( rnTopBinds, rnMethodBinds )
24 import RnEnv ( bindTyVarsRn, lookupRn, lookupOccRn, lookupImplicitOccRn, bindLocalsRn,
25 lookupOptionalOccRn, newDfunName,
26 listType_RDR, tupleType_RDR )
29 import Name ( Name, isLocallyDefined, occNameString,
31 SYN_IE(NameSet), unionNameSets, emptyNameSet, mkNameSet, unitNameSet,
34 import ErrUtils ( addErrLoc, addShortErrLocLine, addShortWarnLocLine )
35 import FiniteMap ( emptyFM, lookupFM, addListToFM_C )
36 import Id ( GenId{-instance NamedThing-} )
37 import IdInfo ( IdInfo, StrictnessInfo(..), FBTypeInfo, DemandInfo, ArgUsageInfo )
38 import SpecEnv ( SpecEnv )
39 import Lex ( isLexCon )
40 import CoreUnfold ( Unfolding(..), SimpleUnfolding )
41 import MagicUFs ( MagicUnfoldingFun )
42 import PrelInfo ( derivingOccurrences, evalClass_RDR, numClass_RDR )
43 import ListSetOps ( unionLists, minusList )
44 import Maybes ( maybeToBool, catMaybes )
45 import Bag ( emptyBag, unitBag, consBag, unionManyBags, unionBags, listToBag, bagToList )
46 import Outputable ( Outputable(..){-instances-} )
47 --import PprStyle -- ToDo:rm
49 import SrcLoc ( SrcLoc )
50 -- import TyCon ( TyCon{-instance NamedThing-} )
51 import Unique ( Unique )
52 import UniqSet ( SYN_IE(UniqSet) )
53 import UniqFM ( UniqFM, lookupUFM )
54 import Util ( isIn, isn'tIn, thenCmp, removeDups, cmpPString,
55 panic, assertPanic{- , pprTrace ToDo:rm-} )
58 rnDecl `renames' declarations.
59 It simultaneously performs dependency analysis and precedence parsing.
60 It also does the following error checks:
63 Checks that tyvars are used properly. This includes checking
64 for undefined tyvars, and tyvars in contexts that are ambiguous.
66 Checks that all variable occurences are defined.
68 Checks the (..) etc constraints in the export list.
72 %*********************************************************
74 \subsection{Value declarations}
76 %*********************************************************
79 rnDecl :: RdrNameHsDecl -> RnMS s RenamedHsDecl
81 rnDecl (ValD binds) = rnTopBinds binds `thenRn` \ new_binds ->
82 returnRn (ValD new_binds)
85 rnDecl (SigD (IfaceSig name ty id_infos loc))
87 lookupRn name `thenRn` \ name' ->
88 rnHsType ty `thenRn` \ ty' ->
90 -- Get the pragma info, unless we should ignore it
91 (if opt_IgnoreIfacePragmas then
94 mapRn rnIdInfo id_infos
95 ) `thenRn` \ id_infos' ->
97 returnRn (SigD (IfaceSig name' ty' id_infos' loc))
100 %*********************************************************
102 \subsection{Type declarations}
104 %*********************************************************
106 @rnTyDecl@ uses the `global name function' to create a new type
107 declaration in which local names have been replaced by their original
108 names, reporting any unknown names.
110 Renaming type variables is a pain. Because they now contain uniques,
111 it is necessary to pass in an association list which maps a parsed
112 tyvar to its Name representation. In some cases (type signatures of
113 values), it is even necessary to go over the type first in order to
114 get the set of tyvars used by it, make an assoc list, and then go over
115 it again to rename the tyvars! However, we can also do some scoping
116 checks at the same time.
119 rnDecl (TyD (TyData context tycon tyvars condecls derivings pragmas src_loc))
120 = pushSrcLocRn src_loc $
121 lookupRn tycon `thenRn` \ tycon' ->
122 bindTyVarsRn "data declaration" tyvars $ \ tyvars' ->
123 rnContext context `thenRn` \ context' ->
124 mapRn rnConDecl condecls `thenRn` \ condecls' ->
125 rnDerivs derivings `thenRn` \ derivings' ->
126 ASSERT(isNoDataPragmas pragmas)
127 returnRn (TyD (TyData context' tycon' tyvars' condecls' derivings' noDataPragmas src_loc))
129 rnDecl (TyD (TyNew context tycon tyvars condecl derivings pragmas src_loc))
130 = pushSrcLocRn src_loc $
131 lookupRn tycon `thenRn` \ tycon' ->
132 bindTyVarsRn "newtype declaration" tyvars $ \ tyvars' ->
133 rnContext context `thenRn` \ context' ->
134 rnConDecl condecl `thenRn` \ condecl' ->
135 rnDerivs derivings `thenRn` \ derivings' ->
136 ASSERT(isNoDataPragmas pragmas)
137 returnRn (TyD (TyNew context' tycon' tyvars' condecl' derivings' noDataPragmas src_loc))
139 rnDecl (TyD (TySynonym name tyvars ty src_loc))
140 = pushSrcLocRn src_loc $
141 lookupRn name `thenRn` \ name' ->
142 bindTyVarsRn "type declaration" tyvars $ \ tyvars' ->
143 rnHsType ty `thenRn` \ ty' ->
144 returnRn (TyD (TySynonym name' tyvars' ty' src_loc))
147 %*********************************************************
149 \subsection{Class declarations}
151 %*********************************************************
153 @rnClassDecl@ uses the `global name function' to create a new
154 class declaration in which local names have been replaced by their
155 original names, reporting any unknown names.
158 rnDecl (ClD (ClassDecl context cname tyvar sigs mbinds pragmas src_loc))
159 = pushSrcLocRn src_loc $
160 bindTyVarsRn "class declaration" [tyvar] $ \ [tyvar'] ->
161 rnContext context `thenRn` \ context' ->
162 lookupRn cname `thenRn` \ cname' ->
163 mapRn (rn_op cname' (getTyVarName tyvar')) sigs `thenRn` \ sigs' ->
164 rnMethodBinds mbinds `thenRn` \ mbinds' ->
165 ASSERT(isNoClassPragmas pragmas)
166 returnRn (ClD (ClassDecl context' cname' tyvar' sigs' mbinds' NoClassPragmas src_loc))
168 rn_op clas clas_tyvar sig@(ClassOpSig op ty pragmas locn)
169 = pushSrcLocRn locn $
170 lookupRn op `thenRn` \ op_name ->
171 rnHsType ty `thenRn` \ new_ty ->
173 (ctxt, op_ty) = case new_ty of
174 HsForAllTy tvs ctxt op_ty -> (ctxt, op_ty)
175 other -> ([], new_ty)
176 ctxt_fvs = extractCtxtTyNames ctxt
177 op_ty_fvs = extractHsTyNames op_ty -- Includes tycons/classes but we
178 -- don't care about that
180 -- check that class tyvar appears in op_ty
181 checkRn (clas_tyvar `elemNameSet` op_ty_fvs)
182 (classTyVarNotInOpTyErr clas_tyvar sig)
185 -- check that class tyvar *doesn't* appear in the sig's context
186 checkRn (not (clas_tyvar `elemNameSet` ctxt_fvs))
187 (classTyVarInOpCtxtErr clas_tyvar sig)
190 ASSERT(isNoClassOpPragmas pragmas)
191 returnRn (ClassOpSig op_name new_ty noClassOpPragmas locn)
195 %*********************************************************
197 \subsection{Instance declarations}
199 %*********************************************************
202 rnDecl (InstD (InstDecl inst_ty mbinds uprags maybe_dfun_name src_loc))
203 = pushSrcLocRn src_loc $
204 rnHsType inst_ty `thenRn` \ inst_ty' ->
205 rnMethodBinds mbinds `thenRn` \ mbinds' ->
206 mapRn rn_uprag uprags `thenRn` \ new_uprags ->
207 rn_dfun maybe_dfun_name `thenRn` \ dfun_name' ->
209 returnRn (InstD (InstDecl inst_ty' mbinds' new_uprags dfun_name' src_loc))
211 rn_dfun Nothing = newDfunName src_loc `thenRn` \ n' ->
213 rn_dfun (Just n) = lookupOccRn n `thenRn` \ n' ->
214 -- The dfun is not optional, because we use its version number
215 -- to identify the version of the instance declaration
218 rn_uprag (SpecSig op ty using locn)
219 = pushSrcLocRn src_loc $
220 lookupRn op `thenRn` \ op_name ->
221 rnHsType ty `thenRn` \ new_ty ->
222 rn_using using `thenRn` \ new_using ->
223 returnRn (SpecSig op_name new_ty new_using locn)
225 rn_uprag (InlineSig op locn)
226 = pushSrcLocRn locn $
227 lookupRn op `thenRn` \ op_name ->
228 returnRn (InlineSig op_name locn)
230 rn_uprag (DeforestSig op locn)
231 = pushSrcLocRn locn $
232 lookupRn op `thenRn` \ op_name ->
233 returnRn (DeforestSig op_name locn)
235 rn_uprag (MagicUnfoldingSig op str locn)
236 = pushSrcLocRn locn $
237 lookupRn op `thenRn` \ op_name ->
238 returnRn (MagicUnfoldingSig op_name str locn)
240 rn_using Nothing = returnRn Nothing
241 rn_using (Just v) = lookupOccRn v `thenRn` \ new_v ->
242 returnRn (Just new_v)
245 %*********************************************************
247 \subsection{Default declarations}
249 %*********************************************************
252 rnDecl (DefD (DefaultDecl tys src_loc))
253 = pushSrcLocRn src_loc $
254 mapRn rnHsType tys `thenRn` \ tys' ->
255 lookupImplicitOccRn numClass_RDR `thenRn_`
256 returnRn (DefD (DefaultDecl tys' src_loc))
259 %*********************************************************
261 \subsection{Support code for type/data declarations}
263 %*********************************************************
266 rnDerivs :: Maybe [RdrName] -> RnMS s (Maybe [Name])
268 rnDerivs Nothing -- derivs not specified
269 = lookupImplicitOccRn evalClass_RDR `thenRn_`
273 = lookupImplicitOccRn evalClass_RDR `thenRn_`
274 mapRn rn_deriv ds `thenRn` \ derivs ->
275 returnRn (Just derivs)
278 = lookupOccRn clas `thenRn` \ clas_name ->
280 -- Now add extra "occurrences" for things that
281 -- the deriving mechanism will later need in order to
282 -- generate code for this class.
283 case lookupUFM derivingOccurrences clas_name of
284 Nothing -> addErrRn (derivingNonStdClassErr clas_name) `thenRn_`
287 Just occs -> mapRn lookupImplicitOccRn occs `thenRn_`
292 rnConDecl :: RdrNameConDecl -> RnMS s RenamedConDecl
294 rnConDecl (ConDecl name tys src_loc)
295 = pushSrcLocRn src_loc $
296 checkConName name `thenRn_`
297 lookupRn name `thenRn` \ new_name ->
298 mapRn rnBangTy tys `thenRn` \ new_tys ->
299 returnRn (ConDecl new_name new_tys src_loc)
301 rnConDecl (ConOpDecl ty1 op ty2 src_loc)
302 = pushSrcLocRn src_loc $
303 lookupRn op `thenRn` \ new_op ->
304 rnBangTy ty1 `thenRn` \ new_ty1 ->
305 rnBangTy ty2 `thenRn` \ new_ty2 ->
306 returnRn (ConOpDecl new_ty1 new_op new_ty2 src_loc)
308 rnConDecl (NewConDecl name ty src_loc)
309 = pushSrcLocRn src_loc $
310 checkConName name `thenRn_`
311 lookupRn name `thenRn` \ new_name ->
312 rnHsType ty `thenRn` \ new_ty ->
313 returnRn (NewConDecl new_name new_ty src_loc)
315 rnConDecl (RecConDecl name fields src_loc)
316 = pushSrcLocRn src_loc $
317 lookupRn name `thenRn` \ new_name ->
318 mapRn rnField fields `thenRn` \ new_fields ->
319 returnRn (RecConDecl new_name new_fields src_loc)
322 = mapRn lookupRn names `thenRn` \ new_names ->
323 rnBangTy ty `thenRn` \ new_ty ->
324 returnRn (new_names, new_ty)
327 = rnHsType ty `thenRn` \ new_ty ->
328 returnRn (Banged new_ty)
330 rnBangTy (Unbanged ty)
331 = rnHsType ty `thenRn` \ new_ty ->
332 returnRn (Unbanged new_ty)
334 -- This data decl will parse OK
336 -- treating "a" as the constructor.
337 -- It is really hard to make the parser spot this malformation.
338 -- So the renamer has to check that the constructor is legal
340 -- We can get an operator as the constructor, even in the prefix form:
341 -- data T = :% Int Int
342 -- from interface files, which always print in prefix form
345 = checkRn (isLexCon (occNameString (rdrNameOcc name)))
350 %*********************************************************
352 \subsection{Support code to rename types}
354 %*********************************************************
357 rnHsType :: RdrNameHsType -> RnMS s RenamedHsType
359 rnHsType (HsForAllTy tvs ctxt ty)
360 = rn_poly_help tvs ctxt ty
362 rnHsType full_ty@(HsPreForAllTy ctxt ty)
363 = getNameEnv `thenRn` \ name_env ->
365 mentioned_tyvars = extractHsTyVars full_ty
366 forall_tyvars = filter not_in_scope mentioned_tyvars
367 not_in_scope tv = case lookupFM name_env tv of
371 rn_poly_help (map UserTyVar forall_tyvars) ctxt ty
373 rnHsType (MonoTyVar tyvar)
374 = lookupOccRn tyvar `thenRn` \ tyvar' ->
375 returnRn (MonoTyVar tyvar')
377 rnHsType (MonoFunTy ty1 ty2)
378 = andRn MonoFunTy (rnHsType ty1) (rnHsType ty2)
380 rnHsType (MonoListTy _ ty)
381 = lookupImplicitOccRn listType_RDR `thenRn` \ tycon_name ->
382 rnHsType ty `thenRn` \ ty' ->
383 returnRn (MonoListTy tycon_name ty')
385 rnHsType (MonoTupleTy _ tys)
386 = lookupImplicitOccRn (tupleType_RDR (length tys)) `thenRn` \ tycon_name ->
387 mapRn rnHsType tys `thenRn` \ tys' ->
388 returnRn (MonoTupleTy tycon_name tys')
390 rnHsType (MonoTyApp ty1 ty2)
391 = rnHsType ty1 `thenRn` \ ty1' ->
392 rnHsType ty2 `thenRn` \ ty2' ->
393 returnRn (MonoTyApp ty1' ty2')
395 rnHsType (MonoDictTy clas ty)
396 = lookupOccRn clas `thenRn` \ clas' ->
397 rnHsType ty `thenRn` \ ty' ->
398 returnRn (MonoDictTy clas' ty')
401 rn_poly_help :: [HsTyVar RdrName] -- Universally quantified tyvars
404 -> RnMS s RenamedHsType
406 rn_poly_help tyvars ctxt ty
407 = bindTyVarsRn "type signature" tyvars $ \ new_tyvars ->
408 rnContext ctxt `thenRn` \ new_ctxt ->
409 rnHsType ty `thenRn` \ new_ty ->
410 returnRn (HsForAllTy new_tyvars new_ctxt new_ty)
415 rnContext :: RdrNameContext -> RnMS s RenamedContext
418 = mapRn rn_ctxt ctxt `thenRn` \ result ->
420 (_, dup_asserts) = removeDups cmp_assert result
422 -- If this isn't an error, then it ought to be:
423 mapRn (addWarnRn . dupClassAssertWarn result) dup_asserts `thenRn_`
427 = lookupOccRn clas `thenRn` \ clas_name ->
428 rnHsType ty `thenRn` \ ty' ->
429 returnRn (clas_name, ty')
431 cmp_assert (c1,ty1) (c2,ty2)
432 = (c1 `cmp` c2) `thenCmp` (cmpHsType cmp ty1 ty2)
436 %*********************************************************
440 %*********************************************************
443 rnIdInfo (HsStrictness strict)
444 = rnStrict strict `thenRn` \ strict' ->
445 returnRn (HsStrictness strict')
447 rnIdInfo (HsUnfold expr) = rnCoreExpr expr `thenRn` \ expr' ->
448 returnRn (HsUnfold expr')
449 rnIdInfo (HsArity arity) = returnRn (HsArity arity)
450 rnIdInfo (HsUpdate update) = returnRn (HsUpdate update)
451 rnIdInfo (HsFBType fb) = returnRn (HsFBType fb)
452 rnIdInfo (HsArgUsage au) = returnRn (HsArgUsage au)
453 rnIdInfo (HsDeforest df) = returnRn (HsDeforest df)
455 rnStrict (StrictnessInfo demands (Just worker))
456 = lookupOptionalOccRn worker `thenRn` \ worker' ->
457 returnRn (StrictnessInfo demands (Just worker'))
459 -- Boring, but necessary for the type checker.
460 rnStrict (StrictnessInfo demands Nothing) = returnRn (StrictnessInfo demands Nothing)
461 rnStrict BottomGuaranteed = returnRn BottomGuaranteed
462 rnStrict NoStrictnessInfo = returnRn NoStrictnessInfo
469 = lookupOptionalOccRn v `thenRn` \ v' ->
472 rnCoreExpr (UfLit lit) = returnRn (UfLit lit)
474 rnCoreExpr (UfCon con args)
475 = lookupOptionalOccRn con `thenRn` \ con' ->
476 mapRn rnCoreArg args `thenRn` \ args' ->
477 returnRn (UfCon con' args')
479 rnCoreExpr (UfPrim prim args)
480 = rnCorePrim prim `thenRn` \ prim' ->
481 mapRn rnCoreArg args `thenRn` \ args' ->
482 returnRn (UfPrim prim' args')
484 rnCoreExpr (UfApp fun arg)
485 = rnCoreExpr fun `thenRn` \ fun' ->
486 rnCoreArg arg `thenRn` \ arg' ->
487 returnRn (UfApp fun' arg')
489 rnCoreExpr (UfCase scrut alts)
490 = rnCoreExpr scrut `thenRn` \ scrut' ->
491 rnCoreAlts alts `thenRn` \ alts' ->
492 returnRn (UfCase scrut' alts')
494 rnCoreExpr (UfSCC cc expr)
495 = rnCoreExpr expr `thenRn` \ expr' ->
496 returnRn (UfSCC cc expr')
498 rnCoreExpr(UfCoerce coercion ty body)
499 = rnCoercion coercion `thenRn` \ coercion' ->
500 rnHsType ty `thenRn` \ ty' ->
501 rnCoreExpr body `thenRn` \ body' ->
502 returnRn (UfCoerce coercion' ty' body')
504 rnCoreExpr (UfLam bndr body)
505 = rnCoreBndr bndr $ \ bndr' ->
506 rnCoreExpr body `thenRn` \ body' ->
507 returnRn (UfLam bndr' body')
509 rnCoreExpr (UfLet (UfNonRec bndr rhs) body)
510 = rnCoreExpr rhs `thenRn` \ rhs' ->
511 rnCoreBndr bndr $ \ bndr' ->
512 rnCoreExpr body `thenRn` \ body' ->
513 returnRn (UfLet (UfNonRec bndr' rhs') body')
515 rnCoreExpr (UfLet (UfRec pairs) body)
516 = rnCoreBndrs bndrs $ \ bndrs' ->
517 mapRn rnCoreExpr rhss `thenRn` \ rhss' ->
518 rnCoreExpr body `thenRn` \ body' ->
519 returnRn (UfLet (UfRec (bndrs' `zip` rhss')) body')
521 (bndrs, rhss) = unzip pairs
525 rnCoreBndr (UfValBinder name ty) thing_inside
526 = rnHsType ty `thenRn` \ ty' ->
527 bindLocalsRn "unfolding value" [name] $ \ [name'] ->
528 thing_inside (UfValBinder name' ty')
530 rnCoreBndr (UfTyBinder name kind) thing_inside
531 = bindLocalsRn "unfolding tyvar" [name] $ \ [name'] ->
532 thing_inside (UfTyBinder name' kind)
534 rnCoreBndr (UfUsageBinder name) thing_inside
535 = bindLocalsRn "unfolding usage" [name] $ \ [name'] ->
536 thing_inside (UfUsageBinder name')
538 rnCoreBndrs bndrs thing_inside -- Expect them all to be ValBinders
539 = mapRn rnHsType tys `thenRn` \ tys' ->
540 bindLocalsRn "unfolding value" names $ \ names' ->
541 thing_inside (zipWith UfValBinder names' tys')
543 names = map (\ (UfValBinder name _) -> name) bndrs
544 tys = map (\ (UfValBinder _ ty) -> ty) bndrs
548 rnCoreArg (UfVarArg v) = lookupOptionalOccRn v `thenRn` \ v' -> returnRn (UfVarArg v')
549 rnCoreArg (UfUsageArg u) = lookupOptionalOccRn u `thenRn` \ u' -> returnRn (UfUsageArg u')
550 rnCoreArg (UfTyArg ty) = rnHsType ty `thenRn` \ ty' -> returnRn (UfTyArg ty')
551 rnCoreArg (UfLitArg lit) = returnRn (UfLitArg lit)
553 rnCoreAlts (UfAlgAlts alts deflt)
554 = mapRn rn_alt alts `thenRn` \ alts' ->
555 rnCoreDefault deflt `thenRn` \ deflt' ->
556 returnRn (UfAlgAlts alts' deflt')
558 rn_alt (con, bndrs, rhs) = lookupOptionalOccRn con `thenRn` \ con' ->
559 rnCoreBndrs bndrs $ \ bndrs' ->
560 rnCoreExpr rhs `thenRn` \ rhs' ->
561 returnRn (con', bndrs', rhs')
563 rnCoreAlts (UfPrimAlts alts deflt)
564 = mapRn rn_alt alts `thenRn` \ alts' ->
565 rnCoreDefault deflt `thenRn` \ deflt' ->
566 returnRn (UfPrimAlts alts' deflt')
568 rn_alt (lit, rhs) = rnCoreExpr rhs `thenRn` \ rhs' ->
571 rnCoreDefault UfNoDefault = returnRn UfNoDefault
572 rnCoreDefault (UfBindDefault bndr rhs) = rnCoreBndr bndr $ \ bndr' ->
573 rnCoreExpr rhs `thenRn` \ rhs' ->
574 returnRn (UfBindDefault bndr' rhs')
576 rnCoercion (UfIn n) = lookupOptionalOccRn n `thenRn` \ n' -> returnRn (UfIn n')
577 rnCoercion (UfOut n) = lookupOptionalOccRn n `thenRn` \ n' -> returnRn (UfOut n')
579 rnCorePrim (UfOtherOp op)
580 = lookupOptionalOccRn op `thenRn` \ op' ->
581 returnRn (UfOtherOp op')
583 rnCorePrim (UfCCallOp str casm gc arg_tys res_ty)
584 = mapRn rnHsType arg_tys `thenRn` \ arg_tys' ->
585 rnHsType res_ty `thenRn` \ res_ty' ->
586 returnRn (UfCCallOp str casm gc arg_tys' res_ty')
589 %*********************************************************
593 %*********************************************************
596 derivingNonStdClassErr clas sty
597 = ppCat [ppStr "non-standard class in deriving:", ppr sty clas]
599 classTyVarNotInOpTyErr clas_tyvar sig sty
600 = ppHang (ppBesides [ppStr "Class type variable `", ppr sty clas_tyvar, ppStr "' does not appear in method signature:"])
603 classTyVarInOpCtxtErr clas_tyvar sig sty
604 = ppHang (ppBesides [ ppStr "Class type variable `", ppr sty clas_tyvar,
605 ppStr "' present in method's local overloading context:"])
608 dupClassAssertWarn ctxt dups sty
609 = ppHang (ppBesides [ppStr "Duplicate class assertion `", ppr sty dups, ppStr "' in context:"])
613 = ppCat [ppStr "Illegal data constructor name:", ppr sty name]
620 =================== OLD STUFF ======================
622 %*********************************************************
624 \subsection{SPECIALIZE data pragmas}
626 %*********************************************************
629 rnSpecDataSig :: RdrNameSpecDataSig
630 -> RnMS s RenamedSpecDataSig
632 rnSpecDataSig (SpecDataSig tycon ty src_loc)
633 = pushSrcLocRn src_loc $
635 tyvars = filter extractHsTyNames ty
637 mkTyVarNamesEnv src_loc tyvars `thenRn` \ (tv_env,_) ->
638 lookupOccRn tycon `thenRn` \ tycon' ->
639 rnHsType tv_env ty `thenRn` \ ty' ->
640 returnRn (SpecDataSig tycon' ty' src_loc)
644 %*********************************************************
646 \subsection{@SPECIALIZE instance@ user-pragmas}
648 %*********************************************************
651 rnSpecInstSig :: RdrNameSpecInstSig
652 -> RnMS s RenamedSpecInstSig
654 rnSpecInstSig (SpecInstSig clas ty src_loc)
655 = pushSrcLocRn src_loc $
657 tyvars = extractHsTyNames is_tyvar_name ty
659 mkTyVarNamesEnv src_loc tyvars `thenRn` \ (tv_env,_) ->
660 lookupOccRn clas `thenRn` \ new_clas ->
661 rnHsType tv_env ty `thenRn` \ new_ty ->
662 returnRn (SpecInstSig new_clas new_ty src_loc)