Define the language
RecFun(
V,
C,
P)
as extending RecExp(
V,
C,
P) with
new types:
| T | ::= | ...as before... |
| | | C T : T |
and new expressions:
| M | ::= | ...as before... | |
| | | fn C P {M} | (Anonymous function) | |
| | | M M | (Function application) |
The typing for anonymous functions is:
![]() |
![]() |
(P : T) : ![]() ![]() |
, ![]() ![]() |
![]() |
M : T in C |
![]() |
![]() |
fn C P {M} : (C T : T ) in val |
and for function application is:
![]() |
![]() |
M : (C T : T ) in val |
![]() |
![]() |
M : T in C |
![]() |
![]() |
M M : T in C |
In particular, note that anonymous functions are always values, even if the function body is central or process. This agrees with the usual definition of normal forms for operational semantics.
To give a graphical semantics for the cartesian closed structure,
we extend the category of cyclic flow graphs
CGraph(
V)
to that of closed cyclic flow graphs
CCGraph(
V)
by allowing edges to be labelled by value function types:
B1,...,Bn
and allowing nodes of the form:
C1,...,Co),
B1,...,Bn
C1,...,Co
in
CCGraph(
V)
(B1,...,Bn
C1,...,Co)
in
CCGraph(
V)
C1,...,Co
in
CCGraph(
V)
V)[A, B
C]
CCGraph(
V)[A
B, C]
Graphically these axioms are:
| Beta: | = | ||
| Eta: | = | ||
| Naturality: | = |
| [[fn val P {M} in val]] | = | |
| [[M N in val]] | = |
To give a semantics for the symmetric monoidal closed structure:
V,
C)
to that of closed cyclic flow graphs
CCGraph(
V,
C), and
V)
to
CCGraph(
V,
C).
B1,...,Bn
We extend flow graphs to allow nodes of the form:
C1,...,Co),
B1,...,Bn
C1,...,Co
in
CCGraph(
V,
C)
(B1,...,Bn
C1,...,Co)
in
CCGraph(
V,
C)
C1,...,Co
in CCGraph(
V,
C)
V,
C)[A, B
C]
CCGraph(
V,
C)[A
B, C]
Graphically:
| Beta: | = | ||
| Eta: | = | ||
| Naturality: | = |
| [[fn central P {M} in val]] | = | |
| [[M N in central]] | = |
To give a semantics for the symmetric monoidal closed structure:
V,
C,
P)
to that of closed cyclic flow graphs
CCGraph(
V,
C,
P),
V,
C)
to
CCGraph(
V,
C,
P), and
V,
C)
to
CCGraph(
V,
C,
P).
B1,...,Bn
and allowing nodes of the form:
C1,...,Co),
B1,...,Bn
C1,...,Co
in
CCGraph(
V,
C,
P)
(B1,...,Bn
C1,...,Co)
in
CCGraph(
V,
C,
P)
C1,...,Co
in
CCGraph(
V,
C,
P)
V,
C,
P)[A, B
C]
CCGraph(
V,
C,
P)[A
B, C]
Graphically:
| Beta: | = | ||
| Eta: | = | ||
| Naturality: | = |
| [[fn proc P {M} in val]] | = | |
| [[M N in proc]] | = |
![]() |
![]() |
proc T : T traceable |
For example, with appropriate string and I/O primitives, we can write a simple `hello' program:
No change is required to the graphical semantics, except to make
edges labelled with types of the form
A1,...,Am
B1,...,Bn
traceable.
V,
C,
P)
CCGraph(
V,
C,
P)
CCGraph(
V,
C,
P)
form the initial triple of categories:
C
P
with:
V.
C.
P.
Z]
V[X
Y, Z]
Z]
C[X
Y, Z]
Z]
P[X
Y, Z]
Y
are traceable.