{-# 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" importGhcPrelude importSrcLoc importOutputable importHscTypes importModule importUniqFM importAvail importIfaceSyn importFieldLabel importVar importErrUtils importName importTcRnMonad importUtil importFingerprint importBasicTypes -- a bit vexingimport{-# SOURCE#-}LoadIface importDynFlags importqualifiedData.TraversableasTimportBag importData.IORefimportNameShape importIfaceEnv tcRnMsgMaybe::IO(EitherErrorMessages a )->TcM a tcRnMsgMaybe do_this =dor <-liftIO$do_this caser ofLefterrs ->doaddMessages (emptyBag ,errs )failM Rightx ->returnx tcRnModIface::[(ModuleName ,Module )]->MaybeNameShape ->ModIface ->TcM ModIface tcRnModIface 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 <-getDynFlags errs <-readTcRef errs_var -- TODO: maybe associate this with a source location?writeTcRef errs_var (errs `snocBag `mkPlainErrMsg dflags noSrcSpan doc )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(EitherErrorMessages ModIface )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 Dependencies rnDependencies 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' =renameHoleModule dflags hmap mod ifisHoleModule mod 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(EitherErrorMessages a )initRnIface hsc_env iface insts nsubst do_this =doerrs_var <-newIORefemptyBag letdflags =hsc_dflagshsc_env hsubst =listToUFM insts rn_mod =renameHoleModule dflags hsubst env =ShIfEnv {sh_if_module=rn_mod (mi_moduleiface ),sh_if_semantic_module=rn_mod (mi_semantic_module iface ),sh_if_hole_subst=listToUFM insts ,sh_if_shape=nsubst ,sh_if_errs=errs_var }-- Modeled off of 'initTc'res <-initTcRnIf 'c'hsc_env env ()$tryM do_this msgs <-readIOReferrs_var caseres ofLeft_->return(Leftmsgs )Rightr |not(isEmptyBag msgs )->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 ShHoleSubst getHoleSubst =fmapsh_if_hole_substgetGblEnv typeShIfM =TcRnIf ShIfEnv ()typeRename a =a ->ShIfM a rnModule::Rename Module rnModule mod =dohmap <-getHoleSubst dflags <-getDynFlags return(renameHoleModule dflags hmap mod )rnAvailInfo::Rename AvailInfo rnAvailInfo (Avail n )=Avail <$>rnIfaceGlobal n rnAvailInfo(AvailTC n 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,ppr rep$$ hcat(mapppr rest ))don' <-setNameModule (Just(nameModule rep ))n return(AvailTC n' ns' fs' )rnFieldLabel::Rename FieldLabel rnFieldLabel (FieldLabel l b sel )=dosel' <-rnIfaceGlobal sel return(FieldLabel l 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 Name rnIfaceGlobal n =dohsc_env <-getTopEnv letdflags =hsc_dflagshsc_env iface_semantic_mod <-fmapsh_if_semantic_modulegetGblEnv mb_nsubst <-fmapsh_if_shapegetGblEnv hmap <-getHoleSubst letm =nameModule n m' =renameHoleModule dflags 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 ,isHoleModule m' -- 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 (occName n' )<+> 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(isHoleModule m )->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'' =ifisHoleModule m' -- Pull out the local guy!!thenmkModule (thisPackage dflags )(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 (occName n )<+> -- NB: report m' because it's more user-friendlytext "does not exist in the signature for"<+> ppr m' ,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 Name rnIfaceNeverExported name =dohmap <-getHoleSubst dflags <-getDynFlags iface_semantic_mod <-fmapsh_if_semantic_modulegetGblEnv letm =renameHoleModule dflags hmap $nameModule name -- Doublecheck that this DFun/coercion axiom was, indeed, locally defined.MASSERT2(iface_semantic_mod== m ,ppr iface_semantic_mod<+> ppr m )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 IfaceClsInst rnIfaceClsInst 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 IfaceFamInst rnIfaceFamInst 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 IfaceDecl rnIfaceDecl 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 IfaceClassBody rnIfaceClassBody IfAbstractClass =returnIfAbstractClass rnIfaceClassBodyd @IfConcreteClass {}=doctxt <-mapMrnIfaceType (ifClassCtxtd )ats <-mapMrnIfaceAT (ifATsd )sigs <-mapMrnIfaceClassOp (ifSigsd )returnd {ifClassCtxt=ctxt ,ifATs=ats ,ifSigs=sigs }rnIfaceFamTyConFlav::Rename IfaceFamTyConFlav rnIfaceFamTyConFlav (IfaceClosedSynFamilyTyCon (Just(n ,axs )))=IfaceClosedSynFamilyTyCon .Just<$>((,)<$>rnIfaceNeverExported n <*>mapMrnIfaceAxBranch axs )rnIfaceFamTyConFlavflav =pureflav rnIfaceAT::Rename IfaceAT rnIfaceAT (IfaceAT decl mb_ty )=IfaceAT <$>rnIfaceDecl decl <*>T.traversernIfaceType mb_ty rnIfaceTyConParent::Rename IfaceTyConParent rnIfaceTyConParent (IfDataInstance n tc args )=IfDataInstance <$>rnIfaceGlobal n <*>rnIfaceTyCon tc <*>rnIfaceAppArgs args rnIfaceTyConParentIfNoParent =pureIfNoParent rnIfaceConDecls::Rename IfaceConDecls rnIfaceConDecls (IfDataTyCon ds )=IfDataTyCon <$>mapMrnIfaceConDecl ds rnIfaceConDecls(IfNewTyCon d )=IfNewTyCon <$>rnIfaceConDecl d rnIfaceConDeclsIfAbstractTyCon =pureIfAbstractTyCon rnIfaceConDecl::Rename IfaceConDecl rnIfaceConDecl 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 (IfUnpackCo co )=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 IfaceClassOp rnIfaceClassOp (IfaceClassOp n ty dm )=IfaceClassOp <$>rnIfaceGlobal n <*>rnIfaceType ty <*>rnMaybeDefMethSpec dm rnMaybeDefMethSpec::Rename (Maybe(DefMethSpec IfaceType ))rnMaybeDefMethSpec (Just(GenericDM ty ))=Just.GenericDM <$>rnIfaceType ty rnMaybeDefMethSpecmb =returnmb rnIfaceAxBranch::Rename IfaceAxBranch rnIfaceAxBranch d =doty_vars <-mapMrnIfaceTvBndr (ifaxbTyVarsd )lhs <-rnIfaceAppArgs (ifaxbLHSd )rhs <-rnIfaceType (ifaxbRHSd )returnd {ifaxbTyVars=ty_vars ,ifaxbLHS=lhs ,ifaxbRHS=rhs }rnIfaceIdInfo::Rename IfaceIdInfo rnIfaceIdInfo NoInfo =pureNoInfo rnIfaceIdInfo(HasInfo is )=HasInfo <$>mapMrnIfaceInfoItem is rnIfaceInfoItem::Rename IfaceInfoItem rnIfaceInfoItem (HsUnfold lb if_unf )=HsUnfold lb <$>rnIfaceUnfolding if_unf rnIfaceInfoItemi =purei rnIfaceUnfolding::Rename IfaceUnfolding rnIfaceUnfolding (IfCoreUnfold stable if_expr )=IfCoreUnfold stable <$>rnIfaceExpr if_expr rnIfaceUnfolding(IfCompulsory if_expr )=IfCompulsory <$>rnIfaceExpr if_expr rnIfaceUnfolding(IfInlineRule arity unsat_ok boring_ok if_expr )=IfInlineRule arity unsat_ok boring_ok <$>rnIfaceExpr if_expr rnIfaceUnfolding(IfDFunUnfold bs ops )=IfDFunUnfold <$>rnIfaceBndrs bs <*>mapMrnIfaceExpr ops rnIfaceExpr::Rename IfaceExpr rnIfaceExpr (IfaceLcl name )=pure(IfaceLcl name )rnIfaceExpr(IfaceExt gbl )=IfaceExt <$>rnIfaceGlobal gbl rnIfaceExpr(IfaceType ty )=IfaceType <$>rnIfaceType ty rnIfaceExpr(IfaceCo co )=IfaceCo <$>rnIfaceCo co rnIfaceExpr(IfaceTuple sort args )=IfaceTuple sort <$>rnIfaceExprs args rnIfaceExpr(IfaceLam lam_bndr expr )=IfaceLam <$>rnIfaceLamBndr lam_bndr <*>rnIfaceExpr expr rnIfaceExpr(IfaceApp fun arg )=IfaceApp <$>rnIfaceExpr fun <*>rnIfaceExpr arg rnIfaceExpr(IfaceCase scrut case_bndr alts )=IfaceCase <$>rnIfaceExpr scrut <*>purecase_bndr <*>mapMrnIfaceAlt alts rnIfaceExpr(IfaceECase scrut ty )=IfaceECase <$>rnIfaceExpr scrut <*>rnIfaceType ty rnIfaceExpr(IfaceLet (IfaceNonRec bndr rhs )body )=IfaceLet <$>(IfaceNonRec <$>rnIfaceLetBndr bndr <*>rnIfaceExpr rhs )<*>rnIfaceExpr body rnIfaceExpr(IfaceLet (IfaceRec pairs )body )=IfaceLet <$>(IfaceRec <$>mapM(\(bndr ,rhs )->(,)<$>rnIfaceLetBndr bndr <*>rnIfaceExpr rhs )pairs )<*>rnIfaceExpr body rnIfaceExpr(IfaceCast expr co )=IfaceCast <$>rnIfaceExpr expr <*>rnIfaceCo co rnIfaceExpr(IfaceLit lit )=pure(IfaceLit lit )rnIfaceExpr(IfaceFCall cc ty )=IfaceFCall cc <$>rnIfaceType ty rnIfaceExpr(IfaceTick tickish expr )=IfaceTick tickish <$>rnIfaceExpr expr rnIfaceBndrs::Rename [IfaceBndr ]rnIfaceBndrs =mapMrnIfaceBndr rnIfaceBndr::Rename IfaceBndr rnIfaceBndr (IfaceIdBndr (fs ,ty ))=IfaceIdBndr <$>((,)fs <$>rnIfaceType ty )rnIfaceBndr(IfaceTvBndr tv_bndr )=IfaceTvBndr <$>rnIfaceTvBndr tv_bndr rnIfaceTvBndr::Rename IfaceTvBndr rnIfaceTvBndr (fs ,kind )=(,)fs <$>rnIfaceType kind rnIfaceTyConBinder::Rename IfaceTyConBinder rnIfaceTyConBinder (Bndr tv vis )=Bndr <$>rnIfaceBndr tv <*>purevis rnIfaceAlt::Rename IfaceAlt rnIfaceAlt (conalt ,names ,rhs )=(,,)<$>rnIfaceConAlt conalt <*>purenames <*>rnIfaceExpr rhs rnIfaceConAlt::Rename IfaceConAlt rnIfaceConAlt (IfaceDataAlt data_occ )=IfaceDataAlt <$>rnIfaceGlobal data_occ rnIfaceConAltalt =purealt rnIfaceLetBndr::Rename IfaceLetBndr rnIfaceLetBndr (IfLetBndr fs ty info jpi )=IfLetBndr fs <$>rnIfaceType ty <*>rnIfaceIdInfo info <*>purejpi rnIfaceLamBndr::Rename IfaceLamBndr rnIfaceLamBndr (bndr ,oneshot )=(,)<$>rnIfaceBndr bndr <*>pureoneshot rnIfaceMCo::Rename IfaceMCoercion rnIfaceMCo IfaceMRefl =pureIfaceMRefl rnIfaceMCo(IfaceMCo co )=IfaceMCo <$>rnIfaceCo co rnIfaceCo::Rename IfaceCoercion rnIfaceCo (IfaceReflCo ty )=IfaceReflCo <$>rnIfaceType ty rnIfaceCo(IfaceGReflCo rolety mco )=IfaceGReflCo role<$>rnIfaceType ty <*>rnIfaceMCo mco rnIfaceCo(IfaceFunCo roleco1 co2 )=IfaceFunCo role<$>rnIfaceCo co1 <*>rnIfaceCo co2 rnIfaceCo(IfaceTyConAppCo roletc cos )=IfaceTyConAppCo role<$>rnIfaceTyCon tc <*>mapMrnIfaceCo cos rnIfaceCo(IfaceAppCo co1 co2 )=IfaceAppCo <$>rnIfaceCo co1 <*>rnIfaceCo co2 rnIfaceCo(IfaceForAllCo bndr co1 co2 )=IfaceForAllCo <$>rnIfaceBndr bndr <*>rnIfaceCo co1 <*>rnIfaceCo co2 rnIfaceCo(IfaceFreeCoVar c )=pure(IfaceFreeCoVar c )rnIfaceCo(IfaceCoVarCo lcl )=IfaceCoVarCo <$>purelcl rnIfaceCo(IfaceHoleCo lcl )=IfaceHoleCo <$>purelcl rnIfaceCo(IfaceAxiomInstCo n i cs )=IfaceAxiomInstCo <$>rnIfaceGlobal n <*>purei <*>mapMrnIfaceCo cs rnIfaceCo(IfaceUnivCo s r t1 t2 )=IfaceUnivCo s r <$>rnIfaceType t1 <*>rnIfaceType t2 rnIfaceCo(IfaceSymCo c )=IfaceSymCo <$>rnIfaceCo c rnIfaceCo(IfaceTransCo c1 c2 )=IfaceTransCo <$>rnIfaceCo c1 <*>rnIfaceCo c2 rnIfaceCo(IfaceInstCo c1 c2 )=IfaceInstCo <$>rnIfaceCo c1 <*>rnIfaceCo c2 rnIfaceCo(IfaceNthCo d c )=IfaceNthCo d <$>rnIfaceCo c rnIfaceCo(IfaceLRCo lr c )=IfaceLRCo lr <$>rnIfaceCo c rnIfaceCo(IfaceSubCo c )=IfaceSubCo <$>rnIfaceCo c rnIfaceCo(IfaceAxiomRuleCo ax cos )=IfaceAxiomRuleCo ax <$>mapMrnIfaceCo cos rnIfaceCo(IfaceKindCo c )=IfaceKindCo <$>rnIfaceCo c rnIfaceTyCon::Rename IfaceTyCon rnIfaceTyCon (IfaceTyCon n info )=IfaceTyCon <$>rnIfaceGlobal n <*>pureinfo rnIfaceExprs::Rename [IfaceExpr ]rnIfaceExprs =mapMrnIfaceExpr rnIfaceIdDetails::Rename IfaceIdDetails rnIfaceIdDetails (IfRecSelId (Lefttc )b )=IfRecSelId <$>fmapLeft(rnIfaceTyCon tc )<*>pureb rnIfaceIdDetails(IfRecSelId (Rightdecl )b )=IfRecSelId <$>fmapRight(rnIfaceDecl decl )<*>pureb rnIfaceIdDetailsdetails =puredetails rnIfaceType::Rename IfaceType rnIfaceType (IfaceFreeTyVar n )=pure(IfaceFreeTyVar n )rnIfaceType(IfaceTyVar n )=pure(IfaceTyVar n )rnIfaceType(IfaceAppTy t1 t2 )=IfaceAppTy <$>rnIfaceType t1 <*>rnIfaceAppArgs t2 rnIfaceType(IfaceLitTy l )=return(IfaceLitTy l )rnIfaceType(IfaceFunTy t1 t2 )=IfaceFunTy <$>rnIfaceType t1 <*>rnIfaceType t2 rnIfaceType(IfaceDFunTy t1 t2 )=IfaceDFunTy <$>rnIfaceType t1 <*>rnIfaceType t2 rnIfaceType(IfaceTupleTy s i tks )=IfaceTupleTy s i <$>rnIfaceAppArgs tks rnIfaceType(IfaceTyConApp tc tks )=IfaceTyConApp <$>rnIfaceTyCon tc <*>rnIfaceAppArgs tks rnIfaceType(IfaceForAllTy tv t )=IfaceForAllTy <$>rnIfaceForAllBndr tv <*>rnIfaceType t rnIfaceType(IfaceCoercionTy co )=IfaceCoercionTy <$>rnIfaceCo co rnIfaceType(IfaceCastTy ty co )=IfaceCastTy <$>rnIfaceType ty <*>rnIfaceCo co rnIfaceForAllBndr::Rename IfaceForAllBndr rnIfaceForAllBndr (Bndr tv vis )=Bndr <$>rnIfaceBndr tv <*>purevis rnIfaceAppArgs::Rename IfaceAppArgs rnIfaceAppArgs (IA_Arg t a ts )=IA_Arg <$>rnIfaceType t <*>purea <*>rnIfaceAppArgs ts rnIfaceAppArgsIA_Nil =pureIA_Nil