Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 6e204a966e8c42d976f99a1700ce5f20 > files > 2841

ghc-7.4.2-4.mga5.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>CoreUtils</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_CoreUtils.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">ghc-7.4.2: The GHC API</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr></table><p class="caption">CoreUtils</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Constructing expressions
</a></li><li><a href="#g:2">Taking expressions apart
</a></li><li><a href="#g:3">Properties of expressions
</a></li><li><a href="#g:4">Expression and bindings size
</a></li><li><a href="#g:5">Hashing
</a></li><li><a href="#g:6">Equality
</a></li><li><a href="#g:7">Eta reduction
</a></li><li><a href="#g:8">Manipulating data constructors and types
</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Commonly useful utilites for manipulating the Core language
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:mkCast">mkCast</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="Coercion.html#t:Coercion">Coercion</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></li><li class="src short"><a href="#v:mkTick">mkTick</a> :: <a href="CoreSyn.html#t:Tickish">Tickish</a> <a href="Var.html#t:Id">Id</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></li><li class="src short"><a href="#v:mkTickNoHNF">mkTickNoHNF</a> :: <a href="CoreSyn.html#t:Tickish">Tickish</a> <a href="Var.html#t:Id">Id</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></li><li class="src short"><a href="#v:bindNonRec">bindNonRec</a> :: <a href="Var.html#t:Id">Id</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></li><li class="src short"><a href="#v:needsCaseBinding">needsCaseBinding</a> :: <a href="Type.html#t:Type">Type</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:mkAltExpr">mkAltExpr</a> :: <a href="CoreSyn.html#t:AltCon">AltCon</a> -&gt; [<a href="CoreSyn.html#t:CoreBndr">CoreBndr</a>] -&gt; [<a href="Type.html#t:Type">Type</a>] -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></li><li class="src short"><a href="#v:findDefault">findDefault</a> :: [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>] -&gt; ([<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>], <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a>)</li><li class="src short"><a href="#v:findAlt">findAlt</a> :: <a href="CoreSyn.html#t:AltCon">AltCon</a> -&gt; [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>] -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="CoreSyn.html#t:CoreAlt">CoreAlt</a></li><li class="src short"><a href="#v:isDefaultAlt">isDefaultAlt</a> :: <a href="CoreSyn.html#t:CoreAlt">CoreAlt</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:mergeAlts">mergeAlts</a> :: [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>] -&gt; [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>] -&gt; [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>]</li><li class="src short"><a href="#v:trimConArgs">trimConArgs</a> :: <a href="CoreSyn.html#t:AltCon">AltCon</a> -&gt; [<a href="CoreSyn.html#t:CoreArg">CoreArg</a>] -&gt; [<a href="CoreSyn.html#t:CoreArg">CoreArg</a>]</li><li class="src short"><a href="#v:exprType">exprType</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="Type.html#t:Type">Type</a></li><li class="src short"><a href="#v:coreAltType">coreAltType</a> :: <a href="CoreSyn.html#t:CoreAlt">CoreAlt</a> -&gt; <a href="Type.html#t:Type">Type</a></li><li class="src short"><a href="#v:coreAltsType">coreAltsType</a> :: [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>] -&gt; <a href="Type.html#t:Type">Type</a></li><li class="src short"><a href="#v:exprIsDupable">exprIsDupable</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:exprIsTrivial">exprIsTrivial</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:getIdFromTrivialExpr">getIdFromTrivialExpr</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="Var.html#t:Id">Id</a></li><li class="src short"><a href="#v:exprIsBottom">exprIsBottom</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:exprIsCheap">exprIsCheap</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:exprIsExpandable">exprIsExpandable</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:exprIsCheap-39-">exprIsCheap'</a> :: <a href="CoreUtils.html#t:CheapAppFun">CheapAppFun</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:CheapAppFun">CheapAppFun</a> = <a href="Var.html#t:Id">Id</a> -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:exprIsHNF">exprIsHNF</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:exprOkForSpeculation">exprOkForSpeculation</a> ::  <a href="CoreSyn.html#t:Expr">Expr</a> b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:exprOkForSideEffects">exprOkForSideEffects</a> ::  <a href="CoreSyn.html#t:Expr">Expr</a> b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:exprIsBig">exprIsBig</a> ::  <a href="CoreSyn.html#t:Expr">Expr</a> b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:exprIsConLike">exprIsConLike</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:rhsIsStatic">rhsIsStatic</a> :: (<a href="Name.html#t:Name">Name</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isCheapApp">isCheapApp</a> :: <a href="CoreUtils.html#t:CheapAppFun">CheapAppFun</a></li><li class="src short"><a href="#v:isExpandableApp">isExpandableApp</a> :: <a href="CoreUtils.html#t:CheapAppFun">CheapAppFun</a></li><li class="src short"><a href="#v:coreBindsSize">coreBindsSize</a> :: [<a href="CoreSyn.html#t:CoreBind">CoreBind</a>] -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:exprSize">exprSize</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:CoreStats">CoreStats</a>  = <a href="#v:CS">CS</a> {<ul class="subs"><li><a href="#v:cs_tm">cs_tm</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></li><li><a href="#v:cs_ty">cs_ty</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></li><li><a href="#v:cs_co">cs_co</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></li></ul>}</li><li class="src short"><a href="#v:coreBindsStats">coreBindsStats</a> :: [<a href="CoreSyn.html#t:CoreBind">CoreBind</a>] -&gt; <a href="CoreUtils.html#t:CoreStats">CoreStats</a></li><li class="src short"><a href="#v:hashExpr">hashExpr</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:cheapEqExpr">cheapEqExpr</a> ::  <a href="CoreSyn.html#t:Expr">Expr</a> b -&gt; <a href="CoreSyn.html#t:Expr">Expr</a> b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:eqExpr">eqExpr</a> :: <a href="VarEnv.html#t:InScopeSet">InScopeSet</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:eqExprX">eqExprX</a> :: <a href="CoreSyn.html#t:IdUnfoldingFun">IdUnfoldingFun</a> -&gt; <a href="VarEnv.html#t:RnEnv2">RnEnv2</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:tryEtaReduce">tryEtaReduce</a> :: [<a href="Var.html#t:Var">Var</a>] -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></li><li class="src short"><a href="#v:applyTypeToArgs">applyTypeToArgs</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="Type.html#t:Type">Type</a> -&gt; [<a href="CoreSyn.html#t:CoreExpr">CoreExpr</a>] -&gt; <a href="Type.html#t:Type">Type</a></li><li class="src short"><a href="#v:applyTypeToArg">applyTypeToArg</a> :: <a href="Type.html#t:Type">Type</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="Type.html#t:Type">Type</a></li><li class="src short"><a href="#v:dataConRepInstPat">dataConRepInstPat</a> :: [<a href="Unique.html#t:Unique">Unique</a>] -&gt; <a href="DataCon.html#t:DataCon">DataCon</a> -&gt; [<a href="Type.html#t:Type">Type</a>] -&gt; ([<a href="Var.html#t:TyVar">TyVar</a>], [<a href="Var.html#t:Id">Id</a>])</li><li class="src short"><a href="#v:dataConRepFSInstPat">dataConRepFSInstPat</a> :: [<a href="FastString.html#t:FastString">FastString</a>] -&gt; [<a href="Unique.html#t:Unique">Unique</a>] -&gt; <a href="DataCon.html#t:DataCon">DataCon</a> -&gt; [<a href="Type.html#t:Type">Type</a>] -&gt; ([<a href="Var.html#t:TyVar">TyVar</a>], [<a href="Var.html#t:Id">Id</a>])</li></ul></div><div id="interface"><h1 id="g:1">Constructing expressions
</h1><div class="top"><p class="src"><a name="v:mkCast" class="def">mkCast</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="Coercion.html#t:Coercion">Coercion</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></p><div class="doc"><p>Wrap the given expression in the coercion safely, dropping
 identity coercions and coalescing nested coercions
</p></div></div><div class="top"><p class="src"><a name="v:mkTick" class="def">mkTick</a> :: <a href="CoreSyn.html#t:Tickish">Tickish</a> <a href="Var.html#t:Id">Id</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></p><div class="doc"><p>Wraps the given expression in the source annotation, dropping the
 annotation if possible.
</p></div></div><div class="top"><p class="src"><a name="v:mkTickNoHNF" class="def">mkTickNoHNF</a> :: <a href="CoreSyn.html#t:Tickish">Tickish</a> <a href="Var.html#t:Id">Id</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></p></div><div class="top"><p class="src"><a name="v:bindNonRec" class="def">bindNonRec</a> :: <a href="Var.html#t:Id">Id</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></p><div class="doc"><p><code>bindNonRec x r b</code> produces either:
</p><pre> let x = r in b
</pre><p>or:
</p><pre> case r of x { _DEFAULT_ -&gt; b }
</pre><p>depending on whether we have to use a <code>case</code> or <code>let</code>
 binding for the expression (see <code><a href="CoreUtils.html#v:needsCaseBinding">needsCaseBinding</a></code>).
 It's used by the desugarer to avoid building bindings
 that give Core Lint a heart attack, although actually
 the simplifier deals with them perfectly well. See
 also <code><a href="MkCore.html#v:mkCoreLet">mkCoreLet</a></code>
</p></div></div><div class="top"><p class="src"><a name="v:needsCaseBinding" class="def">needsCaseBinding</a> :: <a href="Type.html#t:Type">Type</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Tests whether we have to use a <code>case</code> rather than <code>let</code> binding for this expression
 as per the invariants of <code><a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></code>: see <a href="CoreSyn.html#let_app_invariant">CoreSyn</a>
</p></div></div><div class="top"><p class="src"><a name="v:mkAltExpr" class="def">mkAltExpr</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="CoreSyn.html#t:AltCon">AltCon</a></td><td class="doc"><p>Case alternative constructor
</p></td></tr><tr><td class="src">-&gt; [<a href="CoreSyn.html#t:CoreBndr">CoreBndr</a>]</td><td class="doc"><p>Things bound by the pattern match
</p></td></tr><tr><td class="src">-&gt; [<a href="Type.html#t:Type">Type</a>]</td><td class="doc"><p>The type arguments to the case alternative
</p></td></tr><tr><td class="src">-&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>This guy constructs the value that the scrutinee must have
 given that you are in one particular branch of a case
</p></div></div><h1 id="g:2">Taking expressions apart
</h1><div class="top"><p class="src"><a name="v:findDefault" class="def">findDefault</a> :: [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>] -&gt; ([<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>], <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a>)</p><div class="doc"><p>Extract the default case alternative
</p></div></div><div class="top"><p class="src"><a name="v:findAlt" class="def">findAlt</a> :: <a href="CoreSyn.html#t:AltCon">AltCon</a> -&gt; [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>] -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="CoreSyn.html#t:CoreAlt">CoreAlt</a></p><div class="doc"><p>Find the case alternative corresponding to a particular
 constructor: panics if no such constructor exists
</p></div></div><div class="top"><p class="src"><a name="v:isDefaultAlt" class="def">isDefaultAlt</a> :: <a href="CoreSyn.html#t:CoreAlt">CoreAlt</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:mergeAlts" class="def">mergeAlts</a> :: [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>] -&gt; [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>] -&gt; [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>]</p><div class="doc"><p>Merge alternatives preserving order; alternatives in
 the first argument shadow ones in the second
</p></div></div><div class="top"><p class="src"><a name="v:trimConArgs" class="def">trimConArgs</a> :: <a href="CoreSyn.html#t:AltCon">AltCon</a> -&gt; [<a href="CoreSyn.html#t:CoreArg">CoreArg</a>] -&gt; [<a href="CoreSyn.html#t:CoreArg">CoreArg</a>]</p><div class="doc"><p>Given:
</p><pre> case (C a b x y) of
        C b x y -&gt; ...
</pre><p>We want to drop the leading type argument of the scrutinee
 leaving the arguments to match agains the pattern
</p></div></div><h1 id="g:3">Properties of expressions
</h1><div class="top"><p class="src"><a name="v:exprType" class="def">exprType</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="Type.html#t:Type">Type</a></p><div class="doc"><p>Recover the type of a well-typed Core expression. Fails when
 applied to the actual <code><a href="CoreSyn.html#v:Type">Type</a></code> expression as it cannot
 really be said to have a type
</p></div></div><div class="top"><p class="src"><a name="v:coreAltType" class="def">coreAltType</a> :: <a href="CoreSyn.html#t:CoreAlt">CoreAlt</a> -&gt; <a href="Type.html#t:Type">Type</a></p><div class="doc"><p>Returns the type of the alternatives right hand side
</p></div></div><div class="top"><p class="src"><a name="v:coreAltsType" class="def">coreAltsType</a> :: [<a href="CoreSyn.html#t:CoreAlt">CoreAlt</a>] -&gt; <a href="Type.html#t:Type">Type</a></p><div class="doc"><p>Returns the type of the first alternative, which should be the same as for all alternatives
</p></div></div><div class="top"><p class="src"><a name="v:exprIsDupable" class="def">exprIsDupable</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:exprIsTrivial" class="def">exprIsTrivial</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:getIdFromTrivialExpr" class="def">getIdFromTrivialExpr</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="Var.html#t:Id">Id</a></p></div><div class="top"><p class="src"><a name="v:exprIsBottom" class="def">exprIsBottom</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:exprIsCheap" class="def">exprIsCheap</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:exprIsExpandable" class="def">exprIsExpandable</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:exprIsCheap-39-" class="def">exprIsCheap'</a> :: <a href="CoreUtils.html#t:CheapAppFun">CheapAppFun</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:CheapAppFun" class="def">CheapAppFun</a> = <a href="Var.html#t:Id">Id</a> -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:exprIsHNF" class="def">exprIsHNF</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>exprIsHNF returns true for expressions that are certainly <em>already</em>
 evaluated to <em>head</em> normal form.  This is used to decide whether it's ok
 to change:
</p><pre> case x of _ -&gt; e
</pre><p>into:
</p><pre> e
</pre><p>and to decide whether it's safe to discard a <code><a href="../base-4.5.1.0/Prelude.html#v:seq">seq</a></code>.
</p><p>So, it does <em>not</em> treat variables as evaluated, unless they say they are.
 However, it <em>does</em> treat partial applications and constructor applications
 as values, even if their arguments are non-trivial, provided the argument
 type is lifted. For example, both of these are values:
</p><pre> (:) (f x) (map f xs)
 map (...redex...)
</pre><p>because <code><a href="../base-4.5.1.0/Prelude.html#v:seq">seq</a></code> on such things completes immediately.
</p><p>For unlifted argument types, we have to be careful:
</p><pre> C (f x :: Int#)
</pre><p>Suppose <code>f x</code> diverges; then <code>C (f x)</code> is not a value. However this can't
 happen: see <a href="CoreSyn.html#let_app_invariant">CoreSyn</a>. This invariant states that arguments of
 unboxed type must be ok-for-speculation (or trivial).
</p></div></div><div class="top"><p class="src"><a name="v:exprOkForSpeculation" class="def">exprOkForSpeculation</a> ::  <a href="CoreSyn.html#t:Expr">Expr</a> b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><code><a href="CoreUtils.html#v:exprOkForSpeculation">exprOkForSpeculation</a></code> returns True of an expression that is:
</p><ul><li> Safe to evaluate even if normal order eval might not
    evaluate the expression at all, or
</li><li> Safe <em>not</em> to evaluate even if normal order would do so
</li></ul><p>It is usually called on arguments of unlifted type, but not always
 In particular, Simplify.rebuildCase calls it on lifted types
 when a 'case' is a plain <code><a href="../base-4.5.1.0/Prelude.html#v:seq">seq</a></code>. See the example in
 Note [exprOkForSpeculation: case expressions] below
</p><p>Precisely, it returns <code>True</code> iff:
</p><ul><li> The expression guarantees to terminate,
  * soon,
  * without raising an exception,
  * without causing a side effect (e.g. writing a mutable variable)
</li></ul><p>Note that if <code>exprIsHNF e</code>, then <code>exprOkForSpecuation e</code>.
 As an example of the considerations in this test, consider:
</p><pre> let x = case y# +# 1# of { r# -&gt; I# r# }
 in E
</pre><p>being translated to:
</p><pre> case y# +# 1# of { r# -&gt;
    let x = I# r#
    in E
 }
</pre><p>We can only do this if the <code>y + 1</code> is ok for speculation: it has no
 side effects, and can't diverge or raise an exception.
</p></div></div><div class="top"><p class="src"><a name="v:exprOkForSideEffects" class="def">exprOkForSideEffects</a> ::  <a href="CoreSyn.html#t:Expr">Expr</a> b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><code><a href="CoreUtils.html#v:exprOkForSpeculation">exprOkForSpeculation</a></code> returns True of an expression that is:
</p><ul><li> Safe to evaluate even if normal order eval might not
    evaluate the expression at all, or
</li><li> Safe <em>not</em> to evaluate even if normal order would do so
</li></ul><p>It is usually called on arguments of unlifted type, but not always
 In particular, Simplify.rebuildCase calls it on lifted types
 when a 'case' is a plain <code><a href="../base-4.5.1.0/Prelude.html#v:seq">seq</a></code>. See the example in
 Note [exprOkForSpeculation: case expressions] below
</p><p>Precisely, it returns <code>True</code> iff:
</p><ul><li> The expression guarantees to terminate,
  * soon,
  * without raising an exception,
  * without causing a side effect (e.g. writing a mutable variable)
</li></ul><p>Note that if <code>exprIsHNF e</code>, then <code>exprOkForSpecuation e</code>.
 As an example of the considerations in this test, consider:
</p><pre> let x = case y# +# 1# of { r# -&gt; I# r# }
 in E
</pre><p>being translated to:
</p><pre> case y# +# 1# of { r# -&gt;
    let x = I# r#
    in E
 }
</pre><p>We can only do this if the <code>y + 1</code> is ok for speculation: it has no
 side effects, and can't diverge or raise an exception.
</p></div></div><div class="top"><p class="src"><a name="v:exprIsBig" class="def">exprIsBig</a> ::  <a href="CoreSyn.html#t:Expr">Expr</a> b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Returns <code>True</code> of expressions that are too big to be compared by <code><a href="CoreUtils.html#v:cheapEqExpr">cheapEqExpr</a></code>
</p></div></div><div class="top"><p class="src"><a name="v:exprIsConLike" class="def">exprIsConLike</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Similar to <code><a href="CoreUtils.html#v:exprIsHNF">exprIsHNF</a></code> but includes CONLIKE functions as well as
 data constructors. Conlike arguments are considered interesting by the
 inliner.
</p></div></div><div class="top"><p class="src"><a name="v:rhsIsStatic" class="def">rhsIsStatic</a> :: (<a href="Name.html#t:Name">Name</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>This function is called only on *top-level* right-hand sides.
 Returns <code>True</code> if the RHS can be allocated statically in the output,
 with no thunks involved at all.
</p></div></div><div class="top"><p class="src"><a name="v:isCheapApp" class="def">isCheapApp</a> :: <a href="CoreUtils.html#t:CheapAppFun">CheapAppFun</a></p></div><div class="top"><p class="src"><a name="v:isExpandableApp" class="def">isExpandableApp</a> :: <a href="CoreUtils.html#t:CheapAppFun">CheapAppFun</a></p></div><h1 id="g:4">Expression and bindings size
</h1><div class="top"><p class="src"><a name="v:coreBindsSize" class="def">coreBindsSize</a> :: [<a href="CoreSyn.html#t:CoreBind">CoreBind</a>] -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></p></div><div class="top"><p class="src"><a name="v:exprSize" class="def">exprSize</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></p><div class="doc"><p>A measure of the size of the expressions, strictly greater than 0
 It also forces the expression pretty drastically as a side effect
 Counts *leaves*, not internal nodes. Types and coercions are not counted.
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:CoreStats" class="def">CoreStats</a>  </p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:CS" class="def">CS</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:cs_tm" class="def">cs_tm</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:cs_ty" class="def">cs_ty</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:cs_co" class="def">cs_co</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty">&nbsp;</dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:CoreStats" class="caption collapser" onclick="toggleSection('i:CoreStats')">Instances</p><div id="section.i:CoreStats" class="show"><table><tr><td class="src"><a href="Outputable.html#t:Outputable">Outputable</a> <a href="CoreUtils.html#t:CoreStats">CoreStats</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:coreBindsStats" class="def">coreBindsStats</a> :: [<a href="CoreSyn.html#t:CoreBind">CoreBind</a>] -&gt; <a href="CoreUtils.html#t:CoreStats">CoreStats</a></p></div><h1 id="g:5">Hashing
</h1><div class="top"><p class="src"><a name="v:hashExpr" class="def">hashExpr</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></p><div class="doc"><p>Two expressions that hash to the same <code>Int</code> may be equal (but may not be)
 Two expressions that hash to the different Ints are definitely unequal.
</p><p>The emphasis is on a crude, fast hash, rather than on high precision.
</p><p>But unequal here means &quot;not identical&quot;; two alpha-equivalent
 expressions may hash to the different Ints.
</p><p>We must be careful that <code>\x.x</code> and <code>\y.y</code> map to the same hash code,
 (at least if we want the above invariant to be true).
</p></div></div><h1 id="g:6">Equality
</h1><div class="top"><p class="src"><a name="v:cheapEqExpr" class="def">cheapEqExpr</a> ::  <a href="CoreSyn.html#t:Expr">Expr</a> b -&gt; <a href="CoreSyn.html#t:Expr">Expr</a> b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>A cheap equality test which bales out fast!
      If it returns <code>True</code> the arguments are definitely equal,
      otherwise, they may or may not be equal.
</p><p>See also <code><a href="CoreUtils.html#v:exprIsBig">exprIsBig</a></code>
</p></div></div><div class="top"><p class="src"><a name="v:eqExpr" class="def">eqExpr</a> :: <a href="VarEnv.html#t:InScopeSet">InScopeSet</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p></div><div class="top"><p class="src"><a name="v:eqExprX" class="def">eqExprX</a> :: <a href="CoreSyn.html#t:IdUnfoldingFun">IdUnfoldingFun</a> -&gt; <a href="VarEnv.html#t:RnEnv2">RnEnv2</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Compares expressions for equality, modulo alpha.
 Does <em>not</em> look through newtypes or predicate types
 Used in rule matching, and also CSE
</p></div></div><h1 id="g:7">Eta reduction
</h1><div class="top"><p class="src"><a name="v:tryEtaReduce" class="def">tryEtaReduce</a> :: [<a href="Var.html#t:Var">Var</a>] -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a></p></div><h1 id="g:8">Manipulating data constructors and types
</h1><div class="top"><p class="src"><a name="v:applyTypeToArgs" class="def">applyTypeToArgs</a> :: <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="Type.html#t:Type">Type</a> -&gt; [<a href="CoreSyn.html#t:CoreExpr">CoreExpr</a>] -&gt; <a href="Type.html#t:Type">Type</a></p><div class="doc"><p>A more efficient version of <code><a href="CoreUtils.html#v:applyTypeToArg">applyTypeToArg</a></code> when we have several arguments.
 The first argument is just for debugging, and gives some context
</p></div></div><div class="top"><p class="src"><a name="v:applyTypeToArg" class="def">applyTypeToArg</a> :: <a href="Type.html#t:Type">Type</a> -&gt; <a href="CoreSyn.html#t:CoreExpr">CoreExpr</a> -&gt; <a href="Type.html#t:Type">Type</a></p><div class="doc"><p>Determines the type resulting from applying an expression to a function with the given type
</p></div></div><div class="top"><p class="src"><a name="v:dataConRepInstPat" class="def">dataConRepInstPat</a> :: [<a href="Unique.html#t:Unique">Unique</a>] -&gt; <a href="DataCon.html#t:DataCon">DataCon</a> -&gt; [<a href="Type.html#t:Type">Type</a>] -&gt; ([<a href="Var.html#t:TyVar">TyVar</a>], [<a href="Var.html#t:Id">Id</a>])</p></div><div class="top"><p class="src"><a name="v:dataConRepFSInstPat" class="def">dataConRepFSInstPat</a> :: [<a href="FastString.html#t:FastString">FastString</a>] -&gt; [<a href="Unique.html#t:Unique">Unique</a>] -&gt; <a href="DataCon.html#t:DataCon">DataCon</a> -&gt; [<a href="Type.html#t:Type">Type</a>] -&gt; ([<a href="Var.html#t:TyVar">TyVar</a>], [<a href="Var.html#t:Id">Id</a>])</p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.11.0</p></div></body></html>