\documentclass[../main.tex]{subfiles} \begin{document} \section{Core Language}% \label{sec:lang} In this section, we describe \lang{} a new calculus with higher-order functions and regular types~\cite{Squid:unpublished/McBride01}. We start by describing the types within the language: products, sums, recursive types and functions. We then describe the syntax which is standard for n-ary products and sums. We also define a \mapkw{} operation over arbitrary (covariant) functors.\@ \mapkw{} is necessary to define the equational theory of \foldkw{}, the eliminator for recursive types. The equational theory has \(\beta\) equalities, but no \(\eta\) equalities, a consequence of the embedding into System~T. Types for \lang{}, in \cref{fig:lang-wf}, are given relative to a context of type variables. The judgement \(\jdgmnt{ty}{\Theta}{A}\) states that \(A\) is a well-formed type in with variables from context \(\Theta\). Products and sums are well-formed when each of the n-ary components are well-formed. The recursive type \(\mu X. A\) is formed from a type \(A\) in a context extended by \(X\). The other type formation rules ensure that \(X\) is used strictly positively, and thus that recursive types are well-formed. In particular the rule forming function types forbids using any type variables on the left of the arrow. This forbids the use of type variables in negative positions. The function type formation rule also forbids variables on the right. This is to forbid types such as \(\mu X. 1 + \nat \to X\) of countable trees, as such a type cannot be represented by System~T~\cite{proof}. Well-formed types also respect substitution: \begin{proposition}[Type Substitution] Given \(\jdgmnt{ty}{\Theta}{A}\) and \(\jdgmnt{ty}{\Psi}{B_i}\) where \(i\) ranges from \(0\) to \(\lvert \Theta \rvert\), we have \(\jdgmnt{ty}{\Psi}{\FIXME{\sub{A}{X_i/B_i}}}\). \end{proposition} \begin{figure} \[ \begin{array}{ccccc} \begin{prooftree} \hypo{ X \in \Theta \vphantom{\jdgmnt{ty}{\Theta}{A}} %% Spooky formatting phantom } \infer1{\jdgmnt{ty}{\Theta}{X}} \end{prooftree} & \begin{prooftree} \hypo{\rangeover{\jdgmnt{ty}{\Theta}{A_i}}{i