{-# LANGUAGE CPP #-}{-# LANGUAGE LambdaCase #-}-- | This module implements interface renaming, which is-- used to rewrite interface files on the fly when we-- are doing indefinite typechecking and need instantiations-- of modules which do not necessarily exist yet.moduleRnModIface(rnModIface ,rnModExports ,tcRnModIface ,tcRnModExports ,)where#include "HsVersions.h" importGhcPreludeimportSrcLocimportOutputableimportHscTypesimportModuleimportUniqFMimportAvailimportIfaceSynimportFieldLabelimportVarimportErrUtilsimportNameimportTcRnMonad importUtilimportFingerprintimportBasicTypes-- a bit vexingimport{-# SOURCE#-}LoadIface importDynFlagsimportqualifiedData.TraversableasTimportBagimportData.IORefimportNameShape importIfaceEnv tcRnMsgMaybe::IO(EitherErrorMessagesa )->TcMa tcRnMsgMaybe do_this =dor <-liftIO$do_this caser ofLefterrs ->doaddMessages (emptyBag,errs )failMRightx ->returnx tcRnModIface::[(ModuleName,Module)]->MaybeNameShape->ModIface->TcMModIfacetcRnModIface x y z =dohsc_env <-getTopEnv tcRnMsgMaybe $rnModIface hsc_env x y z tcRnModExports::[(ModuleName,Module)]->ModIface->TcM[AvailInfo]tcRnModExports x y =dohsc_env <-getTopEnv tcRnMsgMaybe $rnModExports hsc_env x y failWithRn::SDoc->ShIfM a failWithRn doc =doerrs_var <-fmapsh_if_errsgetGblEnv dflags <-getDynFlagserrs <-readTcRef errs_var -- TODO: maybe associate this with a source location?writeTcRef errs_var (errs `snocBag`mkPlainErrMsgdflags noSrcSpandoc )failM-- | What we have is a generalized ModIface, which corresponds to-- a module that looks like p[A=<A>]:B. We need a *specific* ModIface, e.g.-- p[A=q():A]:B (or maybe even p[A=<B>]:B) which we load-- up (either to merge it, or to just use during typechecking).---- Suppose we have:---- p[A=<A>]:M ==> p[A=q():A]:M---- Substitute all occurrences of <A> with q():A (renameHoleModule).-- Then, for any Name of form {A.T}, replace the Name with-- the Name according to the exports of the implementing module.-- This works even for p[A=<B>]:M, since we just read in the-- exports of B.hi, which is assumed to be ready now.---- This function takes an optional 'NameShape', which can be used-- to further refine the identities in this interface: suppose-- we read a declaration for {H.T} but we actually know that this-- should be Foo.T; then we'll also rename this (this is used-- when loading an interface to merge it into a requirement.)rnModIface::HscEnv->[(ModuleName,Module)]->MaybeNameShape->ModIface->IO(EitherErrorMessagesModIface)rnModIface hsc_env insts nsubst iface =doinitRnIface hsc_env iface insts nsubst $domod <-rnModule (mi_moduleiface )sig_of <-casemi_sig_ofiface ofNothing->returnNothingJustx ->fmapJust(rnModule x )exports <-mapMrnAvailInfo (mi_exportsiface )decls <-mapMrnIfaceDecl' (mi_declsiface )insts <-mapMrnIfaceClsInst (mi_instsiface )fams <-mapMrnIfaceFamInst (mi_fam_instsiface )deps <-rnDependencies (mi_depsiface )-- TODO:-- mi_rulesreturniface {mi_module=mod ,mi_sig_of=sig_of ,mi_insts=insts ,mi_fam_insts=fams ,mi_exports=exports ,mi_decls=decls ,mi_deps=deps }-- | Rename just the exports of a 'ModIface'. Useful when we're doing-- shaping prior to signature merging.rnModExports::HscEnv->[(ModuleName,Module)]->ModIface->IO(EitherErrorMessages[AvailInfo])rnModExports hsc_env insts iface =initRnIface hsc_env iface insts Nothing$mapMrnAvailInfo (mi_exportsiface )rnDependencies::Rename DependenciesrnDependencies deps =doorphs <-rnDepModules dep_orphsdeps finsts <-rnDepModules dep_finstsdeps returndeps {dep_orphs=orphs ,dep_finsts=finsts }rnDepModules::(Dependencies->[Module])->Dependencies->ShIfM [Module]rnDepModules sel deps =dohsc_env <-getTopEnv hmap <-getHoleSubst -- NB: It's not necessary to test if we're doing signature renaming,-- because ModIface will never contain module reference for itself-- in these dependencies.fmap(nubSort.concat).T.forM(sel deps )$\mod ->dodflags <-getDynFlags-- For holes, its necessary to "see through" the instantiation-- of the hole to get accurate family instance dependencies.-- For example, if B imports <A>, and <A> is instantiated with-- F, we must grab and include all of the dep_finsts from-- F to have an accurate transitive dep_finsts list.---- However, we MUST NOT do this for regular modules.-- First, for efficiency reasons, doing this-- bloats the the dep_finsts list, because we *already* had-- those modules in the list (it wasn't a hole module, after-- all). But there's a second, more important correctness-- consideration: we perform module renaming when running-- --abi-hash. In this case, GHC's contract to the user is that-- it will NOT go and read out interfaces of any dependencies-- (https://github.com/haskell/cabal/issues/3633); the point of-- --abi-hash is just to get a hash of the on-disk interfaces-- for this *specific* package. If we go off and tug on the-- interface for /everything/ in dep_finsts, we're gonna have a-- bad time. (It's safe to do do this for hole modules, though,-- because the hmap for --abi-hash is always trivial, so the-- interface we request is local. Though, maybe we ought-- not to do it in this case either...)---- This mistake was bug #15594.letmod' =renameHoleModuledflags hmap mod ifisHoleModulemod thendoiface <-liftIO.initIfaceCheck (text"rnDepModule")hsc_env $loadSysInterface (text"rnDepModule")mod' return(mod' :sel (mi_depsiface ))elsereturn[mod' ]{- ************************************************************************ * * ModIface substitution * * ************************************************************************ -}-- | Run a computation in the 'ShIfM' monad.initRnIface::HscEnv->ModIface->[(ModuleName,Module)]->MaybeNameShape->ShIfM a ->IO(EitherErrorMessagesa )initRnIface hsc_env iface insts nsubst do_this =doerrs_var <-newIORefemptyBagletdflags =hsc_dflagshsc_env hsubst =listToUFMinsts rn_mod =renameHoleModuledflags hsubst env =ShIfEnv {sh_if_module=rn_mod (mi_moduleiface ),sh_if_semantic_module=rn_mod (mi_semantic_moduleiface ),sh_if_hole_subst=listToUFMinsts ,sh_if_shape=nsubst ,sh_if_errs=errs_var }-- Modeled off of 'initTc'res <-initTcRnIf 'c'hsc_env env ()$tryMdo_this msgs <-readIOReferrs_var caseres ofLeft_->return(Leftmsgs )Rightr |not(isEmptyBagmsgs )->return(Leftmsgs )|otherwise->return(Rightr )-- | Environment for 'ShIfM' monads.dataShIfEnv =ShIfEnv {-- What we are renaming the ModIface to. It assumed that-- the original mi_module of the ModIface is-- @generalizeModule (mi_module iface)@.sh_if_module ::Module,-- The semantic module that we are renaming tosh_if_semantic_module ::Module,-- Cached hole substitution, e.g.-- @sh_if_hole_subst == listToUFM . unitIdInsts . moduleUnitId . sh_if_module@sh_if_hole_subst ::ShHoleSubst,-- An optional name substitution to be applied when renaming-- the names in the interface. If this is 'Nothing', then-- we just load the target interface and look at the export-- list to determine the renaming.sh_if_shape ::MaybeNameShape,-- Mutable reference to keep track of errors (similar to 'tcl_errs')sh_if_errs ::IORefErrorMessages}getHoleSubst::ShIfM ShHoleSubstgetHoleSubst =fmapsh_if_hole_substgetGblEnv typeShIfM =TcRnIfShIfEnv ()typeRename a =a ->ShIfM a rnModule::Rename ModulernModule mod =dohmap <-getHoleSubst dflags <-getDynFlagsreturn(renameHoleModuledflags hmap mod )rnAvailInfo::Rename AvailInfornAvailInfo (Availn )=Avail<$>rnIfaceGlobal n rnAvailInfo(AvailTCn ns fs )=do-- Why don't we rnIfaceGlobal the availName itself? It may not-- actually be exported by the module it putatively is from, in-- which case we won't be able to tell what the name actually-- is. But for the availNames they MUST be exported, so they-- will rename fine.ns' <-mapMrnIfaceGlobal ns fs' <-mapMrnFieldLabel fs casens' ++mapflSelectorfs' of[]->panic"rnAvailInfoEmpty AvailInfo"(rep :rest )->ASSERT2(all((==nameModulerep).nameModule)rest,pprrep$$ hcat(mappprrest))don' <-setNameModule (Just(nameModulerep ))n return(AvailTCn' ns' fs' )rnFieldLabel::Rename FieldLabelrnFieldLabel (FieldLabell b sel )=dosel' <-rnIfaceGlobal sel return(FieldLabell b sel' )-- | The key function. This gets called on every Name embedded-- inside a ModIface. Our job is to take a Name from some-- generalized unit ID p[A=<A>, B=<B>], and change-- it to the correct name for a (partially) instantiated unit-- ID, e.g. p[A=q[]:A, B=<B>].---- There are two important things to do:---- If a hole is substituted with a real module implementation,-- we need to look at that actual implementation to determine what-- the true identity of this name should be. We'll do this by-- loading that module's interface and looking at the mi_exports.---- However, there is one special exception: when we are loading-- the interface of a requirement. In this case, we may not have-- the "implementing" interface, because we are reading this-- interface precisely to "merge it in".---- External case:-- p[A=<B>]:A (and thisUnitId is something else)-- We are loading this in order to determine B.hi! So-- don't load B.hi to find the exports.---- Local case:-- p[A=<A>]:A (and thisUnitId is p[A=<A>])-- This should not happen, because the rename is not necessary-- in this case, but if it does we shouldn't load A.hi!---- Compare me with 'tcIfaceGlobal'!-- In effect, this function needs compute the name substitution on the-- fly. What it has is the name that we would like to substitute.-- If the name is not a hole name {M.x} (e.g. isHoleModule) then-- no renaming can take place (although the inner hole structure must-- be updated to account for the hole module renaming.)rnIfaceGlobal::Name->ShIfM NamernIfaceGlobal n =dohsc_env <-getTopEnv letdflags =hsc_dflagshsc_env iface_semantic_mod <-fmapsh_if_semantic_modulegetGblEnv mb_nsubst <-fmapsh_if_shapegetGblEnv hmap <-getHoleSubst letm =nameModulen m' =renameHoleModuledflags hmap m case()of-- Did we encounter {A.T} while renaming p[A=<B>]:A? If so,-- do NOT assume B.hi is available.-- In this case, rename {A.T} to {B.T} but don't look up exports._|m' ==iface_semantic_mod ,isHoleModulem' -- NB: this could be Nothing for computeExports, we have-- nothing to say.->don' <-setNameModule (Justm' )n casemb_nsubst ofNothing->returnn' Justnsubst ->casemaybeSubstNameShape nsubst n' of-- TODO: would love to have context-- TODO: This will give an unpleasant message if n'-- is a constructor; then we'll suggest adding T-- but it won't work.Nothing->failWithRn $vcat[text"The identifier"<+>ppr(occNamen' )<+>text"does not exist in the local signature.",parens(text"Try adding it to the export list of the hsig file.")]Justn'' ->returnn'' -- Fastpath: we are renaming p[H=<H>]:A.T, in which case the-- export list is irrelevant.|not(isHoleModulem )->setNameModule (Justm' )n -- The substitution was from <A> to p[]:A.-- But this does not mean {A.T} goes to p[]:A.T:-- p[]:A may reexport T from somewhere else. Do the name-- substitution. Furthermore, we need-- to make sure we pick the accurate name NOW,-- or we might accidentally reject a merge.|otherwise->do-- Make sure we look up the local interface if substitution-- went from <A> to <B>.letm'' =ifisHoleModulem' -- Pull out the local guy!!thenmkModule(thisPackagedflags )(moduleNamem' )elsem' iface <-liftIO.initIfaceCheck (text"rnIfaceGlobal")hsc_env $loadSysInterface (text"rnIfaceGlobal")m'' letnsubst =mkNameShape (moduleNamem )(mi_exportsiface )casemaybeSubstNameShape nsubst n ofNothing->failWithRn $vcat[text"The identifier"<+>ppr(occNamen )<+>-- NB: report m' because it's more user-friendlytext"does not exist in the signature for"<+>pprm' ,parens(text"Try adding it to the export list in that hsig file.")]Justn' ->returnn' -- | Rename an implicit name, e.g., a DFun or coercion axiom.-- Here is where we ensure that DFuns have the correct module as described in-- Note [rnIfaceNeverExported].rnIfaceNeverExported::Name->ShIfM NamernIfaceNeverExported name =dohmap <-getHoleSubst dflags <-getDynFlagsiface_semantic_mod <-fmapsh_if_semantic_modulegetGblEnv letm =renameHoleModuledflags hmap $nameModulename -- Doublecheck that this DFun/coercion axiom was, indeed, locally defined.MASSERT2(iface_semantic_mod== m ,ppr iface_semantic_mod<+>pprm)setNameModule (Justm )name -- Note [rnIfaceNeverExported]-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~-- For the high-level overview, see-- Note [Handling never-exported TyThings under Backpack]---- When we see a reference to an entity that was defined in a signature,-- 'rnIfaceGlobal' relies on the identifier in question being part of the-- exports of the implementing 'ModIface', so that we can use the exports to-- decide how to rename the identifier. Unfortunately, references to 'DFun's-- and 'CoAxiom's will run into trouble under this strategy, because they are-- never exported.---- Let us consider first what should happen in the absence of promotion. In-- this setting, a reference to a 'DFun' or a 'CoAxiom' can only occur inside-- the signature *that is defining it* (as there are no Core terms in-- typechecked-only interface files, there's no way for a reference to occur-- besides from the defining 'ClsInst' or closed type family). Thus,-- it doesn't really matter what names we give the DFun/CoAxiom, as long-- as it's consistent between the declaration site and the use site.---- We have to make sure that these bogus names don't get propagated,-- but it is fine: see Note [Signature merging DFuns] for the fixups-- to the names we do before writing out the merged interface.-- (It's even easier for instantiation, since the DFuns all get-- dropped entirely; the instances are reexported implicitly.)---- Unfortunately, this strategy is not enough in the presence of promotion-- (see bug #13149), where modules which import the signature may make-- reference to their coercions. It's not altogether clear how to-- fix this case, but it is definitely a bug!-- PILES AND PILES OF BOILERPLATE-- | Rename an 'IfaceClsInst', with special handling for an associated-- dictionary function.rnIfaceClsInst::Rename IfaceClsInstrnIfaceClsInst cls_inst =don <-rnIfaceGlobal (ifInstClscls_inst )tys <-mapMrnMaybeIfaceTyCon (ifInstTyscls_inst )dfun <-rnIfaceNeverExported (ifDFuncls_inst )returncls_inst {ifInstCls=n ,ifInstTys=tys ,ifDFun=dfun }rnMaybeIfaceTyCon::Rename (MaybeIfaceTyCon)rnMaybeIfaceTyCon Nothing=returnNothingrnMaybeIfaceTyCon(Justtc )=Just<$>rnIfaceTyCon tc rnIfaceFamInst::Rename IfaceFamInstrnIfaceFamInst d =dofam <-rnIfaceGlobal (ifFamInstFamd )tys <-mapMrnMaybeIfaceTyCon (ifFamInstTysd )axiom <-rnIfaceGlobal (ifFamInstAxiomd )returnd {ifFamInstFam=fam ,ifFamInstTys=tys ,ifFamInstAxiom=axiom }rnIfaceDecl'::Rename (Fingerprint,IfaceDecl)rnIfaceDecl' (fp ,decl )=(,)fp <$>rnIfaceDecl decl rnIfaceDecl::Rename IfaceDeclrnIfaceDecl d @IfaceId{}=doname <-caseifIdDetailsd ofIfDFunId->rnIfaceNeverExported (ifNamed )_|isDefaultMethodOcc(occName(ifNamed ))->rnIfaceNeverExported (ifNamed )-- Typeable bindings. See Note [Grand plan for Typeable]._|isTypeableBindOcc(occName(ifNamed ))->rnIfaceNeverExported (ifNamed )|otherwise->rnIfaceGlobal (ifNamed )ty <-rnIfaceType (ifTyped )details <-rnIfaceIdDetails (ifIdDetailsd )info <-rnIfaceIdInfo (ifIdInfod )returnd {ifName=name ,ifType=ty ,ifIdDetails=details ,ifIdInfo=info }rnIfaceDecld @IfaceData{}=doname <-rnIfaceGlobal (ifNamed )binders <-mapMrnIfaceTyConBinder (ifBindersd )ctxt <-mapMrnIfaceType (ifCtxtd )cons <-rnIfaceConDecls (ifConsd )res_kind <-rnIfaceType (ifResKindd )parent <-rnIfaceTyConParent (ifParentd )returnd {ifName=name ,ifBinders=binders ,ifCtxt=ctxt ,ifCons=cons ,ifResKind=res_kind ,ifParent=parent }rnIfaceDecld @IfaceSynonym{}=doname <-rnIfaceGlobal (ifNamed )binders <-mapMrnIfaceTyConBinder (ifBindersd )syn_kind <-rnIfaceType (ifResKindd )syn_rhs <-rnIfaceType (ifSynRhsd )returnd {ifName=name ,ifBinders=binders ,ifResKind=syn_kind ,ifSynRhs=syn_rhs }rnIfaceDecld @IfaceFamily{}=doname <-rnIfaceGlobal (ifNamed )binders <-mapMrnIfaceTyConBinder (ifBindersd )fam_kind <-rnIfaceType (ifResKindd )fam_flav <-rnIfaceFamTyConFlav (ifFamFlavd )returnd {ifName=name ,ifBinders=binders ,ifResKind=fam_kind ,ifFamFlav=fam_flav }rnIfaceDecld @IfaceClass{}=doname <-rnIfaceGlobal (ifNamed )binders <-mapMrnIfaceTyConBinder (ifBindersd )body <-rnIfaceClassBody (ifBodyd )returnd {ifName=name ,ifBinders=binders ,ifBody=body }rnIfaceDecld @IfaceAxiom{}=doname <-rnIfaceNeverExported (ifNamed )tycon <-rnIfaceTyCon (ifTyCond )ax_branches <-mapMrnIfaceAxBranch (ifAxBranchesd )returnd {ifName=name ,ifTyCon=tycon ,ifAxBranches=ax_branches }rnIfaceDecld @IfacePatSyn{}=doname <-rnIfaceGlobal (ifNamed )letrnPat (n ,b )=(,)<$>rnIfaceGlobal n <*>pureb pat_matcher <-rnPat (ifPatMatcherd )pat_builder <-T.traversernPat (ifPatBuilderd )pat_univ_bndrs <-mapMrnIfaceForAllBndr (ifPatUnivBndrsd )pat_ex_bndrs <-mapMrnIfaceForAllBndr (ifPatExBndrsd )pat_prov_ctxt <-mapMrnIfaceType (ifPatProvCtxtd )pat_req_ctxt <-mapMrnIfaceType (ifPatReqCtxtd )pat_args <-mapMrnIfaceType (ifPatArgsd )pat_ty <-rnIfaceType (ifPatTyd )returnd {ifName=name ,ifPatMatcher=pat_matcher ,ifPatBuilder=pat_builder ,ifPatUnivBndrs=pat_univ_bndrs ,ifPatExBndrs=pat_ex_bndrs ,ifPatProvCtxt=pat_prov_ctxt ,ifPatReqCtxt=pat_req_ctxt ,ifPatArgs=pat_args ,ifPatTy=pat_ty }rnIfaceClassBody::Rename IfaceClassBodyrnIfaceClassBody IfAbstractClass=returnIfAbstractClassrnIfaceClassBodyd @IfConcreteClass{}=doctxt <-mapMrnIfaceType (ifClassCtxtd )ats <-mapMrnIfaceAT (ifATsd )sigs <-mapMrnIfaceClassOp (ifSigsd )returnd {ifClassCtxt=ctxt ,ifATs=ats ,ifSigs=sigs }rnIfaceFamTyConFlav::Rename IfaceFamTyConFlavrnIfaceFamTyConFlav (IfaceClosedSynFamilyTyCon(Just(n ,axs )))=IfaceClosedSynFamilyTyCon.Just<$>((,)<$>rnIfaceNeverExported n <*>mapMrnIfaceAxBranch axs )rnIfaceFamTyConFlavflav =pureflav rnIfaceAT::Rename IfaceATrnIfaceAT (IfaceATdecl mb_ty )=IfaceAT<$>rnIfaceDecl decl <*>T.traversernIfaceType mb_ty rnIfaceTyConParent::Rename IfaceTyConParentrnIfaceTyConParent (IfDataInstancen tc args )=IfDataInstance<$>rnIfaceGlobal n <*>rnIfaceTyCon tc <*>rnIfaceAppArgs args rnIfaceTyConParentIfNoParent=pureIfNoParentrnIfaceConDecls::Rename IfaceConDeclsrnIfaceConDecls (IfDataTyConds )=IfDataTyCon<$>mapMrnIfaceConDecl ds rnIfaceConDecls(IfNewTyCond )=IfNewTyCon<$>rnIfaceConDecl d rnIfaceConDeclsIfAbstractTyCon=pureIfAbstractTyConrnIfaceConDecl::Rename IfaceConDeclrnIfaceConDecl d =docon_name <-rnIfaceGlobal (ifConNamed )con_ex_tvs <-mapMrnIfaceBndr (ifConExTCvsd )con_user_tvbs <-mapMrnIfaceForAllBndr (ifConUserTvBindersd )letrnIfConEqSpec (n ,t )=(,)n <$>rnIfaceType t con_eq_spec <-mapMrnIfConEqSpec (ifConEqSpecd )con_ctxt <-mapMrnIfaceType (ifConCtxtd )con_arg_tys <-mapMrnIfaceType (ifConArgTysd )con_fields <-mapMrnFieldLabel (ifConFieldsd )letrnIfaceBang (IfUnpackCoco )=IfUnpackCo<$>rnIfaceCo co rnIfaceBangbang =purebang con_stricts <-mapMrnIfaceBang (ifConStrictsd )returnd {ifConName=con_name ,ifConExTCvs=con_ex_tvs ,ifConUserTvBinders=con_user_tvbs ,ifConEqSpec=con_eq_spec ,ifConCtxt=con_ctxt ,ifConArgTys=con_arg_tys ,ifConFields=con_fields ,ifConStricts=con_stricts }rnIfaceClassOp::Rename IfaceClassOprnIfaceClassOp (IfaceClassOpn ty dm )=IfaceClassOp<$>rnIfaceGlobal n <*>rnIfaceType ty <*>rnMaybeDefMethSpec dm rnMaybeDefMethSpec::Rename (Maybe(DefMethSpecIfaceType))rnMaybeDefMethSpec (Just(GenericDMty ))=Just.GenericDM<$>rnIfaceType ty rnMaybeDefMethSpecmb =returnmb rnIfaceAxBranch::Rename IfaceAxBranchrnIfaceAxBranch d =doty_vars <-mapMrnIfaceTvBndr (ifaxbTyVarsd )lhs <-rnIfaceAppArgs (ifaxbLHSd )rhs <-rnIfaceType (ifaxbRHSd )returnd {ifaxbTyVars=ty_vars ,ifaxbLHS=lhs ,ifaxbRHS=rhs }rnIfaceIdInfo::Rename IfaceIdInfornIfaceIdInfo NoInfo=pureNoInfornIfaceIdInfo(HasInfois )=HasInfo<$>mapMrnIfaceInfoItem is rnIfaceInfoItem::Rename IfaceInfoItemrnIfaceInfoItem (HsUnfoldlb if_unf )=HsUnfoldlb <$>rnIfaceUnfolding if_unf rnIfaceInfoItemi =purei rnIfaceUnfolding::Rename IfaceUnfoldingrnIfaceUnfolding (IfCoreUnfoldstable if_expr )=IfCoreUnfoldstable <$>rnIfaceExpr if_expr rnIfaceUnfolding(IfCompulsoryif_expr )=IfCompulsory<$>rnIfaceExpr if_expr rnIfaceUnfolding(IfInlineRulearity unsat_ok boring_ok if_expr )=IfInlineRulearity unsat_ok boring_ok <$>rnIfaceExpr if_expr rnIfaceUnfolding(IfDFunUnfoldbs ops )=IfDFunUnfold<$>rnIfaceBndrs bs <*>mapMrnIfaceExpr ops rnIfaceExpr::Rename IfaceExprrnIfaceExpr (IfaceLclname )=pure(IfaceLclname )rnIfaceExpr(IfaceExtgbl )=IfaceExt<$>rnIfaceGlobal gbl rnIfaceExpr(IfaceTypety )=IfaceType<$>rnIfaceType ty rnIfaceExpr(IfaceCoco )=IfaceCo<$>rnIfaceCo co rnIfaceExpr(IfaceTuplesort args )=IfaceTuplesort <$>rnIfaceExprs args rnIfaceExpr(IfaceLamlam_bndr expr )=IfaceLam<$>rnIfaceLamBndr lam_bndr <*>rnIfaceExpr expr rnIfaceExpr(IfaceAppfun arg )=IfaceApp<$>rnIfaceExpr fun <*>rnIfaceExpr arg rnIfaceExpr(IfaceCasescrut case_bndr alts )=IfaceCase<$>rnIfaceExpr scrut <*>purecase_bndr <*>mapMrnIfaceAlt alts rnIfaceExpr(IfaceECasescrut ty )=IfaceECase<$>rnIfaceExpr scrut <*>rnIfaceType ty rnIfaceExpr(IfaceLet(IfaceNonRecbndr rhs )body )=IfaceLet<$>(IfaceNonRec<$>rnIfaceLetBndr bndr <*>rnIfaceExpr rhs )<*>rnIfaceExpr body rnIfaceExpr(IfaceLet(IfaceRecpairs )body )=IfaceLet<$>(IfaceRec<$>mapM(\(bndr ,rhs )->(,)<$>rnIfaceLetBndr bndr <*>rnIfaceExpr rhs )pairs )<*>rnIfaceExpr body rnIfaceExpr(IfaceCastexpr co )=IfaceCast<$>rnIfaceExpr expr <*>rnIfaceCo co rnIfaceExpr(IfaceLitlit )=pure(IfaceLitlit )rnIfaceExpr(IfaceFCallcc ty )=IfaceFCallcc <$>rnIfaceType ty rnIfaceExpr(IfaceTicktickish expr )=IfaceTicktickish <$>rnIfaceExpr expr rnIfaceBndrs::Rename [IfaceBndr]rnIfaceBndrs =mapMrnIfaceBndr rnIfaceBndr::Rename IfaceBndrrnIfaceBndr (IfaceIdBndr(fs ,ty ))=IfaceIdBndr<$>((,)fs <$>rnIfaceType ty )rnIfaceBndr(IfaceTvBndrtv_bndr )=IfaceTvBndr<$>rnIfaceTvBndr tv_bndr rnIfaceTvBndr::Rename IfaceTvBndrrnIfaceTvBndr (fs ,kind )=(,)fs <$>rnIfaceType kind rnIfaceTyConBinder::Rename IfaceTyConBinderrnIfaceTyConBinder (Bndrtv vis )=Bndr<$>rnIfaceBndr tv <*>purevis rnIfaceAlt::Rename IfaceAltrnIfaceAlt (conalt ,names ,rhs )=(,,)<$>rnIfaceConAlt conalt <*>purenames <*>rnIfaceExpr rhs rnIfaceConAlt::Rename IfaceConAltrnIfaceConAlt (IfaceDataAltdata_occ )=IfaceDataAlt<$>rnIfaceGlobal data_occ rnIfaceConAltalt =purealt rnIfaceLetBndr::Rename IfaceLetBndrrnIfaceLetBndr (IfLetBndrfs ty info jpi )=IfLetBndrfs <$>rnIfaceType ty <*>rnIfaceIdInfo info <*>purejpi rnIfaceLamBndr::Rename IfaceLamBndrrnIfaceLamBndr (bndr ,oneshot )=(,)<$>rnIfaceBndr bndr <*>pureoneshot rnIfaceMCo::Rename IfaceMCoercionrnIfaceMCo IfaceMRefl=pureIfaceMReflrnIfaceMCo(IfaceMCoco )=IfaceMCo<$>rnIfaceCo co rnIfaceCo::Rename IfaceCoercionrnIfaceCo (IfaceReflCoty )=IfaceReflCo<$>rnIfaceType ty rnIfaceCo(IfaceGReflCorolety mco )=IfaceGReflCorole<$>rnIfaceType ty <*>rnIfaceMCo mco rnIfaceCo(IfaceFunCoroleco1 co2 )=IfaceFunCorole<$>rnIfaceCo co1 <*>rnIfaceCo co2 rnIfaceCo(IfaceTyConAppCoroletc cos )=IfaceTyConAppCorole<$>rnIfaceTyCon tc <*>mapMrnIfaceCo cos rnIfaceCo(IfaceAppCoco1 co2 )=IfaceAppCo<$>rnIfaceCo co1 <*>rnIfaceCo co2 rnIfaceCo(IfaceForAllCobndr co1 co2 )=IfaceForAllCo<$>rnIfaceBndr bndr <*>rnIfaceCo co1 <*>rnIfaceCo co2 rnIfaceCo(IfaceFreeCoVarc )=pure(IfaceFreeCoVarc )rnIfaceCo(IfaceCoVarColcl )=IfaceCoVarCo<$>purelcl rnIfaceCo(IfaceHoleColcl )=IfaceHoleCo<$>purelcl rnIfaceCo(IfaceAxiomInstCon i cs )=IfaceAxiomInstCo<$>rnIfaceGlobal n <*>purei <*>mapMrnIfaceCo cs rnIfaceCo(IfaceUnivCos r t1 t2 )=IfaceUnivCos r <$>rnIfaceType t1 <*>rnIfaceType t2 rnIfaceCo(IfaceSymCoc )=IfaceSymCo<$>rnIfaceCo c rnIfaceCo(IfaceTransCoc1 c2 )=IfaceTransCo<$>rnIfaceCo c1 <*>rnIfaceCo c2 rnIfaceCo(IfaceInstCoc1 c2 )=IfaceInstCo<$>rnIfaceCo c1 <*>rnIfaceCo c2 rnIfaceCo(IfaceNthCod c )=IfaceNthCod <$>rnIfaceCo c rnIfaceCo(IfaceLRColr c )=IfaceLRColr <$>rnIfaceCo c rnIfaceCo(IfaceSubCoc )=IfaceSubCo<$>rnIfaceCo c rnIfaceCo(IfaceAxiomRuleCoax cos )=IfaceAxiomRuleCoax <$>mapMrnIfaceCo cos rnIfaceCo(IfaceKindCoc )=IfaceKindCo<$>rnIfaceCo c rnIfaceTyCon::Rename IfaceTyConrnIfaceTyCon (IfaceTyConn info )=IfaceTyCon<$>rnIfaceGlobal n <*>pureinfo rnIfaceExprs::Rename [IfaceExpr]rnIfaceExprs =mapMrnIfaceExpr rnIfaceIdDetails::Rename IfaceIdDetailsrnIfaceIdDetails (IfRecSelId(Lefttc )b )=IfRecSelId<$>fmapLeft(rnIfaceTyCon tc )<*>pureb rnIfaceIdDetails(IfRecSelId(Rightdecl )b )=IfRecSelId<$>fmapRight(rnIfaceDecl decl )<*>pureb rnIfaceIdDetailsdetails =puredetails rnIfaceType::Rename IfaceTypernIfaceType (IfaceFreeTyVarn )=pure(IfaceFreeTyVarn )rnIfaceType(IfaceTyVarn )=pure(IfaceTyVarn )rnIfaceType(IfaceAppTyt1 t2 )=IfaceAppTy<$>rnIfaceType t1 <*>rnIfaceAppArgs t2 rnIfaceType(IfaceLitTyl )=return(IfaceLitTyl )rnIfaceType(IfaceFunTyaf t1 t2 )=IfaceFunTyaf <$>rnIfaceType t1 <*>rnIfaceType t2 rnIfaceType(IfaceTupleTys i tks )=IfaceTupleTys i <$>rnIfaceAppArgs tks rnIfaceType(IfaceTyConApptc tks )=IfaceTyConApp<$>rnIfaceTyCon tc <*>rnIfaceAppArgs tks rnIfaceType(IfaceForAllTytv t )=IfaceForAllTy<$>rnIfaceForAllBndr tv <*>rnIfaceType t rnIfaceType(IfaceCoercionTyco )=IfaceCoercionTy<$>rnIfaceCo co rnIfaceType(IfaceCastTyty co )=IfaceCastTy<$>rnIfaceType ty <*>rnIfaceCo co rnIfaceForAllBndr::Rename IfaceForAllBndrrnIfaceForAllBndr (Bndrtv vis )=Bndr<$>rnIfaceBndr tv <*>purevis rnIfaceAppArgs::Rename IfaceAppArgsrnIfaceAppArgs (IA_Argt a ts )=IA_Arg<$>rnIfaceType t <*>purea <*>rnIfaceAppArgs ts rnIfaceAppArgsIA_Nil=pureIA_Nil