comparison doc/manual.tex @ 558:390cba747188

Proofreading pass
author Adam Chlipala <adamc@hcoop.net>
date Tue, 09 Dec 2008 14:06:51 -0500
parents 0d3db8d6a586
children 5d494183ca89
comparison
equal deleted inserted replaced
557:0d3db8d6a586 558:390cba747188
132 132
133 To compile project \texttt{P.urp}, simply run 133 To compile project \texttt{P.urp}, simply run
134 \begin{verbatim} 134 \begin{verbatim}
135 urweb P 135 urweb P
136 \end{verbatim} 136 \end{verbatim}
137 The output executable is a standalone web server. Run it with the command-line argument \texttt{-h} to see which options it takes. If the project file lists a database, the web server will attempt to connect to that database on startup.
137 138
138 To time how long the different compiler phases run, without generating an executable, run 139 To time how long the different compiler phases run, without generating an executable, run
139 \begin{verbatim} 140 \begin{verbatim}
140 urweb -timing P 141 urweb -timing P
141 \end{verbatim} 142 \end{verbatim}
186 \end{array}$$ 187 \end{array}$$
187 188
188 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. 189 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.
189 $$\begin{array}{rrcll} 190 $$\begin{array}{rrcll}
190 \textrm{Explicitness} & ? &::=& :: & \textrm{explicit} \\ 191 \textrm{Explicitness} & ? &::=& :: & \textrm{explicit} \\
191 &&& \; ::: & \textrm{implicit} 192 &&& ::: & \textrm{implicit}
192 \end{array}$$ 193 \end{array}$$
193 194
194 \emph{Constructors} are the main class of compile-time-only data. They include proper types and are classified by kinds. 195 \emph{Constructors} are the main class of compile-time-only data. They include proper types and are classified by kinds.
195 $$\begin{array}{rrcll} 196 $$\begin{array}{rrcll}
196 \textrm{Constructors} & c, \tau &::=& (c) :: \kappa & \textrm{kind annotation} \\ 197 \textrm{Constructors} & c, \tau &::=& (c) :: \kappa & \textrm{kind annotation} \\
208 \\ 209 \\
209 &&& [(c = c)^*] & \textrm{known-length type-level record} \\ 210 &&& [(c = c)^*] & \textrm{known-length type-level record} \\
210 &&& c \rc c & \textrm{type-level record concatenation} \\ 211 &&& c \rc c & \textrm{type-level record concatenation} \\
211 &&& \mt{fold} & \textrm{type-level record fold} \\ 212 &&& \mt{fold} & \textrm{type-level record fold} \\
212 \\ 213 \\
213 &&& (c^+) & \textrm{type-level tuple} \\ 214 &&& (c,^+) & \textrm{type-level tuple} \\
214 &&& c.n & \textrm{type-level tuple projection ($n \in \mathbb N^+$)} \\ 215 &&& c.n & \textrm{type-level tuple projection ($n \in \mathbb N^+$)} \\
215 \\ 216 \\
216 &&& \lambda [c \sim c] \Rightarrow c & \textrm{guarded constructor} \\ 217 &&& \lambda [c \sim c] \Rightarrow c & \textrm{guarded constructor} \\
217 \\ 218 \\
218 &&& \_ :: \kappa & \textrm{wildcard} \\ 219 &&& \_ :: \kappa & \textrm{wildcard} \\
450 \subsection{Record Disjointness} 451 \subsection{Record Disjointness}
451 452
452 We will use a keyword $\mt{map}$ as a shorthand, such that, for $f$ of kind $\kappa \to \kappa'$, $\mt{map} \; f$ stands for $\mt{fold} \; (\lambda (x_1 :: \mt{Name}) (x_2 :: \kappa) (x_3 :: \{\kappa'\}) \Rightarrow [x_1 = f \; x_2] \rc x_3) \; []$. 453 We will use a keyword $\mt{map}$ as a shorthand, such that, for $f$ of kind $\kappa \to \kappa'$, $\mt{map} \; f$ stands for $\mt{fold} \; (\lambda (x_1 :: \mt{Name}) (x_2 :: \kappa) (x_3 :: \{\kappa'\}) \Rightarrow [x_1 = f \; x_2] \rc x_3) \; []$.
453 454
454 $$\infer{\Gamma \vdash c_1 \sim c_2}{ 455 $$\infer{\Gamma \vdash c_1 \sim c_2}{
455 \Gamma \vdash c_1 \hookrightarrow c'_1 456 \Gamma \vdash c_1 \hookrightarrow C_1
456 & \Gamma \vdash c_2 \hookrightarrow c'_2 457 & \Gamma \vdash c_2 \hookrightarrow C_2
457 & \forall c''_1 \in c'_1, c''_2 \in c'_2: \Gamma \vdash c''_1 \sim c''_2 458 & \forall c'_1 \in C_1, c'_2 \in C_2: \Gamma \vdash c'_1 \sim c'_2
458 } 459 }
459 \quad \infer{\Gamma \vdash X \sim X'}{ 460 \quad \infer{\Gamma \vdash X \sim X'}{
460 X \neq X' 461 X \neq X'
461 }$$ 462 }$$
462 463
463 $$\infer{\Gamma \vdash c_1 \sim c_2}{ 464 $$\infer{\Gamma \vdash c_1 \sim c_2}{
464 c'_1 \sim c'_2 \in \Gamma 465 c'_1 \sim c'_2 \in \Gamma
465 & \Gamma \vdash c'_1 \hookrightarrow c''_1 466 & \Gamma \vdash c'_1 \hookrightarrow C_1
466 & \Gamma \vdash c'_2 \hookrightarrow c''_2 467 & \Gamma \vdash c'_2 \hookrightarrow C_2
467 & c_1 \in c''_1 468 & c_1 \in C_1
468 & c_2 \in c''_2 469 & c_2 \in C_2
469 }$$ 470 }$$
470 471
471 $$\infer{\Gamma \vdash c \hookrightarrow \{c\}}{} 472 $$\infer{\Gamma \vdash c \hookrightarrow \{c\}}{}
472 \quad \infer{\Gamma \vdash [\overline{c = c'}] \hookrightarrow \{\overline{c}\}}{} 473 \quad \infer{\Gamma \vdash [\overline{c = c'}] \hookrightarrow \{\overline{c}\}}{}
473 \quad \infer{\Gamma \vdash c_1 \rc c_2 \hookrightarrow C_1 \cup C_2}{ 474 \quad \infer{\Gamma \vdash c_1 \rc c_2 \hookrightarrow C_1 \cup C_2}{
654 655
655 We use an auxiliary judgment $\overline{y}; x; \Gamma \vdash \overline{dc} \leadsto \Gamma'$, expressing the enrichment of $\Gamma$ with the types of the datatype constructors $\overline{dc}$, when they are known to belong to datatype $x$ with type parameters $\overline{y}$. 656 We use an auxiliary judgment $\overline{y}; x; \Gamma \vdash \overline{dc} \leadsto \Gamma'$, expressing the enrichment of $\Gamma$ with the types of the datatype constructors $\overline{dc}$, when they are known to belong to datatype $x$ with type parameters $\overline{y}$.
656 657
657 This is the first judgment where we deal with type classes, for the $\mt{class}$ declaration form. We will omit their special handling in this formal specification. Section \ref{typeclasses} gives an informal description of how type classes influence type inference. 658 This is the first judgment where we deal with type classes, for the $\mt{class}$ declaration form. We will omit their special handling in this formal specification. Section \ref{typeclasses} gives an informal description of how type classes influence type inference.
658 659
659 We presuppose the existence of a function $\mathcal O$, where $\mathcal(M, \overline{s})$ implements the $\mt{open}$ declaration by producing a context with the appropriate entry for each available component of module $M$ with signature items $\overline{s}$. Where possible, $\mathcal O$ uses ``transparent'' entries (e.g., an abstract type $M.x$ is mapped to $x :: \mt{Type} = M.x$), so that the relationship with $M$ is maintained. A related function $\mathcal O_c$ builds a context containing the disjointness constraints found in $S$. 660 We presuppose the existence of a function $\mathcal O$, where $\mathcal O(M, \overline{s})$ implements the $\mt{open}$ declaration by producing a context with the appropriate entry for each available component of module $M$ with signature items $\overline{s}$. Where possible, $\mathcal O$ uses ``transparent'' entries (e.g., an abstract type $M.x$ is mapped to $x :: \mt{Type} = M.x$), so that the relationship with $M$ is maintained. A related function $\mathcal O_c$ builds a context containing the disjointness constraints found in $\overline s$.
660
661 We write $\kappa_1^n \to \kappa$ as a shorthand, where $\kappa_1^0 \to \kappa = \kappa$ and $\kappa_1^{n+1} \to \kappa_2 = \kappa_1 \to (\kappa_1^n \to \kappa_2)$. We write $\mt{len}(\overline{y})$ for the length of vector $\overline{y}$ of variables. 661 We write $\kappa_1^n \to \kappa$ as a shorthand, where $\kappa_1^0 \to \kappa = \kappa$ and $\kappa_1^{n+1} \to \kappa_2 = \kappa_1 \to (\kappa_1^n \to \kappa_2)$. We write $\mt{len}(\overline{y})$ for the length of vector $\overline{y}$ of variables.
662 662
663 $$\infer{\Gamma \vdash \cdot \leadsto \Gamma}{} 663 $$\infer{\Gamma \vdash \cdot \leadsto \Gamma}{}
664 \quad \infer{\Gamma \vdash d, \overline{d} \leadsto \Gamma''}{ 664 \quad \infer{\Gamma \vdash d, \overline{d} \leadsto \Gamma''}{
665 \Gamma \vdash d \leadsto \Gamma' 665 \Gamma \vdash d \leadsto \Gamma'
688 & \textrm{$e_i$ starts with an expression $\lambda$, optionally preceded by constructor and disjointness $\lambda$s} 688 & \textrm{$e_i$ starts with an expression $\lambda$, optionally preceded by constructor and disjointness $\lambda$s}
689 }$$ 689 }$$
690 690
691 $$\infer{\Gamma \vdash \mt{structure} \; X : S = M \leadsto \Gamma, X : S}{ 691 $$\infer{\Gamma \vdash \mt{structure} \; X : S = M \leadsto \Gamma, X : S}{
692 \Gamma \vdash M : S 692 \Gamma \vdash M : S
693 & \textrm{ ($M$ not a $\mt{struct} \; \ldots \; \mt{end}$)} 693 & \textrm{ $M$ not a constant or application}
694 } 694 }
695 \quad \infer{\Gamma \vdash \mt{structure} \; X : S = \mt{struct} \; \overline{d} \; \mt{end} \leadsto \Gamma, X : \mt{selfify}(X, \overline{s})}{ 695 \quad \infer{\Gamma \vdash \mt{structure} \; X : S = M \leadsto \Gamma, X : \mt{selfify}(X, \overline{s})}{
696 \Gamma \vdash \mt{struct} \; \overline{d} \; \mt{end} : \mt{sig} \; \overline{s} \; \mt{end} 696 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end}
697 }$$ 697 }$$
698 698
699 $$\infer{\Gamma \vdash \mt{signature} \; X = S \leadsto \Gamma, X = S}{ 699 $$\infer{\Gamma \vdash \mt{signature} \; X = S \leadsto \Gamma, X = S}{
700 \Gamma \vdash S 700 \Gamma \vdash S
701 }$$ 701 }$$
784 } 784 }
785 \quad \infer{\Gamma \vdash \mt{class} \; x \leadsto \Gamma, x :: \mt{Type} \to \mt{Type}}{}$$ 785 \quad \infer{\Gamma \vdash \mt{class} \; x \leadsto \Gamma, x :: \mt{Type} \to \mt{Type}}{}$$
786 786
787 \subsection{Signature Compatibility} 787 \subsection{Signature Compatibility}
788 788
789 To simplify the judgments in this section, we assume that all signatures are alpha-varied as necessary to avoid including mmultiple bindings for the same identifier. This is in addition to the usual alpha-variation of locally-bound variables. 789 To simplify the judgments in this section, we assume that all signatures are alpha-varied as necessary to avoid including multiple bindings for the same identifier. This is in addition to the usual alpha-variation of locally-bound variables.
790 790
791 We rely on a judgment $\Gamma \vdash \overline{s} \leq s'$, which expresses the occurrence in signature items $\overline{s}$ of an item compatible with $s'$. We also use a judgment $\Gamma \vdash \overline{dc} \leq \overline{dc}$, which expresses compatibility of datatype definitions. 791 We rely on a judgment $\Gamma \vdash \overline{s} \leq s'$, which expresses the occurrence in signature items $\overline{s}$ of an item compatible with $s'$. We also use a judgment $\Gamma \vdash \overline{dc} \leq \overline{dc}$, which expresses compatibility of datatype definitions.
792 792
793 $$\infer{\Gamma \vdash S \equiv S}{} 793 $$\infer{\Gamma \vdash S \equiv S}{}
794 \quad \infer{\Gamma \vdash S_1 \equiv S_2}{ 794 \quad \infer{\Gamma \vdash S_1 \equiv S_2}{
833 & \Gamma, X : S'_1 \vdash S_2 \leq S'_2 833 & \Gamma, X : S'_1 \vdash S_2 \leq S'_2
834 }$$ 834 }$$
835 835
836 $$\infer{\Gamma \vdash \mt{con} \; x :: \kappa \leq \mt{con} \; x :: \kappa}{} 836 $$\infer{\Gamma \vdash \mt{con} \; x :: \kappa \leq \mt{con} \; x :: \kappa}{}
837 \quad \infer{\Gamma \vdash \mt{con} \; x :: \kappa = c \leq \mt{con} \; x :: \kappa}{} 837 \quad \infer{\Gamma \vdash \mt{con} \; x :: \kappa = c \leq \mt{con} \; x :: \kappa}{}
838 \quad \infer{\Gamma \vdash \mt{datatype} \; x \; \overline{y} = \overline{dc} \leq \mt{con} \; x :: \mt{Type}}{}$$ 838 \quad \infer{\Gamma \vdash \mt{datatype} \; x \; \overline{y} = \overline{dc} \leq \mt{con} \; x :: \mt{Type}^{\mt{len}(\overline y)} \to \mt{Type}}{}$$
839 839
840 $$\infer{\Gamma \vdash \mt{datatype} \; x = \mt{datatype} \; M.z \leq \mt{con} \; x :: \mt{Type}^{\mt{len}(y)} \to \mt{Type}}{ 840 $$\infer{\Gamma \vdash \mt{datatype} \; x = \mt{datatype} \; M.z \leq \mt{con} \; x :: \mt{Type}^{\mt{len}(y)} \to \mt{Type}}{
841 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end} 841 \Gamma \vdash M : \mt{sig} \; \overline{s} \; \mt{end}
842 & \mt{proj}(M, \overline{s}, \mt{datatype} \; z) = (\overline{y}, \overline{dc}) 842 & \mt{proj}(M, \overline{s}, \mt{datatype} \; z) = (\overline{y}, \overline{dc})
843 }$$ 843 }$$
944 \mt{sigOf}(\mt{table} \; x : c) &=& \mt{table} \; x : c \\ 944 \mt{sigOf}(\mt{table} \; x : c) &=& \mt{table} \; x : c \\
945 \mt{sigOf}(\mt{sequence} \; x) &=& \mt{sequence} \; x \\ 945 \mt{sigOf}(\mt{sequence} \; x) &=& \mt{sequence} \; x \\
946 \mt{sigOf}(\mt{cookie} \; x : \tau) &=& \mt{cookie} \; x : \tau \\ 946 \mt{sigOf}(\mt{cookie} \; x : \tau) &=& \mt{cookie} \; x : \tau \\
947 \mt{sigOf}(\mt{class} \; x = c) &=& \mt{class} \; x = c \\ 947 \mt{sigOf}(\mt{class} \; x = c) &=& \mt{class} \; x = c \\
948 \end{eqnarray*} 948 \end{eqnarray*}
949
950 \begin{eqnarray*} 949 \begin{eqnarray*}
951 \mt{selfify}(M, \cdot) &=& \cdot \\ 950 \mt{selfify}(M, \cdot) &=& \cdot \\
952 \mt{selfify}(M, s \; \overline{s'}) &=& \mt{selfify}(M, \sigma, s) \; \mt{selfify}(M, \overline{s'}) \\ 951 \mt{selfify}(M, s \; \overline{s'}) &=& \mt{selfify}(M, s) \; \mt{selfify}(M, \overline{s'}) \\
953 \\ 952 \\
954 \mt{selfify}(M, \mt{con} \; x :: \kappa) &=& \mt{con} \; x :: \kappa = M.x \\ 953 \mt{selfify}(M, \mt{con} \; x :: \kappa) &=& \mt{con} \; x :: \kappa = M.x \\
955 \mt{selfify}(M, \mt{con} \; x :: \kappa = c) &=& \mt{con} \; x :: \kappa = c \\ 954 \mt{selfify}(M, \mt{con} \; x :: \kappa = c) &=& \mt{con} \; x :: \kappa = c \\
956 \mt{selfify}(M, \mt{datatype} \; x \; \overline{y} = \overline{dc}) &=& \mt{datatype} \; x \; \overline{y} = \mt{datatype} \; M.x \\ 955 \mt{selfify}(M, \mt{datatype} \; x \; \overline{y} = \overline{dc}) &=& \mt{datatype} \; x \; \overline{y} = \mt{datatype} \; M.x \\
957 \mt{selfify}(M, \mt{datatype} \; x = \mt{datatype} \; M'.z) &=& \mt{datatype} \; x = \mt{datatype} \; M'.z \\ 956 \mt{selfify}(M, \mt{datatype} \; x = \mt{datatype} \; M'.z) &=& \mt{datatype} \; x = \mt{datatype} \; M'.z \\
982 \mt{proj}(M, \mt{datatype} \; x \; \overline{y} = \overline{dc} \; \overline{s}, \mt{val} \; X) &=& \overline{y ::: \mt{Type}} \to M.x \; \overline y \textrm{ (where $X \in \overline{dc}$)} \\ 981 \mt{proj}(M, \mt{datatype} \; x \; \overline{y} = \overline{dc} \; \overline{s}, \mt{val} \; X) &=& \overline{y ::: \mt{Type}} \to M.x \; \overline y \textrm{ (where $X \in \overline{dc}$)} \\
983 \mt{proj}(M, \mt{datatype} \; x \; \overline{y} = \overline{dc} \; \overline{s}, \mt{val} \; X) &=& \overline{y ::: \mt{Type}} \to \tau \to M.x \; \overline y \textrm{ (where $X \; \mt{of} \; \tau \in \overline{dc}$)} \\ 982 \mt{proj}(M, \mt{datatype} \; x \; \overline{y} = \overline{dc} \; \overline{s}, \mt{val} \; X) &=& \overline{y ::: \mt{Type}} \to \tau \to M.x \; \overline y \textrm{ (where $X \; \mt{of} \; \tau \in \overline{dc}$)} \\
984 \mt{proj}(M, \mt{datatype} \; x = \mt{datatype} \; M'.z, \mt{val} \; X) &=& \overline{y ::: \mt{Type}} \to M.x \; \overline y \textrm{ (where $\Gamma \vdash M' : \mt{sig} \; \overline{s'} \; \mt{end}$} \\ 983 \mt{proj}(M, \mt{datatype} \; x = \mt{datatype} \; M'.z, \mt{val} \; X) &=& \overline{y ::: \mt{Type}} \to M.x \; \overline y \textrm{ (where $\Gamma \vdash M' : \mt{sig} \; \overline{s'} \; \mt{end}$} \\
985 && \textrm{and $\mt{proj}(M', \overline{s'}, \mt{datatype} \; z = (\overline{y}, \overline{dc})$ and $X \in \overline{dc}$)} \\ 984 && \textrm{and $\mt{proj}(M', \overline{s'}, \mt{datatype} \; z = (\overline{y}, \overline{dc})$ and $X \in \overline{dc}$)} \\
986 \mt{proj}(M, \mt{datatype} \; x = \mt{datatype} \; M'.z, \mt{val} \; X) &=& \overline{y ::: \mt{Type}} \to \tau \to M.x \; \overline y \textrm{ (where $\Gamma \vdash M' : \mt{sig} \; \overline{s'} \; \mt{end}$} \\ 985 \mt{proj}(M, \mt{datatype} \; x = \mt{datatype} \; M'.z, \mt{val} \; X) &=& \overline{y ::: \mt{Type}} \to \tau \to M.x \; \overline y \textrm{ (where $\Gamma \vdash M' : \mt{sig} \; \overline{s'} \; \mt{end}$} \\
987 && \textrm{and $\mt{proj}(M', \overline{s'}, \mt{datatype} \; z = (\overline{y}, \overline{dc})$ and $X : \tau \in \overline{dc}$)} \\ 986 && \textrm{and $\mt{proj}(M', \overline{s'}, \mt{datatype} \; z = (\overline{y}, \overline{dc})$ and $X \; \mt{of} \; \tau \in \overline{dc}$)} \\
988 \\ 987 \\
989 \mt{proj}(M, \mt{structure} \; X : S \; \overline{s}, \mt{structure} \; X) &=& S \\ 988 \mt{proj}(M, \mt{structure} \; X : S \; \overline{s}, \mt{structure} \; X) &=& S \\
990 \\ 989 \\
991 \mt{proj}(M, \mt{signature} \; X = S \; \overline{s}, \mt{signature} \; X) &=& S \\ 990 \mt{proj}(M, \mt{signature} \; X = S \; \overline{s}, \mt{signature} \; X) &=& S \\
992 \\ 991 \\
1389 1388
1390 $$\begin{array}{rrcll} 1389 $$\begin{array}{rrcll}
1391 \textrm{Projections} & P &::=& \ast & \textrm{all columns} \\ 1390 \textrm{Projections} & P &::=& \ast & \textrm{all columns} \\
1392 &&& p,^+ & \textrm{particular columns} \\ 1391 &&& p,^+ & \textrm{particular columns} \\
1393 \textrm{Pre-projections} & p &::=& t.f & \textrm{one column from a table} \\ 1392 \textrm{Pre-projections} & p &::=& t.f & \textrm{one column from a table} \\
1394 &&& t.\{\{c\}\} & \textrm{a record of colums from a table (of kind $\{\mt{Type}\}$)} \\ 1393 &&& t.\{\{c\}\} & \textrm{a record of columns from a table (of kind $\{\mt{Type}\}$)} \\
1395 \textrm{Table names} & t &::=& x & \textrm{constant table name (automatically capitalized)} \\ 1394 \textrm{Table names} & t &::=& x & \textrm{constant table name (automatically capitalized)} \\
1396 &&& X & \textrm{constant table name} \\ 1395 &&& X & \textrm{constant table name} \\
1397 &&& \{\{c\}\} & \textrm{computed table name (of kind $\mt{Name}$)} \\ 1396 &&& \{\{c\}\} & \textrm{computed table name (of kind $\mt{Name}$)} \\
1398 \textrm{Column names} & f &::=& X & \textrm{constant column name} \\ 1397 \textrm{Column names} & f &::=& X & \textrm{constant column name} \\
1399 &&& \{c\} & \textrm{computed column name (of kind $\mt{Name}$)} \\ 1398 &&& \{c\} & \textrm{computed column name (of kind $\mt{Name}$)} \\
1460 1459
1461 When the standalone web server receives a request for a known page, it calls the function for that page, ``running'' the resulting transaction to produce the page to return to the client. Pages link to other pages with the \texttt{link} attribute of the \texttt{a} HTML tag. A link has type $\mt{transaction} \; \mt{page}$, and the semantics of a link are that this transaction should be run to compute the result page, when the link is followed. Link targets are assigned URL names in the same way as top-level entry points. 1460 When the standalone web server receives a request for a known page, it calls the function for that page, ``running'' the resulting transaction to produce the page to return to the client. Pages link to other pages with the \texttt{link} attribute of the \texttt{a} HTML tag. A link has type $\mt{transaction} \; \mt{page}$, and the semantics of a link are that this transaction should be run to compute the result page, when the link is followed. Link targets are assigned URL names in the same way as top-level entry points.
1462 1461
1463 HTML forms are handled in a similar way. The $\mt{action}$ attribute of a $\mt{submit}$ form tag takes a value of type $\$\mt{use} \to \mt{transaction} \; \mt{page}$, where $\mt{use}$ is a kind-$\{\mt{Type}\}$ record of the form fields used by this action handler. Action handlers are assigned URL patterns in the same way as above. 1462 HTML forms are handled in a similar way. The $\mt{action}$ attribute of a $\mt{submit}$ form tag takes a value of type $\$\mt{use} \to \mt{transaction} \; \mt{page}$, where $\mt{use}$ is a kind-$\{\mt{Type}\}$ record of the form fields used by this action handler. Action handlers are assigned URL patterns in the same way as above.
1464 1463
1465 For both links and actions, direct arguments and local variables mentioned implicitly via closures are automatically included in serialized form in URLs, in the order in which they appeared in the source code. 1464 For both links and actions, direct arguments and local variables mentioned implicitly via closures are automatically included in serialized form in URLs, in the order in which they appear in the source code.
1466 1465
1467 1466
1468 \section{Compiler Phases} 1467 \section{Compiler Phases}
1469 1468
1470 The Ur/Web compiler is unconventional in that it relies on a kind of \emph{heuristic compilation}. Not all valid programs will compile successfully. Informally, programs fail to compile when they are ``too higher order.'' Compiler phases do their best to eliminate different kinds of higher order-ness, but some programs just won't compile. This is a trade-off for producing very efficient executables. Compiled Ur/Web programs use native C representations and require no garbage collection. 1469 The Ur/Web compiler is unconventional in that it relies on a kind of \emph{heuristic compilation}. Not all valid programs will compile successfully. Informally, programs fail to compile when they are ``too higher order.'' Compiler phases do their best to eliminate different kinds of higher order-ness, but some programs just won't compile. This is a trade-off for producing very efficient executables. Compiled Ur/Web programs use native C representations and require no garbage collection.
1511 1510
1512 This phase specializes polymorphic functions to the specific arguments passed to them in the program. If the program contains real polymorphic recursion, Unpoly will be insufficient to avoid later error messages about too much polymorphism. 1511 This phase specializes polymorphic functions to the specific arguments passed to them in the program. If the program contains real polymorphic recursion, Unpoly will be insufficient to avoid later error messages about too much polymorphism.
1513 1512
1514 \subsection{Specialize} 1513 \subsection{Specialize}
1515 1514
1516 Replace uses of parametrized datatypes with versions specialized to specific parameters. As for Unpoly, this phase will not be effective enough in the presence of polymorphic recursion or other fancy uses of impredicative polymorphism. 1515 Replace uses of parameterized datatypes with versions specialized to specific parameters. As for Unpoly, this phase will not be effective enough in the presence of polymorphic recursion or other fancy uses of impredicative polymorphism.
1517 1516
1518 \subsection{Shake} 1517 \subsection{Shake}
1519 1518
1520 Here the compiler repeats the earlier shake phase. 1519 Here the compiler repeats the earlier Shake phase.
1521 1520
1522 \subsection{Monoize} 1521 \subsection{Monoize}
1523 1522
1524 Programs are translated to a new intermediate language without polymorphism or non-$\mt{Type}$ constructors. Error messages may pop up here if earlier phases failed to remove such features. 1523 Programs are translated to a new intermediate language without polymorphism or non-$\mt{Type}$ constructors. Error messages may pop up here if earlier phases failed to remove such features.
1525 1524