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) = lookupOptionalOccRn n `thenRn` \ n' ->
207 rn_uprag (SpecSig op ty using locn)
208 = pushSrcLocRn src_loc $
209 lookupRn op `thenRn` \ op_name ->
210 rnHsType ty `thenRn` \ new_ty ->
211 rn_using using `thenRn` \ new_using ->
212 returnRn (SpecSig op_name new_ty new_using locn)
214 rn_uprag (InlineSig op locn)
215 = pushSrcLocRn locn $
216 lookupRn op `thenRn` \ op_name ->
217 returnRn (InlineSig op_name locn)
219 rn_uprag (DeforestSig op locn)
220 = pushSrcLocRn locn $
221 lookupRn op `thenRn` \ op_name ->
222 returnRn (DeforestSig op_name locn)
224 rn_uprag (MagicUnfoldingSig op str locn)
225 = pushSrcLocRn locn $
226 lookupRn op `thenRn` \ op_name ->
227 returnRn (MagicUnfoldingSig op_name str locn)
229 rn_using Nothing = returnRn Nothing
230 rn_using (Just v) = lookupOccRn v `thenRn` \ new_v ->
231 returnRn (Just new_v)
234 %*********************************************************
236 \subsection{Default declarations}
238 %*********************************************************
241 rnDecl (DefD (DefaultDecl tys src_loc))
242 = pushSrcLocRn src_loc $
243 mapRn rnHsType tys `thenRn` \ tys' ->
244 lookupImplicitOccRn numClass_RDR `thenRn_`
245 returnRn (DefD (DefaultDecl tys' src_loc))
248 %*********************************************************
250 \subsection{Support code for type/data declarations}
252 %*********************************************************
255 rnDerivs :: Maybe [RdrName] -> RnMS s (Maybe [Name])
257 rnDerivs Nothing -- derivs not specified
258 = lookupImplicitOccRn evalClass_RDR `thenRn_`
262 = lookupImplicitOccRn evalClass_RDR `thenRn_`
263 mapRn rn_deriv ds `thenRn` \ derivs ->
264 returnRn (Just derivs)
267 = lookupOccRn clas `thenRn` \ clas_name ->
269 -- Now add extra "occurrences" for things that
270 -- the deriving mechanism will later need in order to
271 -- generate code for this class.
272 case lookupUFM derivingOccurrences clas_name of
273 Nothing -> addErrRn (derivingNonStdClassErr clas_name) `thenRn_`
276 Just occs -> mapRn lookupImplicitOccRn occs `thenRn_`
281 rnConDecl :: RdrNameConDecl -> RnMS s RenamedConDecl
283 rnConDecl (ConDecl name tys src_loc)
284 = pushSrcLocRn src_loc $
285 lookupRn name `thenRn` \ new_name ->
286 mapRn rnBangTy tys `thenRn` \ new_tys ->
287 returnRn (ConDecl new_name new_tys src_loc)
289 rnConDecl (ConOpDecl ty1 op ty2 src_loc)
290 = pushSrcLocRn src_loc $
291 lookupRn op `thenRn` \ new_op ->
292 rnBangTy ty1 `thenRn` \ new_ty1 ->
293 rnBangTy ty2 `thenRn` \ new_ty2 ->
294 returnRn (ConOpDecl new_ty1 new_op new_ty2 src_loc)
296 rnConDecl (NewConDecl name ty src_loc)
297 = pushSrcLocRn src_loc $
298 lookupRn name `thenRn` \ new_name ->
299 rnHsType ty `thenRn` \ new_ty ->
300 returnRn (NewConDecl new_name new_ty src_loc)
302 rnConDecl (RecConDecl name fields src_loc)
303 = pushSrcLocRn src_loc $
304 lookupRn name `thenRn` \ new_name ->
305 mapRn rnField fields `thenRn` \ new_fields ->
306 returnRn (RecConDecl new_name new_fields src_loc)
309 = mapRn lookupRn names `thenRn` \ new_names ->
310 rnBangTy ty `thenRn` \ new_ty ->
311 returnRn (new_names, new_ty)
314 = rnHsType ty `thenRn` \ new_ty ->
315 returnRn (Banged new_ty)
317 rnBangTy (Unbanged ty)
318 = rnHsType ty `thenRn` \ new_ty ->
319 returnRn (Unbanged new_ty)
323 %*********************************************************
325 \subsection{Support code to rename types}
327 %*********************************************************
330 rnHsType :: RdrNameHsType -> RnMS s RenamedHsType
332 rnHsType (HsForAllTy tvs ctxt ty)
333 = rn_poly_help tvs ctxt ty
335 rnHsType full_ty@(HsPreForAllTy ctxt ty)
336 = getNameEnv `thenRn` \ name_env ->
338 mentioned_tyvars = extractHsTyVars full_ty
339 forall_tyvars = filter not_in_scope mentioned_tyvars
340 not_in_scope tv = case lookupFM name_env tv of
344 rn_poly_help (map UserTyVar forall_tyvars) ctxt ty
346 rnHsType (MonoTyVar tyvar)
347 = lookupOccRn tyvar `thenRn` \ tyvar' ->
348 returnRn (MonoTyVar tyvar')
350 rnHsType (MonoFunTy ty1 ty2)
351 = andRn MonoFunTy (rnHsType ty1) (rnHsType ty2)
353 rnHsType (MonoListTy _ ty)
354 = lookupImplicitOccRn listType_RDR `thenRn` \ tycon_name ->
355 rnHsType ty `thenRn` \ ty' ->
356 returnRn (MonoListTy tycon_name ty')
358 rnHsType (MonoTupleTy _ tys)
359 = lookupImplicitOccRn (tupleType_RDR (length tys)) `thenRn` \ tycon_name ->
360 mapRn rnHsType tys `thenRn` \ tys' ->
361 returnRn (MonoTupleTy tycon_name tys')
363 rnHsType (MonoTyApp name tys)
364 = lookupOccRn name `thenRn` \ name' ->
365 mapRn rnHsType tys `thenRn` \ tys' ->
366 returnRn (MonoTyApp name' tys')
368 rnHsType (MonoDictTy clas ty)
369 = lookupOccRn clas `thenRn` \ clas' ->
370 rnHsType ty `thenRn` \ ty' ->
371 returnRn (MonoDictTy clas' ty')
374 rn_poly_help :: [HsTyVar RdrName] -- Universally quantified tyvars
377 -> RnMS s RenamedHsType
379 rn_poly_help tyvars ctxt ty
380 = bindTyVarsRn "type signature" tyvars $ \ new_tyvars ->
381 rnContext ctxt `thenRn` \ new_ctxt ->
382 rnHsType ty `thenRn` \ new_ty ->
383 returnRn (HsForAllTy new_tyvars new_ctxt new_ty)
388 rnContext :: RdrNameContext -> RnMS s RenamedContext
391 = mapRn rn_ctxt ctxt `thenRn` \ result ->
393 (_, dup_asserts) = removeDups cmp_assert result
395 -- If this isn't an error, then it ought to be:
396 mapRn (addWarnRn . dupClassAssertWarn result) dup_asserts `thenRn_`
400 = lookupOccRn clas `thenRn` \ clas_name ->
401 rnHsType ty `thenRn` \ ty' ->
402 returnRn (clas_name, ty')
404 cmp_assert (c1,ty1) (c2,ty2)
405 = (c1 `cmp` c2) `thenCmp` (cmpHsType cmp ty1 ty2)
409 %*********************************************************
413 %*********************************************************
416 rnIdInfo (HsStrictness strict)
417 = rnStrict strict `thenRn` \ strict' ->
418 returnRn (HsStrictness strict')
420 rnIdInfo (HsUnfold expr) = rnCoreExpr expr `thenRn` \ expr' ->
421 returnRn (HsUnfold expr')
422 rnIdInfo (HsArity arity) = returnRn (HsArity arity)
423 rnIdInfo (HsUpdate update) = returnRn (HsUpdate update)
424 rnIdInfo (HsFBType fb) = returnRn (HsFBType fb)
425 rnIdInfo (HsArgUsage au) = returnRn (HsArgUsage au)
426 rnIdInfo (HsDeforest df) = returnRn (HsDeforest df)
428 rnStrict (StrictnessInfo demands (Just worker))
429 = lookupOptionalOccRn worker `thenRn` \ worker' ->
430 returnRn (StrictnessInfo demands (Just worker'))
432 -- Boring, but necessary for the type checker.
433 rnStrict (StrictnessInfo demands Nothing) = returnRn (StrictnessInfo demands Nothing)
434 rnStrict BottomGuaranteed = returnRn BottomGuaranteed
435 rnStrict NoStrictnessInfo = returnRn NoStrictnessInfo
442 = lookupOptionalOccRn v `thenRn` \ v' ->
445 rnCoreExpr (UfLit lit) = returnRn (UfLit lit)
447 rnCoreExpr (UfCon con args)
448 = lookupOptionalOccRn con `thenRn` \ con' ->
449 mapRn rnCoreArg args `thenRn` \ args' ->
450 returnRn (UfCon con' args')
452 rnCoreExpr (UfPrim prim args)
453 = rnCorePrim prim `thenRn` \ prim' ->
454 mapRn rnCoreArg args `thenRn` \ args' ->
455 returnRn (UfPrim prim' args')
457 rnCoreExpr (UfApp fun arg)
458 = rnCoreExpr fun `thenRn` \ fun' ->
459 rnCoreArg arg `thenRn` \ arg' ->
460 returnRn (UfApp fun' arg')
462 rnCoreExpr (UfCase scrut alts)
463 = rnCoreExpr scrut `thenRn` \ scrut' ->
464 rnCoreAlts alts `thenRn` \ alts' ->
465 returnRn (UfCase scrut' alts')
467 rnCoreExpr (UfSCC cc expr)
468 = rnCoreExpr expr `thenRn` \ expr' ->
469 returnRn (UfSCC cc expr')
471 rnCoreExpr(UfCoerce coercion ty body)
472 = rnCoercion coercion `thenRn` \ coercion' ->
473 rnHsType ty `thenRn` \ ty' ->
474 rnCoreExpr body `thenRn` \ body' ->
475 returnRn (UfCoerce coercion' ty' body')
477 rnCoreExpr (UfLam bndr body)
478 = rnCoreBndr bndr $ \ bndr' ->
479 rnCoreExpr body `thenRn` \ body' ->
480 returnRn (UfLam bndr' body')
482 rnCoreExpr (UfLet (UfNonRec bndr rhs) body)
483 = rnCoreExpr rhs `thenRn` \ rhs' ->
484 rnCoreBndr bndr $ \ bndr' ->
485 rnCoreExpr body `thenRn` \ body' ->
486 returnRn (UfLet (UfNonRec bndr' rhs') body')
488 rnCoreExpr (UfLet (UfRec pairs) body)
489 = rnCoreBndrs bndrs $ \ bndrs' ->
490 mapRn rnCoreExpr rhss `thenRn` \ rhss' ->
491 rnCoreExpr body `thenRn` \ body' ->
492 returnRn (UfLet (UfRec (bndrs' `zip` rhss')) body')
494 (bndrs, rhss) = unzip pairs
498 rnCoreBndr (UfValBinder name ty) thing_inside
499 = rnHsType ty `thenRn` \ ty' ->
500 bindLocalsRn "unfolding value" [name] $ \ [name'] ->
501 thing_inside (UfValBinder name' ty')
503 rnCoreBndr (UfTyBinder name kind) thing_inside
504 = bindLocalsRn "unfolding tyvar" [name] $ \ [name'] ->
505 thing_inside (UfTyBinder name' kind)
507 rnCoreBndr (UfUsageBinder name) thing_inside
508 = bindLocalsRn "unfolding usage" [name] $ \ [name'] ->
509 thing_inside (UfUsageBinder name')
511 rnCoreBndrs bndrs thing_inside -- Expect them all to be ValBinders
512 = mapRn rnHsType tys `thenRn` \ tys' ->
513 bindLocalsRn "unfolding value" names $ \ names' ->
514 thing_inside (zipWith UfValBinder names' tys')
516 names = map (\ (UfValBinder name _) -> name) bndrs
517 tys = map (\ (UfValBinder _ ty) -> ty) bndrs
521 rnCoreArg (UfVarArg v) = lookupOptionalOccRn v `thenRn` \ v' -> returnRn (UfVarArg v')
522 rnCoreArg (UfUsageArg u) = lookupOptionalOccRn u `thenRn` \ u' -> returnRn (UfUsageArg u')
523 rnCoreArg (UfTyArg ty) = rnHsType ty `thenRn` \ ty' -> returnRn (UfTyArg ty')
524 rnCoreArg (UfLitArg lit) = returnRn (UfLitArg lit)
526 rnCoreAlts (UfAlgAlts alts deflt)
527 = mapRn rn_alt alts `thenRn` \ alts' ->
528 rnCoreDefault deflt `thenRn` \ deflt' ->
529 returnRn (UfAlgAlts alts' deflt')
531 rn_alt (con, bndrs, rhs) = lookupOptionalOccRn con `thenRn` \ con' ->
532 rnCoreBndrs bndrs $ \ bndrs' ->
533 rnCoreExpr rhs `thenRn` \ rhs' ->
534 returnRn (con', bndrs', rhs')
536 rnCoreAlts (UfPrimAlts alts deflt)
537 = mapRn rn_alt alts `thenRn` \ alts' ->
538 rnCoreDefault deflt `thenRn` \ deflt' ->
539 returnRn (UfPrimAlts alts' deflt')
541 rn_alt (lit, rhs) = rnCoreExpr rhs `thenRn` \ rhs' ->
544 rnCoreDefault UfNoDefault = returnRn UfNoDefault
545 rnCoreDefault (UfBindDefault bndr rhs) = rnCoreBndr bndr $ \ bndr' ->
546 rnCoreExpr rhs `thenRn` \ rhs' ->
547 returnRn (UfBindDefault bndr' rhs')
549 rnCoercion (UfIn n) = lookupOptionalOccRn n `thenRn` \ n' -> returnRn (UfIn n')
550 rnCoercion (UfOut n) = lookupOptionalOccRn n `thenRn` \ n' -> returnRn (UfOut n')
552 rnCorePrim (UfOtherOp op)
553 = lookupOptionalOccRn op `thenRn` \ op' ->
554 returnRn (UfOtherOp op')
556 rnCorePrim (UfCCallOp str casm gc arg_tys res_ty)
557 = mapRn rnHsType arg_tys `thenRn` \ arg_tys' ->
558 rnHsType res_ty `thenRn` \ res_ty' ->
559 returnRn (UfCCallOp str casm gc arg_tys' res_ty')
562 %*********************************************************
566 %*********************************************************
569 derivingNonStdClassErr clas sty
570 = ppCat [ppStr "non-standard class in deriving:", ppr sty clas]
572 classTyVarNotInOpTyErr clas_tyvar sig sty
573 = ppHang (ppBesides [ppStr "Class type variable `", ppr sty clas_tyvar, ppStr "' does not appear in method signature:"])
576 classTyVarInOpCtxtErr clas_tyvar sig sty
577 = ppHang (ppBesides [ ppStr "Class type variable `", ppr sty clas_tyvar,
578 ppStr "' present in method's local overloading context:"])
581 dupClassAssertWarn ctxt dups sty
582 = ppHang (ppBesides [ppStr "Duplicate class assertion `", ppr sty dups, ppStr "' in context:"])
590 =================== OLD STUFF ======================
592 %*********************************************************
594 \subsection{SPECIALIZE data pragmas}
596 %*********************************************************
599 rnSpecDataSig :: RdrNameSpecDataSig
600 -> RnMS s RenamedSpecDataSig
602 rnSpecDataSig (SpecDataSig tycon ty src_loc)
603 = pushSrcLocRn src_loc $
605 tyvars = filter extractHsTyNames ty
607 mkTyVarNamesEnv src_loc tyvars `thenRn` \ (tv_env,_) ->
608 lookupOccRn tycon `thenRn` \ tycon' ->
609 rnHsType tv_env ty `thenRn` \ ty' ->
610 returnRn (SpecDataSig tycon' ty' src_loc)
614 %*********************************************************
616 \subsection{@SPECIALIZE instance@ user-pragmas}
618 %*********************************************************
621 rnSpecInstSig :: RdrNameSpecInstSig
622 -> RnMS s RenamedSpecInstSig
624 rnSpecInstSig (SpecInstSig clas ty src_loc)
625 = pushSrcLocRn src_loc $
627 tyvars = extractHsTyNames is_tyvar_name ty
629 mkTyVarNamesEnv src_loc tyvars `thenRn` \ (tv_env,_) ->
630 lookupOccRn clas `thenRn` \ new_clas ->
631 rnHsType tv_env ty `thenRn` \ new_ty ->
632 returnRn (SpecInstSig new_clas new_ty src_loc)