






%
%
\makeatletter
\@ifundefined{lhs2tex.lhs2tex.sty.read}%
  {\@namedef{lhs2tex.lhs2tex.sty.read}{}%
   \newcommand\SkipToFmtEnd{}%
   \newcommand\EndFmtInput{}%
   \long\def\SkipToFmtEnd#1\EndFmtInput{}%
  }\SkipToFmtEnd

\newcommand\ReadOnlyOnce[1]{\@ifundefined{#1}{\@namedef{#1}{}}\SkipToFmtEnd}
\usepackage{amstext}
\usepackage{amssymb}
\usepackage{stmaryrd}
\DeclareFontFamily{OT1}{cmtex}{}
\DeclareFontShape{OT1}{cmtex}{m}{n}
  {<5><6><7><8>cmtex8
   <9>cmtex9
   <10><10.95><12><14.4><17.28><20.74><24.88>cmtex10}{}
\DeclareFontShape{OT1}{cmtex}{m}{it}
  {<-> ssub * cmtt/m/it}{}
\newcommand{\texfamily}{\fontfamily{cmtex}\selectfont}
\DeclareFontShape{OT1}{cmtt}{bx}{n}
  {<5><6><7><8>cmtt8
   <9>cmbtt9
   <10><10.95><12><14.4><17.28><20.74><24.88>cmbtt10}{}
\DeclareFontShape{OT1}{cmtex}{bx}{n}
  {<-> ssub * cmtt/bx/n}{}
\newcommand{\tex}[1]{\text{\texfamily#1}}	% NEU

\newcommand{\Sp}{\hskip.33334em\relax}


\newcommand{\Conid}[1]{\mathit{#1}}
\newcommand{\Varid}[1]{\mathit{#1}}
\newcommand{\anonymous}{\kern0.06em \vbox{\hrule\@width.5em}}
\newcommand{\plus}{\mathbin{+\!\!\!+}}
\newcommand{\bind}{\mathbin{>\!\!\!>\mkern-6.7mu=}}
\newcommand{\rbind}{\mathbin{=\mkern-6.7mu<\!\!\!<}}% suggested by Neil Mitchell
\newcommand{\sequ}{\mathbin{>\!\!\!>}}
\renewcommand{\leq}{\leqslant}
\renewcommand{\geq}{\geqslant}
\usepackage{polytable}

%mathindent has to be defined
\@ifundefined{mathindent}%
  {\newdimen\mathindent\mathindent\leftmargini}%
  {}%

\def\resethooks{%
  \global\let\SaveRestoreHook\empty
  \global\let\ColumnHook\empty}
\newcommand*{\savecolumns}[1][default]%
  {\g@addto@macro\SaveRestoreHook{\savecolumns[#1]}}
\newcommand*{\restorecolumns}[1][default]%
  {\g@addto@macro\SaveRestoreHook{\restorecolumns[#1]}}
\newcommand*{\aligncolumn}[2]%
  {\g@addto@macro\ColumnHook{\column{#1}{#2}}}

\resethooks

\newcommand{\onelinecommentchars}{\quad-{}- }
\newcommand{\commentbeginchars}{\enskip\{-}
\newcommand{\commentendchars}{-\}\enskip}

\newcommand{\visiblecomments}{%
  \let\onelinecomment=\onelinecommentchars
  \let\commentbegin=\commentbeginchars
  \let\commentend=\commentendchars}

\newcommand{\invisiblecomments}{%
  \let\onelinecomment=\empty
  \let\commentbegin=\empty
  \let\commentend=\empty}

\visiblecomments

\newlength{\blanklineskip}
\setlength{\blanklineskip}{0.66084ex}

\newcommand{\hsindent}[1]{\quad}% default is fixed indentation
\let\hspre\empty
\let\hspost\empty
\newcommand{\NB}{\textbf{NB}}
\newcommand{\Todo}[1]{$\langle$\textbf{To do:}~#1$\rangle$}

\EndFmtInput
\makeatother
%

\begingroup\par\noindent
\haskellfont\(
\begin{pboxed}\SaveRestoreHook
\column{B}{@{}>{\hspre}l<{\hspost}@{}}%
\column{3}{@{}>{\hspre}l<{\hspost}@{}}%
\column{5}{@{}>{\hspre}l<{\hspost}@{}}%
\column{8}{@{}>{\hspre}l<{\hspost}@{}}%
\column{12}{@{}>{\hspre}l<{\hspost}@{}}%
\column{17}{@{}>{\hspre}l<{\hspost}@{}}%
\column{21}{@{}>{\hspre}l<{\hspost}@{}}%
\column{42}{@{}>{\hspre}l<{\hspost}@{}}%
\column{E}{@{}>{\hspre}l<{\hspost}@{}}%
\>[B]{}\text{\hkw{module}}\;\text{CallArity}\;(\text{callArityAnalProgram},\;{}\<[42]%
\>[42]{}\text{callArityRHS})\;\text{\hkw{where}}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{\hkw{import}}\;\text{VarSet}{}\<[E]%
\\
\>[B]{}\text{\hkw{import}}\;\text{VarEnv}{}\<[E]%
\\
\>[B]{}\text{\hkw{import}}\;\text{DynFlags}\;(\text{DynFlags}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{\hkw{import}}\;\text{BasicTypes}{}\<[E]%
\\
\>[B]{}\text{\hkw{import}}\;\text{CoreSyn}{}\<[E]%
\\
\>[B]{}\text{\hkw{import}}\;\text{Id}{}\<[E]%
\\
\>[B]{}\text{\hkw{import}}\;\text{CoreArity}\;(\text{typeArity}){}\<[E]%
\\
\>[B]{}\text{\hkw{import}}\;\text{CoreUtils}\;(\text{exprIsHNF},\;\text{exprIsTrivial}){}\<[E]%
\\
\>[B]{}\text{\hkw{import}}\;\text{UnVarGraph}{}\<[E]%
\\
\>[B]{}\text{\hkw{import}}\;\text{Demand}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{\hkw{import}}\;\text{\text{Control}.Arrow}\;(\text{first},\;\text{second}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityAnalProgram}\mathbin{::}\text{DynFlags}\rightarrow \text{CoreProgram}\rightarrow \text{CoreProgram}{}\<[E]%
\\
\>[B]{}\text{callArityAnalProgram}\;\text{\char95 dflags}\;\text{binds}\mathrel{=}\text{binds'}{}\<[E]%
\\
\>[B]{}~~{}\<[3]%
\>[3]{}\text{\hkw{where}}{}\<[E]%
\\
\>[3]{}~~{}\<[5]%
\>[5]{}(\text{\char95 },\;\text{binds'})\mathrel{=}\text{callArityTopLvl}\;[\mskip1.5mu \mskip1.5mu]\;\text{emptyVarSet}\;\text{binds}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityTopLvl}\mathbin{::}{}\<[21]%
\>[21]{}[\mskip1.5mu \text{Var}\mskip1.5mu]\rightarrow \text{VarSet}\rightarrow [\mskip1.5mu \text{CoreBind}\mskip1.5mu]\rightarrow {}\<[E]%
\\
\>[21]{}(\text{CallArityRes},\;[\mskip1.5mu \text{CoreBind}\mskip1.5mu]){}\<[E]%
\\
\>[B]{}\text{callArityTopLvl}\;\text{exported}\;\text{\char95 }\;[\mskip1.5mu \mskip1.5mu]{}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[8]%
\>[8]{}({}\<[12]%
\>[12]{}\text{calledMultipleTimes}\mathbin{\$}{}\<[E]%
\\
\>[12]{}(\text{emptyUnVarGraph},\;\text{mkVarEnv}\mathbin{\$}[\mskip1.5mu (\text{v},\;0)\mathrel{|}\text{v}\leftarrow \text{exported}\mskip1.5mu]){}\<[E]%
\\
\>[8]{},\;{}\<[12]%
\>[12]{}[\mskip1.5mu \mskip1.5mu]){}\<[E]%
\\
\>[B]{}\text{callArityTopLvl}\;\text{exported}\;\text{int1}\;(\text{b}\mathbin{:}\text{bs}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[8]%
\>[8]{}(\text{ae2},\;\text{b'}\mathbin{:}\text{bs'}){}\<[E]%
\\
\>[B]{}~~{}\<[3]%
\>[3]{}\text{\hkw{where}}{}\<[E]%
\\
\>[3]{}~~{}\<[5]%
\>[5]{}\text{int2}{}\<[17]%
\>[17]{}\mathrel{=}\text{bindersOf}\;\text{b}{}\<[E]%
\\
\>[3]{}~~{}\<[5]%
\>[5]{}\text{exported'}{}\<[17]%
\>[17]{}\mathrel{=}\text{filter}\;\text{isExportedId}\;\text{int2}\mathbin{++}\text{exported}{}\<[E]%
\\
\>[3]{}~~{}\<[5]%
\>[5]{}\text{int'}{}\<[17]%
\>[17]{}\mathrel{=}\text{int1}\mathbin{`\text{addInterestingBinds}`}\text{b}{}\<[E]%
\\
\>[3]{}~~{}\<[5]%
\>[5]{}(\text{ae1},\;\text{bs'}){}\<[17]%
\>[17]{}\mathrel{=}\text{callArityTopLvl}\;\text{exported'}\;\text{int'}\;\text{bs}{}\<[E]%
\\
\>[3]{}~~{}\<[5]%
\>[5]{}(\text{ae2},\;\text{b'}){}\<[17]%
\>[17]{}\mathrel{=}\text{callArityBind}\;(\text{boringBinds}\;\text{b})\;\text{ae1}\;\text{int1}\;\text{b}{}\<[E]%
\ColumnHook
\end{pboxed}
\)\par\noindent\endgroup\resethooks
\\
\begingroup\par\noindent
\haskellfont\(
\begin{pboxed}\SaveRestoreHook
\column{B}{@{}>{\hspre}l<{\hspost}@{}}%
\column{3}{@{}>{\hspre}l<{\hspost}@{}}%
\column{5}{@{}>{\hspre}c<{\hspost}@{}}%
\column{5E}{@{}l@{}}%
\column{6}{@{}>{\hspre}l<{\hspost}@{}}%
\column{8}{@{}>{\hspre}l<{\hspost}@{}}%
\column{12}{@{}>{\hspre}l<{\hspost}@{}}%
\column{16}{@{}>{\hspre}l<{\hspost}@{}}%
\column{18}{@{}>{\hspre}l<{\hspost}@{}}%
\column{22}{@{}>{\hspre}l<{\hspost}@{}}%
\column{26}{@{}>{\hspre}c<{\hspost}@{}}%
\column{26E}{@{}l@{}}%
\column{27}{@{}>{\hspre}l<{\hspost}@{}}%
\column{29}{@{}>{\hspre}l<{\hspost}@{}}%
\column{32}{@{}>{\hspre}l<{\hspost}@{}}%
\column{47}{@{}>{\hspre}l<{\hspost}@{}}%
\column{E}{@{}>{\hspre}l<{\hspost}@{}}%
\>[B]{}\text{callArityRHS}\mathbin{::}\text{CoreExpr}\rightarrow \text{CoreExpr}{}\<[E]%
\\
\>[B]{}\text{callArityRHS}\mathrel{=}\text{snd}\mathbin{.}\text{callArityAnal}\;0\;\text{emptyVarSet}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityAnal}\mathbin{::}\text{Arity}\rightarrow \text{VarSet}\rightarrow \text{CoreExpr}\rightarrow (\text{CallArityRes},\;\text{CoreExpr}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityAnal}\;\text{\char95 }\;{}\<[22]%
\>[22]{}\text{\char95 }\;{}\<[27]%
\>[27]{}\text{e}\mathord{@}(\text{Lit}\;\text{\char95 }){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{emptyArityRes},\;\text{e}){}\<[E]%
\\
\>[B]{}\text{callArityAnal}\;\text{\char95 }\;{}\<[22]%
\>[22]{}\text{\char95 }\;{}\<[27]%
\>[27]{}\text{e}\mathord{@}(\text{Type}\;\text{\char95 }){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{emptyArityRes},\;\text{e}){}\<[E]%
\\
\>[B]{}\text{callArityAnal}\;\text{\char95 }\;{}\<[22]%
\>[22]{}\text{\char95 }\;{}\<[27]%
\>[27]{}\text{e}\mathord{@}(\text{Coercion}\;\text{\char95 }){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{emptyArityRes},\;\text{e}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityAnal}\;\text{arity}\;{}\<[22]%
\>[22]{}\text{int}\;{}\<[27]%
\>[27]{}(\text{Tick}\;\text{t}\;\text{e}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}\text{second}\;(\text{Tick}\;\text{t})\mathbin{\$}\text{callArityAnal}\;\text{arity}\;\text{int}\;\text{e}{}\<[E]%
\\
\>[B]{}\text{callArityAnal}\;\text{arity}\;{}\<[22]%
\>[22]{}\text{int}\;{}\<[27]%
\>[27]{}(\text{Cast}\;\text{e}\;\text{co}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}\text{second}\;(\lambda \text{e}\rightarrow \text{Cast}\;\text{e}\;\text{co})\mathbin{\$}\text{callArityAnal}\;\text{arity}\;\text{int}\;\text{e}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityAnal}\;\text{arity}\;{}\<[22]%
\>[22]{}\text{int}\;{}\<[27]%
\>[27]{}\text{e}\mathord{@}(\text{Var}\;\text{v}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{|}{}\<[5E]%
\>[8]{}\text{v}\mathbin{`\text{elemVarSet}`}\text{int}{}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{unitArityRes}\;\text{v}\;\text{arity},\;\text{e}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{|}{}\<[5E]%
\>[8]{}\text{otherwise}{}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{emptyArityRes},\;\text{e}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityAnal}\;\text{arity}\;{}\<[22]%
\>[22]{}\text{int}\;{}\<[27]%
\>[27]{}(\text{Lam}\;\text{v}\;\text{e})\mathrel{|}\text{not}\;(\text{isId}\;\text{v}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}\text{second}\;(\text{Lam}\;\text{v})\mathbin{\$}\text{callArityAnal}\;\text{arity}\;(\text{int}\mathbin{`\text{delVarSet}`}\text{v})\;\text{e}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityAnal}\;0\;{}\<[22]%
\>[22]{}\text{int}\;{}\<[27]%
\>[27]{}(\text{Lam}\;\text{v}\;\text{e}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{ae'},\;\text{Lam}\;\text{v}\;\text{e'}){}\<[E]%
\\
\>[B]{}~~{}\<[3]%
\>[3]{}\text{\hkw{where}}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}(\text{ae},\;\text{e'}){}\<[16]%
\>[16]{}\mathrel{=}\text{callArityAnal}\;0\;(\text{int}\mathbin{`\text{delVarSet}`}\text{v})\;\text{e}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{ae'}{}\<[16]%
\>[16]{}\mathrel{=}\text{calledMultipleTimes}\;\text{ae}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityAnal}\;\text{arity}\;{}\<[22]%
\>[22]{}\text{int}\;{}\<[27]%
\>[27]{}(\text{Lam}\;\text{v}\;\text{e}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{ae},\;\text{Lam}\;\text{v}\;\text{e'}){}\<[E]%
\\
\>[B]{}~~{}\<[3]%
\>[3]{}\text{\hkw{where}}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}(\text{ae},\;\text{e'})\mathrel{=}\text{callArityAnal}\;(\text{arity}\mathbin{-}1)\;(\text{int}\mathbin{`\text{delVarSet}`}\text{v})\;\text{e}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityAnal}\;\text{arity}\;{}\<[22]%
\>[22]{}\text{int}\;{}\<[27]%
\>[27]{}(\text{App}\;\text{e}\;(\text{Type}\;\text{t})){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}\text{second}\;(\lambda \text{e}\rightarrow \text{App}\;\text{e}\;(\text{Type}\;\text{t}))\mathbin{\$}\text{callArityAnal}\;\text{arity}\;\text{int}\;\text{e}{}\<[E]%
\\
\>[B]{}\text{callArityAnal}\;\text{arity}\;\text{int}\;(\text{App}\;\text{e1}\;\text{e2}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{final\char95 ae},\;\text{App}\;\text{e1'}\;\text{e2'}){}\<[E]%
\\
\>[B]{}~~{}\<[3]%
\>[3]{}\text{\hkw{where}}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}(\text{ae1},\;\text{e1'}){}\<[18]%
\>[18]{}\mathrel{=}\text{callArityAnal}\;(\text{arity}\mathbin{+}1)\;{}\<[47]%
\>[47]{}\text{int}\;\text{e1}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}(\text{ae2},\;\text{e2'}){}\<[18]%
\>[18]{}\mathrel{=}\text{callArityAnal}\;0\;{}\<[47]%
\>[47]{}\text{int}\;\text{e2}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{ae2'}{}\<[12]%
\>[12]{}\mathrel{|}\text{exprIsTrivial}\;\text{e2}{}\<[32]%
\>[32]{}\mathrel{=}\text{calledMultipleTimes}\;\text{ae2}{}\<[E]%
\\
\>[12]{}\mathrel{|}\text{otherwise}{}\<[32]%
\>[32]{}\mathrel{=}\text{ae2}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{final\char95 ae}{}\<[18]%
\>[18]{}\mathrel{=}\text{ae1}\mathbin{`\text{both}`}\text{ae2'}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityAnal}\;\text{arity}\;{}\<[22]%
\>[22]{}\text{int}\;{}\<[27]%
\>[27]{}(\text{Case}\;\text{scrut}\;\text{bndr}\;\text{ty}\;\text{alts}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{final\char95 ae},\;\text{Case}\;\text{scrut'}\;\text{bndr}\;\text{ty}\;\text{alts'}){}\<[E]%
\\
\>[B]{}~~{}\<[3]%
\>[3]{}\text{\hkw{where}}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}(\text{alt\char95 aes},\;\text{alts'}){}\<[26]%
\>[26]{}\mathrel{=}{}\<[26E]%
\>[29]{}\text{unzip}\mathbin{\$}\text{map}\;\text{go}\;\text{alts}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{go}\;(\text{dc},\;\text{bndrs},\;\text{e}){}\<[26]%
\>[26]{}\mathrel{=}{}\<[26E]%
\>[29]{}\text{\hkw{let}}\;(\text{ae},\;\text{e'})\mathrel{=}\text{callArityAnal}\;\text{arity}\;\text{int}\;\text{e}{}\<[E]%
\\
\>[29]{}\text{\hkw{in}}\;(\text{ae},\;(\text{dc},\;\text{bndrs},\;\text{e'})){}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{alt\char95 ae}{}\<[26]%
\>[26]{}\mathrel{=}{}\<[26E]%
\>[29]{}\text{lubRess}\;\text{alt\char95 aes}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}(\text{scrut\char95 ae},\;\text{scrut'}){}\<[26]%
\>[26]{}\mathrel{=}{}\<[26E]%
\>[29]{}\text{callArityAnal}\;0\;\text{int}\;\text{scrut}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{final\char95 ae}{}\<[26]%
\>[26]{}\mathrel{=}{}\<[26E]%
\>[29]{}\text{scrut\char95 ae}\mathbin{`\text{both}`}\text{alt\char95 ae}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityAnal}\;\text{arity}\;{}\<[22]%
\>[22]{}\text{int}\;{}\<[27]%
\>[27]{}(\text{Let}\;\text{bind}\;\text{e}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{final\char95 ae},\;\text{Let}\;\text{bind'}\;\text{e'}){}\<[E]%
\\
\>[B]{}~~{}\<[3]%
\>[3]{}\text{\hkw{where}}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{int\char95 body}{}\<[26]%
\>[26]{}\mathrel{=}{}\<[26E]%
\>[29]{}\text{int}\mathbin{`\text{addInterestingBinds}`}\text{bind}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}(\text{ae\char95 body},\;\text{e'}){}\<[26]%
\>[26]{}\mathrel{=}{}\<[26E]%
\>[29]{}\text{callArityAnal}\;\text{arity}\;\text{int\char95 body}\;\text{e}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}(\text{final\char95 ae},\;\text{bind'}){}\<[26]%
\>[26]{}\mathrel{=}{}\<[26E]%
\>[29]{}\text{callArityBind}\;(\text{boringBinds}\;\text{bind})\;\text{ae\char95 body}\;\text{int}\;\text{bind}{}\<[E]%
\ColumnHook
\end{pboxed}
\)\par\noindent\endgroup\resethooks
\\
\begingroup\par\noindent
\haskellfont\(
\begin{pboxed}\SaveRestoreHook
\column{B}{@{}>{\hspre}l<{\hspost}@{}}%
\column{5}{@{}>{\hspre}c<{\hspost}@{}}%
\column{5E}{@{}l@{}}%
\column{8}{@{}>{\hspre}l<{\hspost}@{}}%
\column{14}{@{}>{\hspre}l<{\hspost}@{}}%
\column{34}{@{}>{\hspre}l<{\hspost}@{}}%
\column{E}{@{}>{\hspre}l<{\hspost}@{}}%
\>[B]{}\text{isInteresting}\mathbin{::}\text{Var}\rightarrow \text{Bool}{}\<[E]%
\\
\>[B]{}\text{isInteresting}\;\text{v}\mathrel{=}0\mathbin{<}\text{length}\;(\text{typeArity}\;(\text{idType}\;\text{v})){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{interestingBinds}\mathbin{::}\text{CoreBind}\rightarrow [\mskip1.5mu \text{Var}\mskip1.5mu]{}\<[E]%
\\
\>[B]{}\text{interestingBinds}\mathrel{=}\text{filter}\;\text{isInteresting}\mathbin{.}\text{bindersOf}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{boringBinds}\mathbin{::}\text{CoreBind}\rightarrow \text{VarSet}{}\<[E]%
\\
\>[B]{}\text{boringBinds}\mathrel{=}\text{mkVarSet}\mathbin{.}\text{filter}\;(\text{not}\mathbin{.}\text{isInteresting})\mathbin{.}\text{bindersOf}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{addInterestingBinds}\mathbin{::}\text{VarSet}\rightarrow \text{CoreBind}\rightarrow \text{VarSet}{}\<[E]%
\\
\>[B]{}\text{addInterestingBinds}\;\text{int}\;\text{bind}{}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}\text{int}{}\<[14]%
\>[14]{}\mathbin{`\text{delVarSetList}`}{}\<[34]%
\>[34]{}\text{bindersOf}\;\text{bind}{}\<[E]%
\\
\>[14]{}\mathbin{`\text{extendVarSetList}`}{}\<[34]%
\>[34]{}\text{interestingBinds}\;\text{bind}{}\<[E]%
\ColumnHook
\end{pboxed}
\)\par\noindent\endgroup\resethooks
\\
\begingroup\par\noindent
\haskellfont\(
\begin{pboxed}\SaveRestoreHook
\column{B}{@{}>{\hspre}l<{\hspost}@{}}%
\column{3}{@{}>{\hspre}l<{\hspost}@{}}%
\column{5}{@{}>{\hspre}c<{\hspost}@{}}%
\column{5E}{@{}l@{}}%
\column{6}{@{}>{\hspre}l<{\hspost}@{}}%
\column{8}{@{}>{\hspre}l<{\hspost}@{}}%
\column{10}{@{}>{\hspre}l<{\hspost}@{}}%
\column{12}{@{}>{\hspre}l<{\hspost}@{}}%
\column{13}{@{}>{\hspre}l<{\hspost}@{}}%
\column{14}{@{}>{\hspre}l<{\hspost}@{}}%
\column{15}{@{}>{\hspre}l<{\hspost}@{}}%
\column{16}{@{}>{\hspre}l<{\hspost}@{}}%
\column{17}{@{}>{\hspre}l<{\hspost}@{}}%
\column{18}{@{}>{\hspre}l<{\hspost}@{}}%
\column{22}{@{}>{\hspre}l<{\hspost}@{}}%
\column{24}{@{}>{\hspre}l<{\hspost}@{}}%
\column{30}{@{}>{\hspre}l<{\hspost}@{}}%
\column{32}{@{}>{\hspre}l<{\hspost}@{}}%
\column{34}{@{}>{\hspre}l<{\hspost}@{}}%
\column{37}{@{}>{\hspre}l<{\hspost}@{}}%
\column{41}{@{}>{\hspre}c<{\hspost}@{}}%
\column{41E}{@{}l@{}}%
\column{44}{@{}>{\hspre}l<{\hspost}@{}}%
\column{51}{@{}>{\hspre}l<{\hspost}@{}}%
\column{53}{@{}>{\hspre}l<{\hspost}@{}}%
\column{54}{@{}>{\hspre}l<{\hspost}@{}}%
\column{E}{@{}>{\hspre}l<{\hspost}@{}}%
\>[B]{}\text{callArityBind}\mathbin{::}{}\<[E]%
\\
\>[B]{}~~{}\<[6]%
\>[6]{}\text{VarSet}\rightarrow \text{CallArityRes}\rightarrow \text{VarSet}\rightarrow \text{CoreBind}\rightarrow {}\<[E]%
\\
\>[B]{}~~{}\<[6]%
\>[6]{}(\text{CallArityRes},\;\text{CoreBind}){}\<[E]%
\\
\>[B]{}\text{callArityBind}\;\text{boring\char95 vars}\;\text{ae\char95 body}\;\text{int}\;(\text{NonRec}\;\text{v}\;\text{rhs}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{|}{}\<[5E]%
\>[8]{}\text{otherwise}{}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{final\char95 ae},\;\text{NonRec}\;\text{v'}\;\text{rhs'}){}\<[E]%
\\
\>[B]{}~~{}\<[3]%
\>[3]{}\text{\hkw{where}}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{is\char95 thunk}\mathrel{=}\text{not}\;(\text{exprIsHNF}\;\text{rhs}){}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{boring}\mathrel{=}\text{v}\mathbin{`\text{elemVarSet}`}\text{boring\char95 vars}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}(\text{arity},\;\text{called\char95 once}){}\<[E]%
\\
\>[6]{}~~{}\<[18]%
\>[18]{}\mathrel{|}\text{boring}{}\<[37]%
\>[37]{}\mathrel{=}(0,\;\text{False}){}\<[E]%
\\
\>[6]{}~~{}\<[18]%
\>[18]{}\mathrel{|}\text{otherwise}{}\<[37]%
\>[37]{}\mathrel{=}\text{lookupCallArityRes}\;\text{ae\char95 body}\;\text{v}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{safe\char95 arity}{}\<[18]%
\>[18]{}\mathrel{|}\text{called\char95 once}{}\<[37]%
\>[37]{}\mathrel{=}\text{arity}{}\<[E]%
\\
\>[18]{}\mathrel{|}\text{is\char95 thunk}{}\<[37]%
\>[37]{}\mathrel{=}0{}\<[E]%
\\
\>[18]{}\mathrel{|}\text{otherwise}{}\<[37]%
\>[37]{}\mathrel{=}\text{arity}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{trimmed\char95 arity}\mathrel{=}\text{trimArity}\;\text{v}\;\text{safe\char95 arity}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}(\text{ae\char95 rhs},\;\text{rhs'})\mathrel{=}\text{callArityAnal}\;\text{trimmed\char95 arity}\;\text{int}\;\text{rhs}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{ae\char95 rhs'}{}\<[18]%
\>[18]{}\mathrel{|}\text{called\char95 once}{}\<[37]%
\>[37]{}\mathrel{=}\text{ae\char95 rhs}{}\<[E]%
\\
\>[18]{}\mathrel{|}\text{safe\char95 arity}\mathbin{==}0{}\<[37]%
\>[37]{}\mathrel{=}\text{ae\char95 rhs}{}\<[E]%
\\
\>[18]{}\mathrel{|}\text{otherwise}{}\<[37]%
\>[37]{}\mathrel{=}\text{calledMultipleTimes}\;\text{ae\char95 rhs}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{called\char95 by\char95 v}\mathrel{=}\text{domRes}\;\text{ae\char95 rhs'}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{called\char95 with\char95 v}{}\<[E]%
\\
\>[6]{}~~{}\<[18]%
\>[18]{}\mathrel{|}\text{boring}{}\<[37]%
\>[37]{}\mathrel{=}\text{domRes}\;\text{ae\char95 body}{}\<[E]%
\\
\>[6]{}~~{}\<[18]%
\>[18]{}\mathrel{|}\text{otherwise}{}\<[37]%
\>[37]{}\mathrel{=}\text{calledWith}\;\text{ae\char95 body}\;\text{v}\mathbin{`\text{delUnVarSet}`}\text{v}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{final\char95 ae}{}\<[E]%
\\
\>[6]{}~~{}\<[10]%
\>[10]{}\mathrel{=}\text{addCrossCoCalls}\;\text{called\char95 by\char95 v}\;\text{called\char95 with\char95 v}{}\<[E]%
\\
\>[10]{}~~{}\<[14]%
\>[14]{}\mathbin{\$}\text{ae\char95 rhs'}\mathbin{`\text{lubRes}`}\text{resDel}\;\text{v}\;\text{ae\char95 body}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{v'}\mathrel{=}\text{v}\mathbin{`\text{setIdCallArity}`}\text{trimmed\char95 arity}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{callArityBind}\;\text{boring\char95 vars}\;\text{ae\char95 body}\;\text{int}\;\text{b}\mathord{@}(\text{Rec}\;\text{binds}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[5E]%
\>[8]{}(\text{final\char95 ae},\;\text{Rec}\;\text{binds'}){}\<[E]%
\\
\>[B]{}~~{}\<[3]%
\>[3]{}\text{\hkw{where}}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{any\char95 boring}{}\<[24]%
\>[24]{}\mathrel{=}\text{any}\;(\mathbin{`\text{elemVarSet}`}\text{boring\char95 vars})\;[\mskip1.5mu \text{i}\mathrel{|}(\text{i},\;\text{\char95 })\leftarrow \text{binds}\mskip1.5mu]{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{int\char95 body}{}\<[24]%
\>[24]{}\mathrel{=}\text{int}\mathbin{`\text{addInterestingBinds}`}\text{b}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}(\text{ae\char95 rhs},\;\text{binds'}){}\<[24]%
\>[24]{}\mathrel{=}\text{fix}\;\text{initial\char95 binds}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{final\char95 ae}{}\<[24]%
\>[24]{}\mathrel{=}\text{bindersOf}\;\text{b}\mathbin{`\text{resDelList}`}\text{ae\char95 rhs}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{initial\char95 binds}{}\<[24]%
\>[24]{}\mathrel{=}[\mskip1.5mu (\text{i},\;\text{Nothing},\;\text{e})\mathrel{|}(\text{i},\;\text{e})\leftarrow \text{binds}\mskip1.5mu]{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{fix}\mathbin{::}{}\<[16]%
\>[16]{}[\mskip1.5mu (\text{Id},\;\text{Maybe}\;(\text{Bool},\;\text{Arity},\;\text{CallArityRes}),\;\text{CoreExpr})\mskip1.5mu]\rightarrow {}\<[E]%
\\
\>[16]{}(\text{CallArityRes},\;[\mskip1.5mu (\text{Id},\;\text{CoreExpr})\mskip1.5mu]){}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{fix}\;\text{ann\char95 binds}{}\<[E]%
\\
\>[6]{}~~{}\<[10]%
\>[10]{}\mathrel{|}{}\<[13]%
\>[13]{}\text{any\char95 change}{}\<[E]%
\\
\>[6]{}~~{}\<[10]%
\>[10]{}\mathrel{=}{}\<[13]%
\>[13]{}\text{fix}\;\text{ann\char95 binds'}{}\<[E]%
\\
\>[6]{}~~{}\<[10]%
\>[10]{}\mathrel{|}{}\<[13]%
\>[13]{}\text{otherwise}{}\<[E]%
\\
\>[6]{}~~{}\<[10]%
\>[10]{}\mathrel{=}{}\<[13]%
\>[13]{}(\text{ae},\;\text{map}\;(\lambda (\text{i},\;\text{\char95 },\;\text{e})\rightarrow (\text{i},\;\text{e}))\;\text{ann\char95 binds'}){}\<[E]%
\\
\>[6]{}~~{}\<[8]%
\>[8]{}\text{\hkw{where}}{}\<[E]%
\\
\>[8]{}~~{}\<[10]%
\>[10]{}\text{aes\char95 old}\mathrel{=}[\mskip1.5mu (\text{i},\;\text{ae})\mathrel{|}(\text{i},\;\text{Just}\;(\text{\char95 },\;\text{\char95 },\;\text{ae}),\;\text{\char95 })\leftarrow \text{ann\char95 binds}\mskip1.5mu]{}\<[E]%
\\
\>[8]{}~~{}\<[10]%
\>[10]{}\text{ae}\mathrel{=}\text{callArityRecEnv}\;\text{any\char95 boring}\;\text{aes\char95 old}\;\text{ae\char95 body}{}\<[E]%
\\[\blanklineskip]%
\>[8]{}~~{}\<[10]%
\>[10]{}\text{rerun}\;(\text{i},\;\text{mbLastRun},\;\text{rhs}){}\<[E]%
\\
\>[10]{}~~{}\<[14]%
\>[14]{}\mathrel{|}{}\<[17]%
\>[17]{}\text{i}\mathbin{`\text{elemVarSet}`}\text{int\char95 body}\mathbin{\&\&}{}\<[E]%
\\
\>[17]{}\text{not}\;(\text{i}\mathbin{`\text{elemUnVarSet}`}\text{domRes}\;\text{ae}){}\<[E]%
\\
\>[10]{}~~{}\<[14]%
\>[14]{}\mathrel{=}{}\<[17]%
\>[17]{}(\text{False},\;(\text{i},\;\text{Nothing},\;\text{rhs})){}\<[E]%
\\[\blanklineskip]%
\>[10]{}~~{}\<[14]%
\>[14]{}\mathrel{|}{}\<[17]%
\>[17]{}\text{Just}\;(\text{old\char95 called\char95 once},\;\text{old\char95 arity},\;\text{\char95 })\leftarrow \text{mbLastRun}{}\<[E]%
\\
\>[10]{}~~{}\<[14]%
\>[14]{},\;{}\<[17]%
\>[17]{}\text{called\char95 once}\mathbin{==}\text{old\char95 called\char95 once}{}\<[E]%
\\
\>[10]{}~~{}\<[14]%
\>[14]{},\;{}\<[17]%
\>[17]{}\text{new\char95 arity}\mathbin{==}\text{old\char95 arity}{}\<[E]%
\\
\>[10]{}~~{}\<[14]%
\>[14]{}\mathrel{=}{}\<[17]%
\>[17]{}(\text{False},\;(\text{i},\;\text{mbLastRun},\;\text{rhs})){}\<[E]%
\\[\blanklineskip]%
\>[10]{}~~{}\<[14]%
\>[14]{}\mathrel{|}{}\<[17]%
\>[17]{}\text{otherwise}{}\<[E]%
\\
\>[10]{}~~{}\<[14]%
\>[14]{}\mathrel{=}{}\<[17]%
\>[17]{}\text{\hkw{let}}\;{}\<[22]%
\>[22]{}\text{is\char95 thunk}\mathrel{=}\text{not}\;(\text{exprIsHNF}\;\text{rhs}){}\<[E]%
\\[\blanklineskip]%
\>[22]{}\text{safe\char95 arity}{}\<[34]%
\>[34]{}\mathrel{|}\text{is\char95 thunk}{}\<[53]%
\>[53]{}\mathrel{=}0{}\<[E]%
\\
\>[34]{}\mathrel{|}\text{otherwise}{}\<[53]%
\>[53]{}\mathrel{=}\text{new\char95 arity}{}\<[E]%
\\[\blanklineskip]%
\>[22]{}\text{trimmed\char95 arity}\mathrel{=}\text{trimArity}\;\text{i}\;\text{safe\char95 arity}{}\<[E]%
\\[\blanklineskip]%
\>[22]{}(\text{ae\char95 rhs},\;\text{rhs'})\mathrel{=}\text{callArityAnal}\;{}\<[54]%
\>[54]{}\text{trimmed\char95 arity}\;{}\<[E]%
\\
\>[54]{}\text{int\char95 body}\;\text{rhs}{}\<[E]%
\\[\blanklineskip]%
\>[22]{}\text{ae\char95 rhs'}{}\<[32]%
\>[32]{}\mathrel{|}\text{called\char95 once}{}\<[51]%
\>[51]{}\mathrel{=}\text{ae\char95 rhs}{}\<[E]%
\\
\>[32]{}\mathrel{|}\text{safe\char95 arity}\mathbin{==}0{}\<[51]%
\>[51]{}\mathrel{=}\text{ae\char95 rhs}{}\<[E]%
\\
\>[32]{}\mathrel{|}\text{otherwise}{}\<[51]%
\>[51]{}\mathrel{=}\text{calledMultipleTimes}\;\text{ae\char95 rhs}{}\<[E]%
\\[\blanklineskip]%
\>[17]{}\text{\hkw{in}}\;(\text{True},\;({}\<[30]%
\>[30]{}\text{i}\mathbin{`\text{setIdCallArity}`}\text{trimmed\char95 arity},\;{}\<[E]%
\\
\>[30]{}\text{Just}\;(\text{called\char95 once},\;\text{new\char95 arity},\;\text{ae\char95 rhs'}),\;\text{rhs'})){}\<[E]%
\\
\>[10]{}~~{}\<[12]%
\>[12]{}\text{\hkw{where}}{}\<[E]%
\\
\>[12]{}~~{}\<[15]%
\>[15]{}(\text{new\char95 arity},\;\text{called\char95 once}){}\<[41]%
\>[41]{}\mathrel{|}{}\<[41E]%
\>[44]{}\text{i}\mathbin{`\text{elemVarSet}`}\text{boring\char95 vars}{}\<[E]%
\\
\>[41]{}\mathrel{=}{}\<[41E]%
\>[44]{}(0,\;\text{False}){}\<[E]%
\\
\>[41]{}\mathrel{|}{}\<[41E]%
\>[44]{}\text{otherwise}{}\<[E]%
\\
\>[41]{}\mathrel{=}{}\<[41E]%
\>[44]{}\text{lookupCallArityRes}\;\text{ae}\;\text{i}{}\<[E]%
\\[\blanklineskip]%
\>[8]{}~~{}\<[10]%
\>[10]{}(\text{changes},\;\text{ann\char95 binds'})\mathrel{=}\text{unzip}\mathbin{\$}\text{map}\;\text{rerun}\;\text{ann\char95 binds}{}\<[E]%
\\
\>[8]{}~~{}\<[10]%
\>[10]{}\text{any\char95 change}\mathrel{=}\text{or}\;\text{changes}{}\<[E]%
\ColumnHook
\end{pboxed}
\)\par\noindent\endgroup\resethooks
\\
\begingroup\par\noindent
\haskellfont\(
\begin{pboxed}\SaveRestoreHook
\column{B}{@{}>{\hspre}l<{\hspost}@{}}%
\column{3}{@{}>{\hspre}l<{\hspost}@{}}%
\column{5}{@{}>{\hspre}l<{\hspost}@{}}%
\column{6}{@{}>{\hspre}l<{\hspost}@{}}%
\column{8}{@{}>{\hspre}l<{\hspost}@{}}%
\column{10}{@{}>{\hspre}c<{\hspost}@{}}%
\column{10E}{@{}l@{}}%
\column{11}{@{}>{\hspre}l<{\hspost}@{}}%
\column{13}{@{}>{\hspre}l<{\hspost}@{}}%
\column{15}{@{}>{\hspre}l<{\hspost}@{}}%
\column{24}{@{}>{\hspre}c<{\hspost}@{}}%
\column{24E}{@{}l@{}}%
\column{27}{@{}>{\hspre}l<{\hspost}@{}}%
\column{30}{@{}>{\hspre}l<{\hspost}@{}}%
\column{34}{@{}>{\hspre}l<{\hspost}@{}}%
\column{E}{@{}>{\hspre}l<{\hspost}@{}}%
\>[B]{}\text{callArityRecEnv}\mathbin{::}{}\<[E]%
\\
\>[B]{}~~{}\<[6]%
\>[6]{}\text{Bool}\rightarrow [\mskip1.5mu (\text{Var},\;\text{CallArityRes})\mskip1.5mu]\rightarrow \text{CallArityRes}\rightarrow \text{CallArityRes}{}\<[E]%
\\
\>[B]{}\text{callArityRecEnv}\;\text{any\char95 boring}\;\text{ae\char95 rhss}\;\text{ae\char95 body}{}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}\text{ae\char95 new}{}\<[E]%
\\
\>[B]{}~~{}\<[3]%
\>[3]{}\text{\hkw{where}}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{vars}\mathrel{=}\text{map}\;\text{fst}\;\text{ae\char95 rhss}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{ae\char95 combined}\mathrel{=}\text{lubRess}\;(\text{map}\;\text{snd}\;\text{ae\char95 rhss})\mathbin{`\text{lubRes}`}\text{ae\char95 body}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{cross\char95 calls}{}\<[E]%
\\
\>[6]{}~~{}\<[10]%
\>[10]{}\mathrel{|}{}\<[10E]%
\>[13]{}\text{any\char95 boring}{}\<[34]%
\>[34]{}\mathrel{=}\text{completeGraph}\;(\text{domRes}\;\text{ae\char95 combined}){}\<[E]%
\\
\>[6]{}~~{}\<[10]%
\>[10]{}\mathrel{|}{}\<[10E]%
\>[13]{}\text{length}\;\text{ae\char95 rhss}\mathbin{>}25{}\<[34]%
\>[34]{}\mathrel{=}\text{completeGraph}\;(\text{domRes}\;\text{ae\char95 combined}){}\<[E]%
\\
\>[6]{}~~{}\<[10]%
\>[10]{}\mathrel{|}{}\<[10E]%
\>[13]{}\text{otherwise}{}\<[34]%
\>[34]{}\mathrel{=}\text{unionUnVarGraphs}\mathbin{\$}\text{map}\;\text{cross\char95 call}\;\text{ae\char95 rhss}{}\<[E]%
\\
\>[3]{}~~{}\<[6]%
\>[6]{}\text{cross\char95 call}\;(\text{v},\;\text{ae\char95 rhs}){}\<[E]%
\\
\>[6]{}~~{}\<[10]%
\>[10]{}\mathrel{=}{}\<[10E]%
\>[13]{}\text{completeBipartiteGraph}\;\text{called\char95 by\char95 v}\;\text{called\char95 with\char95 v}{}\<[E]%
\\
\>[6]{}~~{}\<[8]%
\>[8]{}\text{\hkw{where}}{}\<[E]%
\\
\>[8]{}~~{}\<[11]%
\>[11]{}\text{is\char95 thunk}\mathrel{=}\text{idCallArity}\;\text{v}\mathbin{==}0{}\<[E]%
\\[\blanklineskip]%
\>[8]{}~~{}\<[11]%
\>[11]{}\text{ae\char95 before\char95 v}{}\<[24]%
\>[24]{}\mathrel{|}{}\<[24E]%
\>[27]{}\text{is\char95 thunk}{}\<[E]%
\\
\>[24]{}\mathrel{=}{}\<[24E]%
\>[27]{}\text{lubRess}\;(\text{map}\;\text{snd}\mathbin{\$}\text{filter}\;((\mathbin{/=}\text{v})\mathbin{.}\text{fst})\;\text{ae\char95 rhss}){}\<[E]%
\\
\>[27]{}~~{}\<[30]%
\>[30]{}\mathbin{`\text{lubRes}`}\text{ae\char95 body}{}\<[E]%
\\
\>[24]{}\mathrel{|}{}\<[24E]%
\>[27]{}\text{otherwise}{}\<[E]%
\\
\>[24]{}\mathrel{=}{}\<[24E]%
\>[27]{}\text{ae\char95 combined}{}\<[E]%
\\[\blanklineskip]%
\>[8]{}~~{}\<[11]%
\>[11]{}\text{called\char95 with\char95 v}{}\<[E]%
\\
\>[11]{}~~{}\<[15]%
\>[15]{}\mathrel{=}\text{unionUnVarSets}\mathbin{\$}\text{map}\;(\text{calledWith}\;\text{ae\char95 before\char95 v})\;\text{vars}{}\<[E]%
\\
\>[8]{}~~{}\<[11]%
\>[11]{}\text{called\char95 by\char95 v}\mathrel{=}\text{domRes}\;\text{ae\char95 rhs}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[6]%
\>[6]{}\text{ae\char95 new}\mathrel{=}\text{first}\;(\text{cross\char95 calls}\mathbin{`\text{unionUnVarGraph}`})\;\text{ae\char95 combined}{}\<[E]%
\ColumnHook
\end{pboxed}
\)\par\noindent\endgroup\resethooks
\\
\begingroup\par\noindent
\haskellfont\(
\begin{pboxed}\SaveRestoreHook
\column{B}{@{}>{\hspre}l<{\hspost}@{}}%
\column{3}{@{}>{\hspre}l<{\hspost}@{}}%
\column{5}{@{}>{\hspre}l<{\hspost}@{}}%
\column{9}{@{}>{\hspre}c<{\hspost}@{}}%
\column{9E}{@{}l@{}}%
\column{12}{@{}>{\hspre}l<{\hspost}@{}}%
\column{E}{@{}>{\hspre}l<{\hspost}@{}}%
\>[B]{}\text{trimArity}\mathbin{::}\text{Id}\rightarrow \text{Arity}\rightarrow \text{Arity}{}\<[E]%
\\
\>[B]{}\text{trimArity}\;\text{v}\;\text{a}\mathrel{=}\text{minimum}\;[\mskip1.5mu \text{a},\;\text{max\char95 arity\char95 by\char95 type},\;\text{max\char95 arity\char95 by\char95 strsig}\mskip1.5mu]{}\<[E]%
\\
\>[B]{}~~{}\<[3]%
\>[3]{}\text{\hkw{where}}{}\<[E]%
\\
\>[3]{}~~{}\<[5]%
\>[5]{}\text{max\char95 arity\char95 by\char95 type}\mathrel{=}\text{length}\;(\text{typeArity}\;(\text{idType}\;\text{v})){}\<[E]%
\\
\>[3]{}~~{}\<[5]%
\>[5]{}\text{max\char95 arity\char95 by\char95 strsig}{}\<[E]%
\\
\>[5]{}~~{}\<[9]%
\>[9]{}\mathrel{|}{}\<[9E]%
\>[12]{}\text{isBotRes}\;\text{result\char95 info}\mathrel{=}\text{length}\;\text{demands}{}\<[E]%
\\
\>[5]{}~~{}\<[9]%
\>[9]{}\mathrel{|}{}\<[9E]%
\>[12]{}\text{otherwise}\mathrel{=}\text{a}{}\<[E]%
\\[\blanklineskip]%
\>[3]{}~~{}\<[5]%
\>[5]{}(\text{demands},\;\text{result\char95 info})\mathrel{=}\text{splitStrictSig}\;(\text{idStrictness}\;\text{v}){}\<[E]%
\ColumnHook
\end{pboxed}
\)\par\noindent\endgroup\resethooks
\\
\begingroup\par\noindent
\haskellfont\(
\begin{pboxed}\SaveRestoreHook
\column{B}{@{}>{\hspre}l<{\hspost}@{}}%
\column{5}{@{}>{\hspre}l<{\hspost}@{}}%
\column{8}{@{}>{\hspre}l<{\hspost}@{}}%
\column{10}{@{}>{\hspre}l<{\hspost}@{}}%
\column{19}{@{}>{\hspre}l<{\hspost}@{}}%
\column{E}{@{}>{\hspre}l<{\hspost}@{}}%
\>[B]{}\text{\hkw{type}}\;\text{CallArityRes}\mathrel{=}(\text{UnVarGraph},\;\text{VarEnv}\;\text{Arity}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{emptyArityRes}\mathbin{::}\text{CallArityRes}{}\<[E]%
\\
\>[B]{}\text{emptyArityRes}\mathrel{=}(\text{emptyUnVarGraph},\;\text{emptyVarEnv}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{unitArityRes}\mathbin{::}\text{Var}\rightarrow \text{Arity}\rightarrow \text{CallArityRes}{}\<[E]%
\\
\>[B]{}\text{unitArityRes}\;\text{v}\;\text{arity}\mathrel{=}(\text{emptyUnVarGraph},\;\text{unitVarEnv}\;\text{v}\;\text{arity}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{resDelList}\mathbin{::}[\mskip1.5mu \text{Var}\mskip1.5mu]\rightarrow \text{CallArityRes}\rightarrow \text{CallArityRes}{}\<[E]%
\\
\>[B]{}\text{resDelList}\;\text{vs}\;\text{ae}\mathrel{=}\text{foldr}\;\text{resDel}\;\text{ae}\;\text{vs}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{resDel}\mathbin{::}\text{Var}\rightarrow \text{CallArityRes}\rightarrow \text{CallArityRes}{}\<[E]%
\\
\>[B]{}\text{resDel}\;\text{v}\;(\text{g},\;\text{ae})\mathrel{=}(\text{g}\mathbin{`\text{delNode}`}\text{v},\;\text{ae}\mathbin{`\text{delVarEnv}`}\text{v}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{domRes}\mathbin{::}\text{CallArityRes}\rightarrow \text{UnVarSet}{}\<[E]%
\\
\>[B]{}\text{domRes}\;(\text{\char95 },\;\text{ae})\mathrel{=}\text{varEnvDom}\;\text{ae}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{lookupCallArityRes}\mathbin{::}\text{CallArityRes}\rightarrow \text{Var}\rightarrow (\text{Arity},\;\text{Bool}){}\<[E]%
\\
\>[B]{}\text{lookupCallArityRes}\;(\text{g},\;\text{ae})\;\text{v}{}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}{}\<[8]%
\>[8]{}\text{\hkw{case}}\;\text{lookupVarEnv}\;\text{ae}\;\text{v}\;\text{\hkw{of}}{}\<[E]%
\\
\>[8]{}~~{}\<[10]%
\>[10]{}\text{Just}\;\text{a}{}\<[19]%
\>[19]{}\rightarrow (\text{a},\;\text{not}\;(\text{v}\mathbin{`\text{elemUnVarSet}`}(\text{neighbors}\;\text{g}\;\text{v}))){}\<[E]%
\\
\>[8]{}~~{}\<[10]%
\>[10]{}\text{Nothing}{}\<[19]%
\>[19]{}\rightarrow (0,\;\text{False}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{calledWith}\mathbin{::}\text{CallArityRes}\rightarrow \text{Var}\rightarrow \text{UnVarSet}{}\<[E]%
\\
\>[B]{}\text{calledWith}\;(\text{g},\;\text{\char95 })\;\text{v}\mathrel{=}\text{neighbors}\;\text{g}\;\text{v}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{addCrossCoCalls}\mathbin{::}\text{UnVarSet}\rightarrow \text{UnVarSet}\rightarrow \text{CallArityRes}\rightarrow \text{CallArityRes}{}\<[E]%
\\
\>[B]{}\text{addCrossCoCalls}\;\text{set1}\;\text{set2}{}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}\text{first}\;(\text{completeBipartiteGraph}\;\text{set1}\;\text{set2}\mathbin{`\text{unionUnVarGraph}`}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{calledMultipleTimes}\mathbin{::}\text{CallArityRes}\rightarrow \text{CallArityRes}{}\<[E]%
\\
\>[B]{}\text{calledMultipleTimes}\;\text{res}{}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}\text{first}\;(\text{const}\;(\text{completeGraph}\;(\text{domRes}\;\text{res})))\;\text{res}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{both}\mathbin{::}\text{CallArityRes}\rightarrow \text{CallArityRes}\rightarrow \text{CallArityRes}{}\<[E]%
\\
\>[B]{}\text{both}\;\text{r1}\;\text{r2}{}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}\text{addCrossCoCalls}\;(\text{domRes}\;\text{r1})\;(\text{domRes}\;\text{r2})\mathbin{\$}\text{r1}\mathbin{`\text{lubRes}`}\text{r2}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{lubRes}\mathbin{::}\text{CallArityRes}\rightarrow \text{CallArityRes}\rightarrow \text{CallArityRes}{}\<[E]%
\\
\>[B]{}\text{lubRes}\;(\text{g1},\;\text{ae1})\;(\text{g2},\;\text{ae2}){}\<[E]%
\\
\>[B]{}~~{}\<[5]%
\>[5]{}\mathrel{=}(\text{g1}\mathbin{`\text{unionUnVarGraph}`}\text{g2},\;\text{ae1}\mathbin{`\text{lubArityEnv}`}\text{ae2}){}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{lubArityEnv}\mathbin{::}\text{VarEnv}\;\text{Arity}\rightarrow \text{VarEnv}\;\text{Arity}\rightarrow \text{VarEnv}\;\text{Arity}{}\<[E]%
\\
\>[B]{}\text{lubArityEnv}\mathrel{=}\text{plusVarEnv\char95 C}\;\text{min}{}\<[E]%
\\[\blanklineskip]%
\>[B]{}\text{lubRess}\mathbin{::}[\mskip1.5mu \text{CallArityRes}\mskip1.5mu]\rightarrow \text{CallArityRes}{}\<[E]%
\\
\>[B]{}\text{lubRess}\mathrel{=}\text{foldl}\;\text{lubRes}\;\text{emptyArityRes}{}\<[E]%
\ColumnHook
\end{pboxed}
\)\par\noindent\endgroup\resethooks
