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 )
22 import RnBinds ( rnTopBinds, rnMethodBinds )
23 import RnEnv ( bindTyVarsRn, lookupRn, lookupOccRn, lookupImplicitOccRn, bindLocalsRn,
24 lookupOptionalOccRn, newDfunName,
25 listType_RDR, tupleType_RDR )
28 import Name ( Name, isLocallyDefined, isTvOcc, pprNonSym,
30 SYN_IE(NameSet), unionNameSets, emptyNameSet, mkNameSet, unitNameSet,
33 import ErrUtils ( addErrLoc, addShortErrLocLine, addShortWarnLocLine )
34 import FiniteMap ( emptyFM, lookupFM, addListToFM_C )
35 import Id ( GenId{-instance NamedThing-} )
36 import IdInfo ( IdInfo, StrictnessInfo(..), FBTypeInfo, DemandInfo, ArgUsageInfo )
37 import SpecEnv ( SpecEnv )
38 import CoreUnfold ( Unfolding(..), SimpleUnfolding )
39 import MagicUFs ( MagicUnfoldingFun )
40 import PrelInfo ( derivingOccurrences, evalClass_RDR, numClass_RDR )
41 import ListSetOps ( unionLists, minusList )
42 import Maybes ( maybeToBool, catMaybes )
43 import Bag ( emptyBag, unitBag, consBag, unionManyBags, unionBags, listToBag, bagToList )
44 import Outputable ( Outputable(..){-instances-} )
45 --import PprStyle -- ToDo:rm
47 import SrcLoc ( SrcLoc )
48 -- import TyCon ( TyCon{-instance NamedThing-} )
49 import Unique ( Unique )
50 import UniqSet ( SYN_IE(UniqSet) )
51 import UniqFM ( UniqFM, lookupUFM )
52 import Util ( isIn, isn'tIn, thenCmp, removeDups, cmpPString,
53 panic, assertPanic{- , pprTrace ToDo:rm-} )
56 rnDecl `renames' declarations.
57 It simultaneously performs dependency analysis and precedence parsing.
58 It also does the following error checks:
61 Checks that tyvars are used properly. This includes checking
62 for undefined tyvars, and tyvars in contexts that are ambiguous.
64 Checks that all variable occurences are defined.
66 Checks the (..) etc constraints in the export list.
70 %*********************************************************
72 \subsection{Value declarations}
74 %*********************************************************
77 rnDecl :: RdrNameHsDecl -> RnMS s RenamedHsDecl
79 rnDecl (ValD binds) = rnTopBinds binds `thenRn` \ new_binds ->
80 returnRn (ValD new_binds)
83 rnDecl (SigD (IfaceSig name ty id_infos loc))
85 lookupRn name `thenRn` \ name' ->
86 rnHsType ty `thenRn` \ ty' ->
87 mapRn rnIdInfo id_infos `thenRn` \ id_infos' ->
88 returnRn (SigD (IfaceSig name' ty' id_infos' loc))
91 %*********************************************************
93 \subsection{Type declarations}
95 %*********************************************************
97 @rnTyDecl@ uses the `global name function' to create a new type
98 declaration in which local names have been replaced by their original
99 names, reporting any unknown names.
101 Renaming type variables is a pain. Because they now contain uniques,
102 it is necessary to pass in an association list which maps a parsed
103 tyvar to its Name representation. In some cases (type signatures of
104 values), it is even necessary to go over the type first in order to
105 get the set of tyvars used by it, make an assoc list, and then go over
106 it again to rename the tyvars! However, we can also do some scoping
107 checks at the same time.
110 rnDecl (TyD (TyData context tycon tyvars condecls derivings pragmas src_loc))
111 = pushSrcLocRn src_loc $
112 lookupRn tycon `thenRn` \ tycon' ->
113 bindTyVarsRn "data declaration" tyvars $ \ tyvars' ->
114 rnContext context `thenRn` \ context' ->
115 mapRn rnConDecl condecls `thenRn` \ condecls' ->
116 rnDerivs derivings `thenRn` \ derivings' ->
117 ASSERT(isNoDataPragmas pragmas)
118 returnRn (TyD (TyData context' tycon' tyvars' condecls' derivings' noDataPragmas src_loc))
120 rnDecl (TyD (TyNew context tycon tyvars condecl derivings pragmas src_loc))
121 = pushSrcLocRn src_loc $
122 lookupRn tycon `thenRn` \ tycon' ->
123 bindTyVarsRn "newtype declaration" tyvars $ \ tyvars' ->
124 rnContext context `thenRn` \ context' ->
125 rnConDecl condecl `thenRn` \ condecl' ->
126 rnDerivs derivings `thenRn` \ derivings' ->
127 ASSERT(isNoDataPragmas pragmas)
128 returnRn (TyD (TyNew context' tycon' tyvars' condecl' derivings' noDataPragmas src_loc))
130 rnDecl (TyD (TySynonym name tyvars ty src_loc))
131 = pushSrcLocRn src_loc $
132 lookupRn name `thenRn` \ name' ->
133 bindTyVarsRn "type declaration" tyvars $ \ tyvars' ->
134 rnHsType ty `thenRn` \ ty' ->
135 returnRn (TyD (TySynonym name' tyvars' ty' src_loc))
138 %*********************************************************
140 \subsection{Class declarations}
142 %*********************************************************
144 @rnClassDecl@ uses the `global name function' to create a new
145 class declaration in which local names have been replaced by their
146 original names, reporting any unknown names.
149 rnDecl (ClD (ClassDecl context cname tyvar sigs mbinds pragmas src_loc))
150 = pushSrcLocRn src_loc $
151 bindTyVarsRn "class declaration" [tyvar] $ \ [tyvar'] ->
152 rnContext context `thenRn` \ context' ->
153 lookupRn cname `thenRn` \ cname' ->
154 mapRn (rn_op cname' (getTyVarName tyvar')) sigs `thenRn` \ sigs' ->
155 rnMethodBinds mbinds `thenRn` \ mbinds' ->
156 ASSERT(isNoClassPragmas pragmas)
157 returnRn (ClD (ClassDecl context' cname' tyvar' sigs' mbinds' NoClassPragmas src_loc))
159 rn_op clas clas_tyvar sig@(ClassOpSig op ty pragmas locn)
160 = pushSrcLocRn locn $
161 lookupRn op `thenRn` \ op_name ->
162 rnHsType ty `thenRn` \ new_ty ->
164 (ctxt, op_ty) = case new_ty of
165 HsForAllTy tvs ctxt op_ty -> (ctxt, op_ty)
166 other -> ([], new_ty)
167 ctxt_fvs = extractCtxtTyNames ctxt
168 op_ty_fvs = extractHsTyNames op_ty -- Includes tycons/classes but we
169 -- don't care about that
171 -- check that class tyvar appears in op_ty
172 checkRn (clas_tyvar `elemNameSet` op_ty_fvs)
173 (classTyVarNotInOpTyErr clas_tyvar sig)
176 -- check that class tyvar *doesn't* appear in the sig's context
177 checkRn (not (clas_tyvar `elemNameSet` ctxt_fvs))
178 (classTyVarInOpCtxtErr clas_tyvar sig)
181 ASSERT(isNoClassOpPragmas pragmas)
182 returnRn (ClassOpSig op_name new_ty noClassOpPragmas locn)
186 %*********************************************************
188 \subsection{Instance declarations}
190 %*********************************************************
193 rnDecl (InstD (InstDecl inst_ty mbinds uprags maybe_dfun_name src_loc))
194 = pushSrcLocRn src_loc $
195 rnHsType inst_ty `thenRn` \ inst_ty' ->
196 rnMethodBinds mbinds `thenRn` \ mbinds' ->
197 mapRn rn_uprag uprags `thenRn` \ new_uprags ->
198 rn_dfun maybe_dfun_name `thenRn` \ dfun_name' ->
200 returnRn (InstD (InstDecl inst_ty' mbinds' new_uprags dfun_name' src_loc))
202 rn_dfun Nothing = newDfunName src_loc `thenRn` \ n' ->
204 rn_dfun (Just n) = lookupOccRn n `thenRn` \ n' ->
205 -- The dfun is not optional, because we use its version number
206 -- to identify the version of the instance declaration
209 rn_uprag (SpecSig op ty using locn)
210 = pushSrcLocRn src_loc $
211 lookupRn op `thenRn` \ op_name ->
212 rnHsType ty `thenRn` \ new_ty ->
213 rn_using using `thenRn` \ new_using ->
214 returnRn (SpecSig op_name new_ty new_using locn)
216 rn_uprag (InlineSig op locn)
217 = pushSrcLocRn locn $
218 lookupRn op `thenRn` \ op_name ->
219 returnRn (InlineSig op_name locn)
221 rn_uprag (DeforestSig op locn)
222 = pushSrcLocRn locn $
223 lookupRn op `thenRn` \ op_name ->
224 returnRn (DeforestSig op_name locn)
226 rn_uprag (MagicUnfoldingSig op str locn)
227 = pushSrcLocRn locn $
228 lookupRn op `thenRn` \ op_name ->
229 returnRn (MagicUnfoldingSig op_name str locn)
231 rn_using Nothing = returnRn Nothing
232 rn_using (Just v) = lookupOccRn v `thenRn` \ new_v ->
233 returnRn (Just new_v)
236 %*********************************************************
238 \subsection{Default declarations}
240 %*********************************************************
243 rnDecl (DefD (DefaultDecl tys src_loc))
244 = pushSrcLocRn src_loc $
245 mapRn rnHsType tys `thenRn` \ tys' ->
246 lookupImplicitOccRn numClass_RDR `thenRn_`
247 returnRn (DefD (DefaultDecl tys' src_loc))
250 %*********************************************************
252 \subsection{Support code for type/data declarations}
254 %*********************************************************
257 rnDerivs :: Maybe [RdrName] -> RnMS s (Maybe [Name])
259 rnDerivs Nothing -- derivs not specified
260 = lookupImplicitOccRn evalClass_RDR `thenRn_`
264 = lookupImplicitOccRn evalClass_RDR `thenRn_`
265 mapRn rn_deriv ds `thenRn` \ derivs ->
266 returnRn (Just derivs)
269 = lookupOccRn clas `thenRn` \ clas_name ->
271 -- Now add extra "occurrences" for things that
272 -- the deriving mechanism will later need in order to
273 -- generate code for this class.
274 case lookupUFM derivingOccurrences clas_name of
275 Nothing -> addErrRn (derivingNonStdClassErr clas_name) `thenRn_`
278 Just occs -> mapRn lookupImplicitOccRn occs `thenRn_`
283 rnConDecl :: RdrNameConDecl -> RnMS s RenamedConDecl
285 rnConDecl (ConDecl name tys src_loc)
286 = pushSrcLocRn src_loc $
287 lookupRn name `thenRn` \ new_name ->
288 mapRn rnBangTy tys `thenRn` \ new_tys ->
289 returnRn (ConDecl new_name new_tys src_loc)
291 rnConDecl (ConOpDecl ty1 op ty2 src_loc)
292 = pushSrcLocRn src_loc $
293 lookupRn op `thenRn` \ new_op ->
294 rnBangTy ty1 `thenRn` \ new_ty1 ->
295 rnBangTy ty2 `thenRn` \ new_ty2 ->
296 returnRn (ConOpDecl new_ty1 new_op new_ty2 src_loc)
298 rnConDecl (NewConDecl name ty src_loc)
299 = pushSrcLocRn src_loc $
300 lookupRn name `thenRn` \ new_name ->
301 rnHsType ty `thenRn` \ new_ty ->
302 returnRn (NewConDecl new_name new_ty src_loc)
304 rnConDecl (RecConDecl name fields src_loc)
305 = pushSrcLocRn src_loc $
306 lookupRn name `thenRn` \ new_name ->
307 mapRn rnField fields `thenRn` \ new_fields ->
308 returnRn (RecConDecl new_name new_fields src_loc)
311 = mapRn lookupRn names `thenRn` \ new_names ->
312 rnBangTy ty `thenRn` \ new_ty ->
313 returnRn (new_names, new_ty)
316 = rnHsType ty `thenRn` \ new_ty ->
317 returnRn (Banged new_ty)
319 rnBangTy (Unbanged ty)
320 = rnHsType ty `thenRn` \ new_ty ->
321 returnRn (Unbanged new_ty)
325 %*********************************************************
327 \subsection{Support code to rename types}
329 %*********************************************************
332 rnHsType :: RdrNameHsType -> RnMS s RenamedHsType
334 rnHsType (HsForAllTy tvs ctxt ty)
335 = rn_poly_help tvs ctxt ty
337 rnHsType full_ty@(HsPreForAllTy ctxt ty)
338 = getNameEnv `thenRn` \ name_env ->
340 mentioned_tyvars = extractHsTyVars full_ty
341 forall_tyvars = filter not_in_scope mentioned_tyvars
342 not_in_scope tv = case lookupFM name_env tv of
346 rn_poly_help (map UserTyVar forall_tyvars) ctxt ty
348 rnHsType (MonoTyVar tyvar)
349 = lookupOccRn tyvar `thenRn` \ tyvar' ->
350 returnRn (MonoTyVar tyvar')
352 rnHsType (MonoFunTy ty1 ty2)
353 = andRn MonoFunTy (rnHsType ty1) (rnHsType ty2)
355 rnHsType (MonoListTy _ ty)
356 = lookupImplicitOccRn listType_RDR `thenRn` \ tycon_name ->
357 rnHsType ty `thenRn` \ ty' ->
358 returnRn (MonoListTy tycon_name ty')
360 rnHsType (MonoTupleTy _ tys)
361 = lookupImplicitOccRn (tupleType_RDR (length tys)) `thenRn` \ tycon_name ->
362 mapRn rnHsType tys `thenRn` \ tys' ->
363 returnRn (MonoTupleTy tycon_name tys')
365 rnHsType (MonoTyApp name tys)
366 = lookupOccRn name `thenRn` \ name' ->
367 mapRn rnHsType tys `thenRn` \ tys' ->
368 returnRn (MonoTyApp name' tys')
370 rnHsType (MonoDictTy clas ty)
371 = lookupOccRn clas `thenRn` \ clas' ->
372 rnHsType ty `thenRn` \ ty' ->
373 returnRn (MonoDictTy clas' ty')
376 rn_poly_help :: [HsTyVar RdrName] -- Universally quantified tyvars
379 -> RnMS s RenamedHsType
381 rn_poly_help tyvars ctxt ty
382 = bindTyVarsRn "type signature" tyvars $ \ new_tyvars ->
383 rnContext ctxt `thenRn` \ new_ctxt ->
384 rnHsType ty `thenRn` \ new_ty ->
385 returnRn (HsForAllTy new_tyvars new_ctxt new_ty)
390 rnContext :: RdrNameContext -> RnMS s RenamedContext
393 = mapRn rn_ctxt ctxt `thenRn` \ result ->
395 (_, dup_asserts) = removeDups cmp_assert result
397 -- If this isn't an error, then it ought to be:
398 mapRn (addWarnRn . dupClassAssertWarn result) dup_asserts `thenRn_`
402 = lookupOccRn clas `thenRn` \ clas_name ->
403 rnHsType ty `thenRn` \ ty' ->
404 returnRn (clas_name, ty')
406 cmp_assert (c1,ty1) (c2,ty2)
407 = (c1 `cmp` c2) `thenCmp` (cmpHsType cmp ty1 ty2)
411 %*********************************************************
415 %*********************************************************
418 rnIdInfo (HsStrictness strict)
419 = rnStrict strict `thenRn` \ strict' ->
420 returnRn (HsStrictness strict')
422 rnIdInfo (HsUnfold expr) = rnCoreExpr expr `thenRn` \ expr' ->
423 returnRn (HsUnfold expr')
424 rnIdInfo (HsArity arity) = returnRn (HsArity arity)
425 rnIdInfo (HsUpdate update) = returnRn (HsUpdate update)
426 rnIdInfo (HsFBType fb) = returnRn (HsFBType fb)
427 rnIdInfo (HsArgUsage au) = returnRn (HsArgUsage au)
428 rnIdInfo (HsDeforest df) = returnRn (HsDeforest df)
430 rnStrict (StrictnessInfo demands (Just worker))
431 = lookupOptionalOccRn worker `thenRn` \ worker' ->
432 returnRn (StrictnessInfo demands (Just worker'))
434 -- Boring, but necessary for the type checker.
435 rnStrict (StrictnessInfo demands Nothing) = returnRn (StrictnessInfo demands Nothing)
436 rnStrict BottomGuaranteed = returnRn BottomGuaranteed
437 rnStrict NoStrictnessInfo = returnRn NoStrictnessInfo
444 = lookupOptionalOccRn v `thenRn` \ v' ->
447 rnCoreExpr (UfLit lit) = returnRn (UfLit lit)
449 rnCoreExpr (UfCon con args)
450 = lookupOptionalOccRn con `thenRn` \ con' ->
451 mapRn rnCoreArg args `thenRn` \ args' ->
452 returnRn (UfCon con' args')
454 rnCoreExpr (UfPrim prim args)
455 = rnCorePrim prim `thenRn` \ prim' ->
456 mapRn rnCoreArg args `thenRn` \ args' ->
457 returnRn (UfPrim prim' args')
459 rnCoreExpr (UfApp fun arg)
460 = rnCoreExpr fun `thenRn` \ fun' ->
461 rnCoreArg arg `thenRn` \ arg' ->
462 returnRn (UfApp fun' arg')
464 rnCoreExpr (UfCase scrut alts)
465 = rnCoreExpr scrut `thenRn` \ scrut' ->
466 rnCoreAlts alts `thenRn` \ alts' ->
467 returnRn (UfCase scrut' alts')
469 rnCoreExpr (UfSCC cc expr)
470 = rnCoreExpr expr `thenRn` \ expr' ->
471 returnRn (UfSCC cc expr')
473 rnCoreExpr(UfCoerce coercion ty body)
474 = rnCoercion coercion `thenRn` \ coercion' ->
475 rnHsType ty `thenRn` \ ty' ->
476 rnCoreExpr body `thenRn` \ body' ->
477 returnRn (UfCoerce coercion' ty' body')
479 rnCoreExpr (UfLam bndr body)
480 = rnCoreBndr bndr $ \ bndr' ->
481 rnCoreExpr body `thenRn` \ body' ->
482 returnRn (UfLam bndr' body')
484 rnCoreExpr (UfLet (UfNonRec bndr rhs) body)
485 = rnCoreExpr rhs `thenRn` \ rhs' ->
486 rnCoreBndr bndr $ \ bndr' ->
487 rnCoreExpr body `thenRn` \ body' ->
488 returnRn (UfLet (UfNonRec bndr' rhs') body')
490 rnCoreExpr (UfLet (UfRec pairs) body)
491 = rnCoreBndrs bndrs $ \ bndrs' ->
492 mapRn rnCoreExpr rhss `thenRn` \ rhss' ->
493 rnCoreExpr body `thenRn` \ body' ->
494 returnRn (UfLet (UfRec (bndrs' `zip` rhss')) body')
496 (bndrs, rhss) = unzip pairs
500 rnCoreBndr (UfValBinder name ty) thing_inside
501 = rnHsType ty `thenRn` \ ty' ->
502 bindLocalsRn "unfolding value" [name] $ \ [name'] ->
503 thing_inside (UfValBinder name' ty')
505 rnCoreBndr (UfTyBinder name kind) thing_inside
506 = bindLocalsRn "unfolding tyvar" [name] $ \ [name'] ->
507 thing_inside (UfTyBinder name' kind)
509 rnCoreBndr (UfUsageBinder name) thing_inside
510 = bindLocalsRn "unfolding usage" [name] $ \ [name'] ->
511 thing_inside (UfUsageBinder name')
513 rnCoreBndrs bndrs thing_inside -- Expect them all to be ValBinders
514 = mapRn rnHsType tys `thenRn` \ tys' ->
515 bindLocalsRn "unfolding value" names $ \ names' ->
516 thing_inside (zipWith UfValBinder names' tys')
518 names = map (\ (UfValBinder name _) -> name) bndrs
519 tys = map (\ (UfValBinder _ ty) -> ty) bndrs
523 rnCoreArg (UfVarArg v) = lookupOptionalOccRn v `thenRn` \ v' -> returnRn (UfVarArg v')
524 rnCoreArg (UfUsageArg u) = lookupOptionalOccRn u `thenRn` \ u' -> returnRn (UfUsageArg u')
525 rnCoreArg (UfTyArg ty) = rnHsType ty `thenRn` \ ty' -> returnRn (UfTyArg ty')
526 rnCoreArg (UfLitArg lit) = returnRn (UfLitArg lit)
528 rnCoreAlts (UfAlgAlts alts deflt)
529 = mapRn rn_alt alts `thenRn` \ alts' ->
530 rnCoreDefault deflt `thenRn` \ deflt' ->
531 returnRn (UfAlgAlts alts' deflt')
533 rn_alt (con, bndrs, rhs) = lookupOptionalOccRn con `thenRn` \ con' ->
534 rnCoreBndrs bndrs $ \ bndrs' ->
535 rnCoreExpr rhs `thenRn` \ rhs' ->
536 returnRn (con', bndrs', rhs')
538 rnCoreAlts (UfPrimAlts alts deflt)
539 = mapRn rn_alt alts `thenRn` \ alts' ->
540 rnCoreDefault deflt `thenRn` \ deflt' ->
541 returnRn (UfPrimAlts alts' deflt')
543 rn_alt (lit, rhs) = rnCoreExpr rhs `thenRn` \ rhs' ->
546 rnCoreDefault UfNoDefault = returnRn UfNoDefault
547 rnCoreDefault (UfBindDefault bndr rhs) = rnCoreBndr bndr $ \ bndr' ->
548 rnCoreExpr rhs `thenRn` \ rhs' ->
549 returnRn (UfBindDefault bndr' rhs')
551 rnCoercion (UfIn n) = lookupOptionalOccRn n `thenRn` \ n' -> returnRn (UfIn n')
552 rnCoercion (UfOut n) = lookupOptionalOccRn n `thenRn` \ n' -> returnRn (UfOut n')
554 rnCorePrim (UfOtherOp op)
555 = lookupOptionalOccRn op `thenRn` \ op' ->
556 returnRn (UfOtherOp op')
558 rnCorePrim (UfCCallOp str casm gc arg_tys res_ty)
559 = mapRn rnHsType arg_tys `thenRn` \ arg_tys' ->
560 rnHsType res_ty `thenRn` \ res_ty' ->
561 returnRn (UfCCallOp str casm gc arg_tys' res_ty')
564 %*********************************************************
568 %*********************************************************
571 derivingNonStdClassErr clas sty
572 = ppCat [ppStr "non-standard class in deriving:", ppr sty clas]
574 classTyVarNotInOpTyErr clas_tyvar sig sty
575 = ppHang (ppBesides [ppStr "Class type variable `", ppr sty clas_tyvar, ppStr "' does not appear in method signature:"])
578 classTyVarInOpCtxtErr clas_tyvar sig sty
579 = ppHang (ppBesides [ ppStr "Class type variable `", ppr sty clas_tyvar,
580 ppStr "' present in method's local overloading context:"])
583 dupClassAssertWarn ctxt dups sty
584 = ppHang (ppBesides [ppStr "Duplicate class assertion `", ppr sty dups, ppStr "' in context:"])
592 =================== OLD STUFF ======================
594 %*********************************************************
596 \subsection{SPECIALIZE data pragmas}
598 %*********************************************************
601 rnSpecDataSig :: RdrNameSpecDataSig
602 -> RnMS s RenamedSpecDataSig
604 rnSpecDataSig (SpecDataSig tycon ty src_loc)
605 = pushSrcLocRn src_loc $
607 tyvars = filter extractHsTyNames ty
609 mkTyVarNamesEnv src_loc tyvars `thenRn` \ (tv_env,_) ->
610 lookupOccRn tycon `thenRn` \ tycon' ->
611 rnHsType tv_env ty `thenRn` \ ty' ->
612 returnRn (SpecDataSig tycon' ty' src_loc)
616 %*********************************************************
618 \subsection{@SPECIALIZE instance@ user-pragmas}
620 %*********************************************************
623 rnSpecInstSig :: RdrNameSpecInstSig
624 -> RnMS s RenamedSpecInstSig
626 rnSpecInstSig (SpecInstSig clas ty src_loc)
627 = pushSrcLocRn src_loc $
629 tyvars = extractHsTyNames is_tyvar_name ty
631 mkTyVarNamesEnv src_loc tyvars `thenRn` \ (tv_env,_) ->
632 lookupOccRn clas `thenRn` \ new_clas ->
633 rnHsType tv_env ty `thenRn` \ new_ty ->
634 returnRn (SpecInstSig new_clas new_ty src_loc)