Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specification for type synonyms in DAML-LF #3635

Merged
merged 5 commits into from
Nov 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions daml-lf/spec/daml-lf-1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ Version: 1.dev

* **Rename** ``Map`` to ``TextMap``

* **Add** type synonyms.

Abstract syntax
^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -474,8 +476,8 @@ future addition to allowed identifier characters.

In the following, we will use identifiers to represent *built-in
functions*, term and type *variable names*, record and tuple *field
names*, *variant constructors*, and *template choices*. On the other
hand, we will use names to represent *type constructors*, *value
names*, *variant constructors* and *template choices*. On the other
hand, we will use names to represent *type constructors*, *type synonyms*, *value
references*, and *module names*. Finally, we will use PackageId
strings as *package identifiers*. ::

Expand Down Expand Up @@ -506,6 +508,9 @@ strings as *package identifiers*. ::
Type constructors
T ::= Name -- TyConName

Type synonym names
S ::= Name -- TypeSynonym

Module names
ModName ::= Name -- ModName

Expand Down Expand Up @@ -676,6 +681,7 @@ available for usage::
| 'variant' T (α₁: k₁)… (αₙ: kₙ) ↦ V₁ : τ₁ | … | Vₘ : τₘ
-- DefVariant
| 'enum' T ↦ E₁ | … | Eₘ -- DefEnum
| 'synonym' S (α₁: k₁)… (αₙ: kₙ) ↦ τ -- DefTypeSynonym
| 'val' W : τ ↦ e -- DefValue
| 'tpl' (x : T) ↦ -- DefTemplate
{ 'precondition' e₁
Expand Down Expand Up @@ -846,6 +852,13 @@ First, we formally defined *well-formed types*. ::
————————————————————————————————————————————— TyTuple
Γ ⊢ ⟨ f₁: τ₁, …, fₙ: τₙ ⟩ : ⋆

'synonym' S (α₁:k₁) … (αₙ:kₙ) ↦ τ ∈ 〚Ξ〛Mod
Γ ⊢ τ₁ : k₁ … Γ ⊢ τₙ : kₙ
————————————————————————————————————————————— TyTypeSynonym
Γ ⊢ S τ₁ … τₙ : ⋆
cocreature marked this conversation as resolved.
Show resolved Hide resolved




Well-formed expression
......................
Expand Down Expand Up @@ -982,6 +995,12 @@ Then we define *well-formed expressions*. ::
——————————————————————————————————————————————————————————————— ExpEnumCon
Γ ⊢ Mod:T:Eᵢ : Mod:T

'synonym' S (α₁:k₁) … (αₙ:kₙ) ↦ τ
Γ ⊢ τ₁ : k₁ ⋯ Γ ⊢ τₙ : kₙ
Γ ↦ e : τ[α₁ ↦ τ₁, …, α₁ ↦ τₙ]
——————————————————————————————————————————————————————————————— ExpTypeSynonym
Γ ⊢ e : Mod:S τ₁ … τₙ

Γ ⊢ e₁ : τ₁ … Γ ⊢ eₘ : τₘ
——————————————————————————————————————————————————————————————— ExpTupleCon
Γ ⊢ ⟨ f₁ = e₁, …, fₘ = eₘ ⟩ : ⟨ f₁: τ₁, …, fₘ: τₘ ⟩
Expand Down Expand Up @@ -1219,6 +1238,10 @@ for the ``DefTemplate`` rule). ::
——————————————————————————————————————————————————————————————— DefEnum
⊢ 'enum' T ↦ E₁ | … | Eₘ

(α₁:k₁) … (αₙ:kₙ) · Γ ⊢ τ : ⋆
——————————————————————————————————————————————————————————————— DefTypeSynonym
⊢ 'synonym' S (α₁: k₁) … (αₙ: kₙ) ↦ τ

ε ⊢ e : τ
——————————————————————————————————————————————————————————————— DefValue
⊢ 'val' W : τ ↦ e
Expand Down