%%
%% Calculi names.
%%
\newcommand{\Links}{Links\xspace}
\newcommand{\CoreLinks}{\ensuremath{\mathsf{CoreLinks}}\xspace}
\newcommand{\BCalc}{\ensuremath{\lambda_{\mathsf{b}}}\xspace}
\newcommand{\BCalcRec}{\ensuremath{\lambda_{\mathsf{b}+\mathsf{rec}}}\xspace}

%%
%% Calculi terms and types type-setting.
%%
\newcommand{\revto}{\ensuremath{\leftarrow}}

\newcommand{\dec}[1]{\mathsf{#1}}
\newcommand{\keyw}[1]{\mathbf{#1}}
\newcommand{\Handle}{\keyw{handle}}
\newcommand{\ShallowHandle}{\ensuremath{\keyw{handle}^\dagger}}
\newcommand{\With}{\keyw{with}}
\newcommand{\Let}{\keyw{let}}
\newcommand{\Rec}{\keyw{rec}}
\newcommand{\In}{\keyw{in}}
\newcommand{\Do}{\keyw{do}}
\newcommand{\Return}{\keyw{return}}
\newcommand{\Val}{\keyw{val}}
\newcommand{\Case}{\keyw{case}}
\newcommand{\If}{\keyw{if}}
\newcommand{\Then}{\keyw{then}}
\newcommand{\Else}{\keyw{else}}
\newcommand{\Absurd}{\keyw{absurd}}
\newcommand{\Record}[1]{\ensuremath{\langle #1 \rangle}}
\newcommand{\Unit}{\Record{}}
\newcommand{\Inl}{\keyw{inl}}
\newcommand{\Inr}{\keyw{inr}}
\newcommand{\Thunk}{\lambda \Unit.}

\newcommand{\Pre}[1]{\mathsf{Pre}(#1)}
\newcommand{\Abs}{\mathsf{Abs}}
\newcommand{\Presence}{\mathsf{Presence}}
\newcommand{\Row}{\mathsf{Row}}
\newcommand{\Type}{\mathsf{Type}}
\newcommand{\Ground}{\mathsf{ground}}

\newcommand{\Comp}{\mathsf{Comp}}
\newcommand{\Effect}{\mathsf{Effect}}
\newcommand{\Handler}{\mathsf{Handler}}

\newcommand{\ZeroType}{0}
\newcommand{\UnitType}{1}
\newcommand{\One}{1}
\newcommand{\Int}{\mathsf{Int}}
\newcommand{\Bool}{\mathsf{Bool}}
\newcommand{\List}{\mathsf{List}}
\newcommand{\Nat}{\mathsf{Nat}}
\newcommand{\Choose}{\dec{Choose}}
\newcommand{\Count}{\dec{count}}
\newcommand{\GenericSearch}{\dec{genericSearch}}
\newcommand{\Predicate}{\dec{Predicate}}
\newcommand{\Point}{\dec{Point}}
\newcommand{\Branch}{\dec{Branch}}
\newcommand{\Get}{\dec{Get}}
\newcommand{\Put}{\dec{Put}}
\newcommand{\Zero}{\dec{Zero}}
\newcommand{\Fail}{\dec{Fail}}

\newcommand{\True}{\mathsf{true}}
\newcommand{\False}{\mathsf{false}}

\newcommand{\eff}{!}
\newcommand{\typ}[2]{#1 \vdash #2}
\newcommand{\typv}[2]{#1 \vdash #2}
\newcommand{\typc}[3]{#1 \vdash #2 \eff #3}

\newcommand{\FTV}{\ensuremath{\mathrm{FTV}}}

\newcommand{\reducesto}[0]{\ensuremath{\leadsto}}
\newcommand{\stepsto}[0]{\ensuremath{\longrightarrow}}
\newcommand{\EC}{\ensuremath{\mathcal{E}}}

%% Handler projections.
\newcommand{\hret}{H^{\mathrm{val}}}
\newcommand{\hval}{\hret}
\newcommand{\hops}{H^{\mathrm{ops}}}
%\newcommand{\hex}{H^{\mathrm{ex}}}
\newcommand{\hell}{H^{\ell}}

\newcommand{\alertbox}[2]{{\par\noindent\small\color{red} \framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{\textbf{#1:} #2}}}}
\newcommand{\todo}[1]{\alertbox{TODO}{#1}}
\newcommand{\dhil}[1]{\alertbox{Daniel}{#1}}

%%
%% Labels
%%
\newcommand{\slab}[1]{\textrm{#1}}
\newcommand{\klab}[1]{\textrm{K-#1}}
\newcommand{\semlab}[1]{\textrm{S-#1}}
\newcommand{\tylab}[1]{\textrm{T-#1}}
\newcommand{\mlab}[1]{\text{\scshape{M-#1}}}
\newcommand{\siglab}[1]{\text{\scshape{Sig-#1}}}
\newcommand{\rowlab}[1]{\text{\scshape{R-#1}}}

%%
%% Syntactic categories.
%%
\newcommand{\CatName}[1]{\textrm{#1}}
\newcommand{\CompCat}{\CatName{Comp}}
\newcommand{\ValCat}{\CatName{Val}}
\newcommand{\VarCat}{\CatName{Var}}
\newcommand{\TypCat}{\CatName{Type}}
\newcommand{\TyVarCat}{\CatName{TyVar}}
\newcommand{\KindCat}{\CatName{Kind}}
\newcommand{\RowCat}{\RowCat}

%%
%% Lindley's array stuff.
%%
\newcommand{\ba}{\begin{array}}
\newcommand{\ea}{\end{array}}

\newcommand{\bl}{\ba[t]{@{}l@{}}}
\newcommand{\el}{\ea}


%%
%% Lindley's syntax, reductions, equations, and derivation environments.
%%
\newenvironment{syntax}{\[\ba{@{}l@{\quad}r@{~}c@{~}l@{}}}{\ea\]\ignorespacesafterend}
\newenvironment{reductions}{\[\ba{@{}l@{\qquad}@{}r@{~~}c@{~~}l@{}}}{\ea\]\ignorespacesafterend}

\newenvironment{eqs}{\ba{@{}r@{~}c@{~}l@{}}}{\ea}
\newenvironment{equations}{\[\ba{@{}r@{~}c@{~}l@{}}}{\ea\]\ignorespacesafterend}
\newenvironment{derivation}{\begin{displaymath}\ba{@{}r@{~}l@{}}}{\ea\end{displaymath}\ignorespacesafterend}
\newcommand{\reason}[1]{\quad (\text{#1})}


\newenvironment{smathpar}{\vspace{-3ex}\small\begin{mathpar}}{\end{mathpar}\normalsize\ignorespacesafterend}

%%
%% Defined-as equality
%%
\newcommand{\defas}[0]{\mathrel{\overset{\makebox[0pt]{\mbox{\normalfont\tiny\text{def}}}}{=}}}