Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 70ec89744a04da80369b4702b2c37256 > files > 711

ghc-doc-6.10.4-1mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--Rendered using the Haskell Html Library v0.2-->
<HTML
><HEAD
><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"
><TITLE
>CoreSubst</TITLE
><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"
><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"
></SCRIPT
><SCRIPT TYPE="text/javascript"
>window.onload = function () {setSynopsis("mini_CoreSubst.html")};</SCRIPT
></HEAD
><BODY
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="topbar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "
></TD
><TD CLASS="title"
>ghc-6.10.4: The GHC API</TD
><TD CLASS="topbut"
><A HREF="index.html"
>Contents</A
></TD
><TD CLASS="topbut"
><A HREF="doc-index.html"
>Index</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="modulebar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><FONT SIZE="6"
>CoreSubst</FONT
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="section4"
><B
>Contents</B
></TD
></TR
><TR
><TD
><DL
><DT
><A HREF="#1"
>Main data types
</A
></DT
><DD
><DL
><DT
><A HREF="#2"
>Substituting into expressions and related types
</A
></DT
><DT
><A HREF="#3"
>Operations on substitutions
</A
></DT
><DT
><A HREF="#4"
>Substituting and cloning binders
</A
></DT
></DL
></DD
></DL
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Synopsis</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>data</SPAN
>  <A HREF="#t%3ASubst"
>Subst</A
> </TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>type</SPAN
> <A HREF="#t%3ATvSubstEnv"
>TvSubstEnv</A
> = <A HREF="VarEnv.html#t%3ATyVarEnv"
>TyVarEnv</A
> <A HREF="Type.html#t%3AType"
>Type</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>type</SPAN
> <A HREF="#t%3AIdSubstEnv"
>IdSubstEnv</A
> = <A HREF="VarEnv.html#t%3AIdEnv"
>IdEnv</A
> <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>data</SPAN
>  <A HREF="#t%3AInScopeSet"
>InScopeSet</A
> </TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AdeShadowBinds"
>deShadowBinds</A
> :: [<A HREF="CoreSyn.html#t%3ACoreBind"
>CoreBind</A
>] -&gt; [<A HREF="CoreSyn.html#t%3ACoreBind"
>CoreBind</A
>]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AsubstTy"
>substTy</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Type.html#t%3AType"
>Type</A
> -&gt; <A HREF="Type.html#t%3AType"
>Type</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AsubstExpr"
>substExpr</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
> -&gt; <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AsubstSpec"
>substSpec</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AId"
>Id</A
> -&gt; <A HREF="IdInfo.html#t%3ASpecInfo"
>SpecInfo</A
> -&gt; <A HREF="IdInfo.html#t%3ASpecInfo"
>SpecInfo</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AsubstWorker"
>substWorker</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="IdInfo.html#t%3AWorkerInfo"
>WorkerInfo</A
> -&gt; <A HREF="IdInfo.html#t%3AWorkerInfo"
>WorkerInfo</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AlookupIdSubst"
>lookupIdSubst</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AId"
>Id</A
> -&gt; <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AlookupTvSubst"
>lookupTvSubst</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3ATyVar"
>TyVar</A
> -&gt; <A HREF="Type.html#t%3AType"
>Type</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AemptySubst"
>emptySubst</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AmkEmptySubst"
>mkEmptySubst</A
> :: <A HREF="CoreSubst.html#t%3AInScopeSet"
>InScopeSet</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AmkSubst"
>mkSubst</A
> :: <A HREF="CoreSubst.html#t%3AInScopeSet"
>InScopeSet</A
> -&gt; <A HREF="CoreSubst.html#t%3ATvSubstEnv"
>TvSubstEnv</A
> -&gt; <A HREF="CoreSubst.html#t%3AIdSubstEnv"
>IdSubstEnv</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AsubstInScope"
>substInScope</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="CoreSubst.html#t%3AInScopeSet"
>InScopeSet</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AisEmptySubst"
>isEmptySubst</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool"
>Bool</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AextendIdSubst"
>extendIdSubst</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AId"
>Id</A
> -&gt; <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AextendIdSubstList"
>extendIdSubstList</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [(<A HREF="Var.html#t%3AId"
>Id</A
>, <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
>)] -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AextendTvSubst"
>extendTvSubst</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3ATyVar"
>TyVar</A
> -&gt; <A HREF="Type.html#t%3AType"
>Type</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AextendTvSubstList"
>extendTvSubstList</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [(<A HREF="Var.html#t%3ATyVar"
>TyVar</A
>, <A HREF="Type.html#t%3AType"
>Type</A
>)] -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AextendSubst"
>extendSubst</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AVar"
>Var</A
> -&gt; <A HREF="CoreSyn.html#t%3ACoreArg"
>CoreArg</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AextendSubstList"
>extendSubstList</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [(<A HREF="Var.html#t%3AVar"
>Var</A
>, <A HREF="CoreSyn.html#t%3ACoreArg"
>CoreArg</A
>)] -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AzapSubstEnv"
>zapSubstEnv</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AextendInScope"
>extendInScope</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AVar"
>Var</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AextendInScopeList"
>extendInScopeList</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [<A HREF="Var.html#t%3AVar"
>Var</A
>] -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AextendInScopeIds"
>extendInScopeIds</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [<A HREF="Var.html#t%3AId"
>Id</A
>] -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AisInScope"
>isInScope</A
> :: <A HREF="Var.html#t%3AVar"
>Var</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool"
>Bool</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AsubstBndr"
>substBndr</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AVar"
>Var</A
> -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, <A HREF="Var.html#t%3AVar"
>Var</A
>)</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AsubstBndrs"
>substBndrs</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [<A HREF="Var.html#t%3AVar"
>Var</A
>] -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, [<A HREF="Var.html#t%3AVar"
>Var</A
>])</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AsubstRecBndrs"
>substRecBndrs</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [<A HREF="Var.html#t%3AId"
>Id</A
>] -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, [<A HREF="Var.html#t%3AId"
>Id</A
>])</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AcloneIdBndr"
>cloneIdBndr</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="UniqSupply.html#t%3AUniqSupply"
>UniqSupply</A
> -&gt; <A HREF="Var.html#t%3AId"
>Id</A
> -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, <A HREF="Var.html#t%3AId"
>Id</A
>)</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AcloneIdBndrs"
>cloneIdBndrs</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="UniqSupply.html#t%3AUniqSupply"
>UniqSupply</A
> -&gt; [<A HREF="Var.html#t%3AId"
>Id</A
>] -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, [<A HREF="Var.html#t%3AId"
>Id</A
>])</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AcloneRecIdBndrs"
>cloneRecIdBndrs</A
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="UniqSupply.html#t%3AUniqSupply"
>UniqSupply</A
> -&gt; [<A HREF="Var.html#t%3AId"
>Id</A
>] -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, [<A HREF="Var.html#t%3AId"
>Id</A
>])</TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="1"
><A NAME="1"
>Main data types
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>data</SPAN
>  <A NAME="t:Subst"
><A NAME="t%3ASubst"
></A
></A
><B
>Subst</B
>  </TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="ndoc"
><P
>A substitution environment, containing both <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
> and <TT
><A HREF="Var.html#t%3ATyVar"
>TyVar</A
></TT
> substitutions.
</P
><P
>Some invariants apply to how you use the substitution:
</P
><P
>1. <A NAME="in_scope_invariant"
><A NAME="in_scope_invariant"
></A
></A
> The in-scope set contains at least those <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
>s and <TT
><A HREF="Var.html#t%3ATyVar"
>TyVar</A
></TT
>s that will be in scope <EM
>after</EM
>
 applying the substitution to a term. Precisely, the in-scope set must be a superset of the free vars of the
 substitution range that might possibly clash with locally-bound variables in the thing being substituted in.
</P
><P
>2. <A NAME="apply_once"
><A NAME="apply_once"
></A
></A
> You may apply the substitution only <EM
>once</EM
>
</P
><P
>There are various ways of setting up the in-scope set such that the first of these invariants hold:
</P
><UL
><LI
> Arrange that the in-scope set really is all the things in scope
</LI
><LI
> Arrange that it's the free vars of the range of the substitution
</LI
><LI
> Make it empty, if you know that all the free vars of the substitution are fresh, and hence can't possibly clash
</LI
></UL
></TD
></TR
><TR
><TD CLASS="section4"
><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Subst')" ALT="show/hide"
> Instances</TD
></TR
><TR
><TD CLASS="body"
><DIV ID="i:Subst" STYLE="display:block;"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="Outputable.html#t%3AOutputable"
>Outputable</A
> <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>type</SPAN
> <A NAME="t:TvSubstEnv"
><A NAME="t%3ATvSubstEnv"
></A
></A
><B
>TvSubstEnv</B
> = <A HREF="VarEnv.html#t%3ATyVarEnv"
>TyVarEnv</A
> <A HREF="Type.html#t%3AType"
>Type</A
></TD
></TR
><TR
><TD CLASS="doc"
>A substitition of <TT
><A HREF="Type.html#t%3AType"
>Type</A
></TT
>s for <TT
><A HREF="Var.html#t%3ATyVar"
>TyVar</A
></TT
>s
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>type</SPAN
> <A NAME="t:IdSubstEnv"
><A NAME="t%3AIdSubstEnv"
></A
></A
><B
>IdSubstEnv</B
> = <A HREF="VarEnv.html#t%3AIdEnv"
>IdEnv</A
> <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
></TD
></TR
><TR
><TD CLASS="doc"
>An environment for substituting for <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
>s
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>data</SPAN
>  <A NAME="t:InScopeSet"
><A NAME="t%3AInScopeSet"
></A
></A
><B
>InScopeSet</B
>  </TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="ndoc"
>A set of variables that are in scope at some point
</TD
></TR
><TR
><TD CLASS="section4"
><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:InScopeSet')" ALT="show/hide"
> Instances</TD
></TR
><TR
><TD CLASS="body"
><DIV ID="i:InScopeSet" STYLE="display:block;"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="Outputable.html#t%3AOutputable"
>Outputable</A
> <A HREF="CoreSubst.html#t%3AInScopeSet"
>InScopeSet</A
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section2"
><A NAME="2"
><A NAME="2"
>Substituting into expressions and related types
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:deShadowBinds"
><A NAME="v%3AdeShadowBinds"
></A
></A
><B
>deShadowBinds</B
> :: [<A HREF="CoreSyn.html#t%3ACoreBind"
>CoreBind</A
>] -&gt; [<A HREF="CoreSyn.html#t%3ACoreBind"
>CoreBind</A
>]</TD
></TR
><TR
><TD CLASS="doc"
><P
>De-shadowing the program is sometimes a useful pre-pass. It can be done simply
 by running over the bindings with an empty substitution, becuase substitution
 returns a result that has no-shadowing guaranteed.
</P
><P
>(Actually, within a single <EM
>type</EM
> there might still be shadowing, because 
 <TT
><A HREF="CoreSubst.html#v%3AsubstTy"
>substTy</A
></TT
> is a no-op for the empty substitution, but that's probably OK.)
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:substTy"
><A NAME="v%3AsubstTy"
></A
></A
><B
>substTy</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Type.html#t%3AType"
>Type</A
> -&gt; <A HREF="Type.html#t%3AType"
>Type</A
></TD
></TR
><TR
><TD CLASS="doc"
>See <TT
><A HREF="Type.html#v%3AsubstTy"
>substTy</A
></TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:substExpr"
><A NAME="v%3AsubstExpr"
></A
></A
><B
>substExpr</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
> -&gt; <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
></TD
></TR
><TR
><TD CLASS="doc"
><P
>Apply a substititon to an entire <TT
><A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
></TT
>. Rememeber, you may only 
 apply the substitution <EM
>once</EM
>: see <A HREF="CoreSubst.html#apply_once"
>CoreSubst</A
>
</P
><P
>Do *not* attempt to short-cut in the case of an empty substitution!
 See Note [Extending the Subst]
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:substSpec"
><A NAME="v%3AsubstSpec"
></A
></A
><B
>substSpec</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AId"
>Id</A
> -&gt; <A HREF="IdInfo.html#t%3ASpecInfo"
>SpecInfo</A
> -&gt; <A HREF="IdInfo.html#t%3ASpecInfo"
>SpecInfo</A
></TD
></TR
><TR
><TD CLASS="doc"
>Substitutes for the <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
>s within the <TT
><A HREF="IdInfo.html#t%3AWorkerInfo"
>WorkerInfo</A
></TT
> given the new function <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:substWorker"
><A NAME="v%3AsubstWorker"
></A
></A
><B
>substWorker</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="IdInfo.html#t%3AWorkerInfo"
>WorkerInfo</A
> -&gt; <A HREF="IdInfo.html#t%3AWorkerInfo"
>WorkerInfo</A
></TD
></TR
><TR
><TD CLASS="doc"
>Substitutes for the <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
>s within the <TT
><A HREF="IdInfo.html#t%3AWorkerInfo"
>WorkerInfo</A
></TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:lookupIdSubst"
><A NAME="v%3AlookupIdSubst"
></A
></A
><B
>lookupIdSubst</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AId"
>Id</A
> -&gt; <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
></TD
></TR
><TR
><TD CLASS="doc"
>Find the substitution for an <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
> in the <TT
><A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:lookupTvSubst"
><A NAME="v%3AlookupTvSubst"
></A
></A
><B
>lookupTvSubst</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3ATyVar"
>TyVar</A
> -&gt; <A HREF="Type.html#t%3AType"
>Type</A
></TD
></TR
><TR
><TD CLASS="doc"
>Find the substitution for a <TT
><A HREF="Var.html#t%3ATyVar"
>TyVar</A
></TT
> in the <TT
><A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section2"
><A NAME="3"
><A NAME="3"
>Operations on substitutions
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:emptySubst"
><A NAME="v%3AemptySubst"
></A
></A
><B
>emptySubst</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:mkEmptySubst"
><A NAME="v%3AmkEmptySubst"
></A
></A
><B
>mkEmptySubst</B
> :: <A HREF="CoreSubst.html#t%3AInScopeSet"
>InScopeSet</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:mkSubst"
><A NAME="v%3AmkSubst"
></A
></A
><B
>mkSubst</B
> :: <A HREF="CoreSubst.html#t%3AInScopeSet"
>InScopeSet</A
> -&gt; <A HREF="CoreSubst.html#t%3ATvSubstEnv"
>TvSubstEnv</A
> -&gt; <A HREF="CoreSubst.html#t%3AIdSubstEnv"
>IdSubstEnv</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:substInScope"
><A NAME="v%3AsubstInScope"
></A
></A
><B
>substInScope</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="CoreSubst.html#t%3AInScopeSet"
>InScopeSet</A
></TD
></TR
><TR
><TD CLASS="doc"
>Find the in-scope set: see <A HREF="CoreSubst.html#in_scope_invariant"
>CoreSubst</A
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:isEmptySubst"
><A NAME="v%3AisEmptySubst"
></A
></A
><B
>isEmptySubst</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool"
>Bool</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:extendIdSubst"
><A NAME="v%3AextendIdSubst"
></A
></A
><B
>extendIdSubst</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AId"
>Id</A
> -&gt; <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="doc"
>Add a substitution for an <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
> to the <TT
><A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TT
>: you must ensure that the in-scope set is
 such that the <A HREF="CoreSubst.html#in_scope_invariant"
>CoreSubst</A
> is true after extending the substitution like this
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:extendIdSubstList"
><A NAME="v%3AextendIdSubstList"
></A
></A
><B
>extendIdSubstList</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [(<A HREF="Var.html#t%3AId"
>Id</A
>, <A HREF="CoreSyn.html#t%3ACoreExpr"
>CoreExpr</A
>)] -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="doc"
>Adds multiple <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
> substitutions to the <TT
><A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TT
>: see also <TT
><A HREF="CoreSubst.html#v%3AextendIdSubst"
>extendIdSubst</A
></TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:extendTvSubst"
><A NAME="v%3AextendTvSubst"
></A
></A
><B
>extendTvSubst</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3ATyVar"
>TyVar</A
> -&gt; <A HREF="Type.html#t%3AType"
>Type</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="doc"
>Add a substitution for a <TT
><A HREF="Var.html#t%3ATyVar"
>TyVar</A
></TT
> to the <TT
><A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TT
>: you must ensure that the in-scope set is
 such that the <A HREF="CoreSubst.html#in_scope_invariant"
>CoreSubst</A
> is true after extending the substitution like this
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:extendTvSubstList"
><A NAME="v%3AextendTvSubstList"
></A
></A
><B
>extendTvSubstList</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [(<A HREF="Var.html#t%3ATyVar"
>TyVar</A
>, <A HREF="Type.html#t%3AType"
>Type</A
>)] -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="doc"
>Adds multiple <TT
><A HREF="Var.html#t%3ATyVar"
>TyVar</A
></TT
> substitutions to the <TT
><A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TT
>: see also <TT
><A HREF="CoreSubst.html#v%3AextendTvSubst"
>extendTvSubst</A
></TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:extendSubst"
><A NAME="v%3AextendSubst"
></A
></A
><B
>extendSubst</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AVar"
>Var</A
> -&gt; <A HREF="CoreSyn.html#t%3ACoreArg"
>CoreArg</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="doc"
>Add a substitution for a <TT
><A HREF="Var.html#t%3ATyVar"
>TyVar</A
></TT
> or <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
> as appropriate to the <TT
><A HREF="Var.html#t%3AVar"
>Var</A
></TT
> being added. See also
 <TT
><A HREF="CoreSubst.html#v%3AextendIdSubst"
>extendIdSubst</A
></TT
> and <TT
><A HREF="CoreSubst.html#v%3AextendTvSubst"
>extendTvSubst</A
></TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:extendSubstList"
><A NAME="v%3AextendSubstList"
></A
></A
><B
>extendSubstList</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [(<A HREF="Var.html#t%3AVar"
>Var</A
>, <A HREF="CoreSyn.html#t%3ACoreArg"
>CoreArg</A
>)] -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="doc"
>Add a substitution for a <TT
><A HREF="Var.html#t%3ATyVar"
>TyVar</A
></TT
> or <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
> as appropriate to all the <TT
><A HREF="Var.html#t%3AVar"
>Var</A
></TT
>s being added. See also <TT
><A HREF="CoreSubst.html#v%3AextendSubst"
>extendSubst</A
></TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:zapSubstEnv"
><A NAME="v%3AzapSubstEnv"
></A
></A
><B
>zapSubstEnv</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="doc"
>Remove all substitutions for <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
>s and <TT
><A HREF="Var.html#t%3AVar"
>Var</A
></TT
>s that might have been built up
 while preserving the in-scope set
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:extendInScope"
><A NAME="v%3AextendInScope"
></A
></A
><B
>extendInScope</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AVar"
>Var</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="doc"
>Add the <TT
><A HREF="Var.html#t%3AVar"
>Var</A
></TT
> to the in-scope set: as a side effect, removes any existing substitutions for it
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:extendInScopeList"
><A NAME="v%3AextendInScopeList"
></A
></A
><B
>extendInScopeList</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [<A HREF="Var.html#t%3AVar"
>Var</A
>] -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="doc"
>Add the <TT
><A HREF="Var.html#t%3AVar"
>Var</A
></TT
>s to the in-scope set: see also <TT
><A HREF="CoreSubst.html#v%3AextendInScope"
>extendInScope</A
></TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:extendInScopeIds"
><A NAME="v%3AextendInScopeIds"
></A
></A
><B
>extendInScopeIds</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [<A HREF="Var.html#t%3AId"
>Id</A
>] -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TD
></TR
><TR
><TD CLASS="doc"
>Optimized version of <TT
><A HREF="CoreSubst.html#v%3AextendInScopeList"
>extendInScopeList</A
></TT
> that can be used if you are certain 
 all the things being added are <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
>s and hence none are <TT
><A HREF="Var.html#t%3ATyVar"
>TyVar</A
></TT
>s
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:isInScope"
><A NAME="v%3AisInScope"
></A
></A
><B
>isInScope</B
> :: <A HREF="Var.html#t%3AVar"
>Var</A
> -&gt; <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool"
>Bool</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section2"
><A NAME="4"
><A NAME="4"
>Substituting and cloning binders
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:substBndr"
><A NAME="v%3AsubstBndr"
></A
></A
><B
>substBndr</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="Var.html#t%3AVar"
>Var</A
> -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, <A HREF="Var.html#t%3AVar"
>Var</A
>)</TD
></TR
><TR
><TD CLASS="doc"
>Substitutes a <TT
><A HREF="Var.html#t%3AVar"
>Var</A
></TT
> for another one according to the <TT
><A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TT
> given, returning
 the result and an updated <TT
><A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TT
> that should be used by subsequent substitutons.
 <TT
><A HREF="IdInfo.html#t%3AIdInfo"
>IdInfo</A
></TT
> is preserved by this process, although it is substituted into appropriately.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:substBndrs"
><A NAME="v%3AsubstBndrs"
></A
></A
><B
>substBndrs</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [<A HREF="Var.html#t%3AVar"
>Var</A
>] -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, [<A HREF="Var.html#t%3AVar"
>Var</A
>])</TD
></TR
><TR
><TD CLASS="doc"
>Applies <TT
><A HREF="CoreSubst.html#v%3AsubstBndr"
>substBndr</A
></TT
> to a number of <TT
><A HREF="Var.html#t%3AVar"
>Var</A
></TT
>s, accumulating a new <TT
><A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
></TT
> left-to-right
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:substRecBndrs"
><A NAME="v%3AsubstRecBndrs"
></A
></A
><B
>substRecBndrs</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; [<A HREF="Var.html#t%3AId"
>Id</A
>] -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, [<A HREF="Var.html#t%3AId"
>Id</A
>])</TD
></TR
><TR
><TD CLASS="doc"
>Substitute in a mutually recursive group of <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
>s
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:cloneIdBndr"
><A NAME="v%3AcloneIdBndr"
></A
></A
><B
>cloneIdBndr</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="UniqSupply.html#t%3AUniqSupply"
>UniqSupply</A
> -&gt; <A HREF="Var.html#t%3AId"
>Id</A
> -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, <A HREF="Var.html#t%3AId"
>Id</A
>)</TD
></TR
><TR
><TD CLASS="doc"
>Very similar to <TT
><A HREF="CoreSubst.html#v%3AsubstBndr"
>substBndr</A
></TT
>, but it always allocates a new <TT
><A HREF="Unique.html#t%3AUnique"
>Unique</A
></TT
> for
 each variable in its output and removes all <TT
><A HREF="IdInfo.html#t%3AIdInfo"
>IdInfo</A
></TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:cloneIdBndrs"
><A NAME="v%3AcloneIdBndrs"
></A
></A
><B
>cloneIdBndrs</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="UniqSupply.html#t%3AUniqSupply"
>UniqSupply</A
> -&gt; [<A HREF="Var.html#t%3AId"
>Id</A
>] -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, [<A HREF="Var.html#t%3AId"
>Id</A
>])</TD
></TR
><TR
><TD CLASS="doc"
>Applies <TT
><A HREF="CoreSubst.html#v%3AcloneIdBndr"
>cloneIdBndr</A
></TT
> to a number of <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
>s, accumulating a final
 substitution from left to right
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:cloneRecIdBndrs"
><A NAME="v%3AcloneRecIdBndrs"
></A
></A
><B
>cloneRecIdBndrs</B
> :: <A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
> -&gt; <A HREF="UniqSupply.html#t%3AUniqSupply"
>UniqSupply</A
> -&gt; [<A HREF="Var.html#t%3AId"
>Id</A
>] -&gt; (<A HREF="CoreSubst.html#t%3ASubst"
>Subst</A
>, [<A HREF="Var.html#t%3AId"
>Id</A
>])</TD
></TR
><TR
><TD CLASS="doc"
>Clone a mutually recursive group of <TT
><A HREF="Var.html#t%3AId"
>Id</A
></TT
>s
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="botbar"
>Produced by <A HREF="http://www.haskell.org/haddock/"
>Haddock</A
> version 2.4.2</TD
></TR
></TABLE
></BODY
></HTML
>