mirror of
https://github.com/thufschmitt/tix-papers.git
synced 2024-09-11 13:00:34 +03:00
Rewrite the Semantics of pattern-matching
Using multi-fields records This is basically a copy-paste of the semantic of pattern-matching of a type. Fixes #8
This commit is contained in:
parent
ee998adb40
commit
9e18af9de4
@ -40,13 +40,42 @@ figure~\pref{fig:semantics:nix-light:patterns}
|
|||||||
% commutative monoid.
|
% commutative monoid.
|
||||||
|
|
||||||
\begin{tabular}{rl}
|
\begin{tabular}{rl}
|
||||||
\eqdefa{\assignp{q@x}{e}}{\assign{x}{e}; \assignp{q}{e}}{}
|
\eqdefa{$\sfrac{x}{e}$}{$\sfrac{x}{e}$}{}
|
||||||
\eqdefa{\assignp{(\{ x \} \orthplus q)}{(\{ x = e; \} \orthplus v)}}{\assignp{x}{e}; \assignp{q}{v}}{}
|
\eqdefa{$\sfrac{q@x}{e}$}{$\sfrac{x}{e}; \sfrac{q}{x}$}{}
|
||||||
\eqdefa{\assignp{(\{ x ? c' \} \orthplus q)}{(\{ x = e; \} \orthplus v)}}{\assignp{x}{e}; \assignp{q}{v}}{}
|
\eqdefa{$\sfrac{\{\}}{\{ x_1 ? c_1, \cdots, x_n ? c_n \}}$}{%
|
||||||
\eqdefa{\assignp{(\{ x ? c \} \orthplus q)}{(v_1 \orthplus v_2)}}{\assignp{x}{c}; \assignp{q}{\left( v_1 \orthplus v_2\right)}}{if $v_1 \neq \{ x = e'; \}$}
|
$\sfrac{x_1}{c_1}; \cdots; \sfrac{x_n}{c_n}$}{}
|
||||||
\eqdefa{\assignp{\{\}}{\{ \}}}{ø}{}
|
\eqdefa{%
|
||||||
\eqdefa{\assignp{\{ .. \}}{v}}{ø}{}
|
$\sfrac{%
|
||||||
\eqdefa{\assignp{Cons(x, x')}{Cons(e, e')}}{\assign{x}{e}; \assign{x'}{e'}}{}
|
\{ s_1 = e_1; \cdots; s_m = e_m; \}%
|
||||||
|
}{%
|
||||||
|
\{x_1 ? c_1, \cdots, x_n ? c_n, \textbf{\ldots}\}%
|
||||||
|
}$%
|
||||||
|
}{%
|
||||||
|
$\sfrac{x_1}{c_1}; \cdots; \sfrac{x_n}{c_n}$%
|
||||||
|
}{%
|
||||||
|
if %
|
||||||
|
$\forall (i,j) \in \discrete{1}{m} \times \discrete{1}{n}, s_i \neq s_j$%
|
||||||
|
}
|
||||||
|
\eqdefa{$\sfrac{\{ s = e;\}}{\{ x \}}$}{$\sfrac{x}{e}$}{if $s = x$}
|
||||||
|
\eqdefa{$\sfrac{\{ s = e;\}}{\{ x ? c \}}$}{$\sfrac{x}{e}$}{if $s = x$}
|
||||||
|
\eqdefa{$%
|
||||||
|
\sfrac{\{ s_1 = e_1; \cdots; s_n = e_n \}}{\{ x, f_1, \cdots, f_m \}}%
|
||||||
|
$}{$%
|
||||||
|
\sfrac{x}{e};%
|
||||||
|
\sfrac{\{ s_2 = e_2; \cdots; s_n = e_n \}}{\{ f_1, \cdots, f_m \}}%
|
||||||
|
$}{if $s_1 = x$}
|
||||||
|
\eqdefa{
|
||||||
|
$\sfrac{%
|
||||||
|
\{ s_1 = e_1; \cdots; s_n = e_n \}}%
|
||||||
|
{\{ x ? c, f_1 \cdots, f_m \}}$%
|
||||||
|
}{%
|
||||||
|
$\sfrac{x}{e};%
|
||||||
|
\sfrac{\{ s_2 = e_2; \cdots; s_n = e_n \}}%
|
||||||
|
{\{ f_1, \cdots, f_m \}}$%
|
||||||
|
}{if $s_1 = x$}
|
||||||
|
\eqdefa{%
|
||||||
|
$\sfrac{\text{Cons}(e_1, e_2)}{\text{Cons}(x_1, x_2)}$%
|
||||||
|
}{$\sfrac{x_1}{e_1}; \sfrac{x_2}{e_2}$}{}
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
\caption{Semantic of the pattern-matching in nix-light\label{fig:semantics:nix-light:patterns}}
|
\caption{Semantic of the pattern-matching in nix-light\label{fig:semantics:nix-light:patterns}}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
Loading…
Reference in New Issue
Block a user