Mercurial > urweb
comparison doc/manual.tex @ 524:a6159d0940f0
Start of manual
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 27 Nov 2008 14:38:53 -0500 |
parents | |
children | 602f7536cae3 |
comparison
equal
deleted
inserted
replaced
523:612001c39ed6 | 524:a6159d0940f0 |
---|---|
1 \documentclass{article} | |
2 \usepackage{fullpage,amsmath,amssymb,proof} | |
3 | |
4 \newcommand{\cd}[1]{\texttt{#1}} | |
5 \newcommand{\mt}[1]{\mathsf{#1}} | |
6 | |
7 \newcommand{\rc}{+ \hspace{-.075in} + \;} | |
8 | |
9 \begin{document} | |
10 | |
11 \title{The Ur/Web Manual} | |
12 \author{Adam Chlipala} | |
13 | |
14 \maketitle | |
15 | |
16 \section{Syntax} | |
17 | |
18 \subsection{Lexical Conventions} | |
19 | |
20 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. | |
21 | |
22 \begin{center} | |
23 \begin{tabular}{rl} | |
24 \textbf{\LaTeX} & \textbf{ASCII} \\ | |
25 $\to$ & \cd{->} \\ | |
26 $\times$ & \cd{*} \\ | |
27 $\lambda$ & \cd{fn} \\ | |
28 $\Rightarrow$ & \cd{=>} \\ | |
29 $\rc$ & \cd{++} \\ | |
30 \\ | |
31 $x$ & Normal textual identifier, not beginning with an uppercase letter \\ | |
32 $\alpha$ & Normal textual identifier, not beginning with an uppercase letter \\ | |
33 $f$ & Normal textual identifier, beginning with an uppercase letter \\ | |
34 \end{tabular} | |
35 \end{center} | |
36 | |
37 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. | |
38 | |
39 \subsection{Core Syntax} | |
40 | |
41 \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. | |
42 $$\begin{array}{rrcll} | |
43 \textrm{Kinds} & \kappa &::=& \mt{Type} & \textrm{proper types} \\ | |
44 &&& \mid \mt{Unit} & \textrm{the trivial constructor} \\ | |
45 &&& \mid \mt{Name} & \textrm{field names} \\ | |
46 &&& \mid \kappa \to \kappa & \textrm{type-level functions} \\ | |
47 &&& \mid \{\kappa\} & \textrm{type-level records} \\ | |
48 &&& \mid (\kappa \times \cdots \times \kappa) & \textrm{type-level tuples} \\ | |
49 &&& \mid (\kappa) & \textrm{explicit precedence} \\ | |
50 \end{array}$$ | |
51 | |
52 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. | |
53 $$\begin{array}{rrcll} | |
54 \textrm{Explicitness} & ? &::=& :: & \textrm{explicit} \\ | |
55 &&& \mid \; ::: & \textrm{implicit} | |
56 \end{array}$$ | |
57 | |
58 \emph{Constructors} are the main class of compile-time-only data. They include proper types and are classified by kinds. | |
59 $$\begin{array}{rrcll} | |
60 \textrm{Constructors} & c, \tau &::=& (c) :: \kappa & \textrm{kind annotation} \\ | |
61 &&& \mid \alpha & \textrm{constructor variable} \\ | |
62 \\ | |
63 &&& \mid \tau \to \tau & \textrm{function type} \\ | |
64 &&& \mid \alpha \; ? \; \kappa \to \tau & \textrm{polymorphic function type} \\ | |
65 &&& \mid \$ c & \textrm{record type} \\ | |
66 \\ | |
67 &&& \mid c \; c & \textrm{type-level function application} \\ | |
68 &&& \mid \lambda \alpha \; ? \; \kappa \Rightarrow c & \textrm{type-level function abstraction} \\ | |
69 \\ | |
70 &&& \mid () & \textrm{type-level unit} \\ | |
71 &&& \mid \#f & \textrm{field name} \\ | |
72 \\ | |
73 &&& \mid [c = c, \cdots, c = c] & \textrm{known-length type-level record} \\ | |
74 &&& \mid c \rc c & \textrm{type-level record concatenation} \\ | |
75 &&& \mid \mt{fold} & \textrm{type-level record fold} \\ | |
76 \\ | |
77 &&& \mid (c, \cdots, c) & \textrm{type-level tuple} \\ | |
78 &&& \mid c.n & \textrm{type-level tuple projection ($n \in \mathbb N^+$)} \\ | |
79 \\ | |
80 &&& \mid \lambda [c \sim c] \Rightarrow c & \textrm{guarded constructor} \\ | |
81 \\ | |
82 &&& \mid (c) & \textrm{explicit precedence} \\ | |
83 \end{array}$$ | |
84 | |
85 \end{document} |