
adamc@524: \documentclass{article}
adamc@524: \usepackage{fullpage,amsmath,amssymb,proof}
adamc@524: 
adamc@524: \newcommand{\cd}[1]{\texttt{#1}}
adamc@524: \newcommand{\mt}[1]{\mathsf{#1}}
adamc@524: 
adamc@524: \newcommand{\rc}{+ \hspace{-.075in} + \;}
adamc@524: 
adamc@524: \begin{document}
adamc@524: 
adamc@524: \title{The Ur/Web Manual}
adamc@524: \author{Adam Chlipala}
adamc@524: 
adamc@524: \maketitle
adamc@524: 
adamc@524: \section{Syntax}
adamc@524: 
adamc@524: \subsection{Lexical Conventions}
adamc@524: 
adamc@524: We give the Ur language definition in \LaTeX $\;$ math mode, since that is prettier than monospaced ASCII.  The corresponding ASCII syntax can be read off directly.  Here is the key for mapping math symbols to ASCII character sequences.
adamc@524: 
adamc@524: \begin{center}
adamc@524:   \begin{tabular}{rl}
adamc@524:     \textbf{\LaTeX} & \textbf{ASCII} \\
adamc@524:     $\to$ & \cd{->} \\
adamc@524:     $\times$ & \cd{*} \\
adamc@524:     $\lambda$ & \cd{fn} \\
adamc@524:     $\Rightarrow$ & \cd{=>} \\
adamc@524:     $\rc$ & \cd{++} \\
adamc@524:     \\
adamc@524:     $x$ & Normal textual identifier, not beginning with an uppercase letter \\
adamc@524:     $\alpha$ & Normal textual identifier, not beginning with an uppercase letter \\
adamc@524:     $f$ & Normal textual identifier, beginning with an uppercase letter \\
adamc@524:   \end{tabular}
adamc@524: \end{center}
adamc@524: 
adamc@524: We often write syntax like $N, \cdots, N$ to stand for the non-terminal $N$ repeated 0 or more times.  That is, the $\cdots$ symbol is not translated literally to ASCII.
adamc@524: 
adamc@524: \subsection{Core Syntax}
adamc@524: 
adamc@524: \emph{Kinds} classify types and other compile-time-only entities.  Each kind in the grammar is listed with a description of the sort of data it classifies.
adamc@524: $$\begin{array}{rrcll}
adamc@524:   \textrm{Kinds} & \kappa &::=& \mt{Type} & \textrm{proper types} \\
adamc@524:   &&& \mid \mt{Unit} & \textrm{the trivial constructor} \\
adamc@524:   &&& \mid \mt{Name} & \textrm{field names} \\
adamc@524:   &&& \mid \kappa \to \kappa & \textrm{type-level functions} \\
adamc@524:   &&& \mid \{\kappa\} & \textrm{type-level records} \\
adamc@524:   &&& \mid (\kappa \times \cdots \times \kappa) & \textrm{type-level tuples} \\
adamc@524:   &&& \mid (\kappa) & \textrm{explicit precedence} \\
adamc@524: \end{array}$$
adamc@524: 
adamc@524: Ur supports several different notions of functions that take types as arguments.  These arguments can be either implicit, causing them to be inferred at use sites; or explicit, forcing them to be specified manually at use sites.  There is a common explicitness annotation convention applied at the definitions of and in the types of such functions.
adamc@524: $$\begin{array}{rrcll}
adamc@524:   \textrm{Explicitness} & ? &::=& :: & \textrm{explicit} \\
adamc@524:   &&& \mid \; ::: & \textrm{implicit}
adamc@524: \end{array}$$
adamc@524: 
adamc@524: \emph{Constructors} are the main class of compile-time-only data.  They include proper types and are classified by kinds.
adamc@524: $$\begin{array}{rrcll}
adamc@524:   \textrm{Constructors} & c, \tau &::=& (c) :: \kappa & \textrm{kind annotation} \\
adamc@524:   &&& \mid \alpha & \textrm{constructor variable} \\
adamc@524:   \\
adamc@524:   &&& \mid \tau \to \tau & \textrm{function type} \\
adamc@524:   &&& \mid \alpha \; ? \; \kappa \to \tau & \textrm{polymorphic function type} \\
adamc@524:   &&& \mid \$ c & \textrm{record type} \\
adamc@524:   \\
adamc@524:   &&& \mid c \; c & \textrm{type-level function application} \\
adamc@524:   &&& \mid \lambda \alpha \; ? \; \kappa \Rightarrow c & \textrm{type-level function abstraction} \\
adamc@524:   \\
adamc@524:   &&& \mid () & \textrm{type-level unit} \\
adamc@524:   &&& \mid \#f & \textrm{field name} \\
adamc@524:   \\
adamc@524:   &&& \mid [c = c, \cdots, c = c] & \textrm{known-length type-level record} \\
adamc@524:   &&& \mid c \rc c & \textrm{type-level record concatenation} \\
adamc@524:   &&& \mid \mt{fold} & \textrm{type-level record fold} \\
adamc@524:   \\
adamc@524:   &&& \mid (c, \cdots, c) & \textrm{type-level tuple} \\
adamc@524:   &&& \mid c.n & \textrm{type-level tuple projection ($n \in \mathbb N^+$)} \\
adamc@524:   \\
adamc@524:   &&& \mid \lambda [c \sim c] \Rightarrow c & \textrm{guarded constructor} \\
adamc@524:   \\
adamc@524:   &&& \mid (c) & \textrm{explicit precedence} \\
adamc@524: \end{array}$$
adamc@524: 
adamc@524: \end{document}



