Skip to content

Commit 1f861be

Browse files
committed
Title cased everything
1 parent 965bd95 commit 1f861be

File tree

7 files changed

+113
-83
lines changed

7 files changed

+113
-83
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ competitors if your project requires:
4343

4444
## Documentation
4545

46-
- [Compiler](./docs/compiler.md)
46+
- [Design](./docs/design.md),
47+
- [Compiler](./docs/compiler.md),
48+
- [Codegen](./docs/codegen.md),
49+
- [Comparison matrix](./docs/comparison-matrix.md),
50+
- [User feedback](.docs/feedback)
4751

4852
## Getting started
4953

docs/codegen.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# LambdaBuffers Codegen Spec & Design
1+
# LambdaBuffers Codegen
22

33
NOTE: The implementation of the code generation framework is still in early stages and will likely undergo substantial changes as development continues. This document serves to outline general principles that any implementation of the LambdaBuffers code generation framework ought to adhere to.
44

@@ -9,23 +9,23 @@ NOTE: The implementation of the code generation framework is still in early stag
99
3. Extensible to new opaque types
1010
4. Extensible to new type classes
1111

12-
### Modular & reusable components
12+
### Modular & Reusable Components
1313

1414
Because the code generation modules for each target language will almost certainly constitute the bulk of the final LambdaBuffers codebase, it is essential that components of the code generation framework be as modular and reusable as is practicable.
1515

1616
Although each target language has its own distinct syntax and semantics, many syntactic forms exist in multiple target languages. For example, Haskell and PureScript both use a comma-separated set enclosed in square brackets (e.g. `[1,2,3]`) to represent a `List _/[_]` value, while Rust uses a similar form (in conjunction with a macro, e.g. `vec![1,2,3]`) to represent a `Vector<_>` value. To reduce redundant and superfluous code, common syntactic patterns such at this should be abstracted out into a set of functions that can be reused across languages.
1717

18-
### Ergonomic interface
18+
### Ergonomic Interface
1919

2020
While the LambdaBuffers team will support a finite set of specific target languages, adding support for an additional language should be as painless as possible (ceteris paribus) to encourage and facilitate open source contributions by third parties. A basic set of tools which can be used to write code generation modules for any target language should be developed, and all code generation modules written by the LambdaBuffers team should employ those tools (in order to provide a robust set of examples for future contributors, among other benefits).
2121

22-
### Extensible to new opaque types
22+
### Extensible to New Opaque Types
2323

2424
Users and contributors should be able to easily extend the default set of supported opaque types to support additional opaque types. In the context of code generation, this means: Users should have the ability to specify the target type for a given opaque type in the target language (including the package or module that contains the target type if the target type is not part of the language's standard library).
2525

2626
Because type class instances must be derived structurally, and because an opaque type is by definition a type with no visible internal structure, users should be provided with an ergonomic interface for noting the presence of a type class instance for an opaque type's target type in a particular language (if the instance exists in the standard library), or for referring to the module where such an instance is located (if the instance is defined in a library or by the user in one of their own modules).
2727

28-
### Extensible to new type classes
28+
### Extensible to New Type Classes
2929

3030
Users and contributors should be able to easily extend the default set of supported type classes to support additional type classes and facilitate the derivation of instances for newly defined classes.
3131

docs/command-line-interface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# LambdaBuffers command line interface
1+
# LambdaBuffers Command Line Interface
22

33
LambdaBuffers consists of three runtime command line interface components:
44

docs/comparison-matrix.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Legend:
1111
- ❔ Not clear
1212

1313
| **Feature** | **Proto Buffers** | **ADL** | **JSON Schema** | **Lambda Buffers** | **CDDL** | **ASN.1** |
14-
|--------------------------------------------------------|-------------------|--------------|-----------------|--------------------|----------|--------------|
15-
| Sum Types | 🟢 | 🟢 | 🔴 | 🟢 | 🟢 | 🟢 |
16-
| Record Types | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
17-
| Product Types | 🔴 | 🔴 | 🔴 | 🟢 || 🔴 |
18-
| Recursive Types | 🟢 | 🟢 | 🔴 | 🟢 | 🟢 ||
19-
| Type functions (Generics) | 🔴 | 🟢 | 🔴 | 🟢 | 🟢 | 🔴 |
14+
|--------------------------------------------------------+-------------------+--------------+-----------------+--------------------+----------+--------------|
15+
| Sum types | 🟢 | 🟢 | 🔴 | 🟢 | 🟢 | 🟢 |
16+
| Record types | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
17+
| Product types | 🔴 | 🔴 | 🔴 | 🟢 || 🔴 |
18+
| Recursive types | 🟢 | 🟢 | 🔴 | 🟢 | 🟢 ||
19+
| Parameterized types (generic types) | 🔴 | 🟢 | 🔴 | 🟢 | 🟢 | 🔴 |
2020
| Type annotations/constraints | 🟢 | 🟢 | 🟢 | 🔵 | 🟢 | 🟢 |
2121
| Add new builtin types | 🔴 | 🟢 | 🔴 | 🟢 | 🔴 | 🔴 |
2222
| Add new type semantics (e.g. different encodings) | 🟢 | 🟢 | 🔴 | 🟢 | 🔴 | 🟢 |
@@ -31,7 +31,38 @@ Legend:
3131
| Language specification | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
3232
| Backwards compatibility strategy | 🟢 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 |
3333

34-
:todo: add chapter elaborating on each feature
34+
## Features
35+
36+
### Sum types
37+
38+
A type that can take on several different forms, also referred to as a *tagged
39+
union* or a *variant* (see https://en.wikipedia.org/wiki/Tagged_union).
40+
41+
An example sum type definition in Haskell
42+
43+
```haskell
44+
45+
data Either a b = Left a | Right b
46+
```
47+
### Record types
48+
49+
A record type is essentially a product type where each field is accompanied by a
50+
field name (https://en.wikipedia.org/wiki/Product_type)
51+
52+
### Product types
53+
54+
A product type is a tuple of types.
55+
56+
### Recursive types
57+
58+
Recursive types are types that are defined in terms of themselves.
59+
60+
```haskell
61+
62+
data List a = Nil | Cons a (List a)
63+
data Tree a = Leaf a | Branch (Tree a) (Tree a)
64+
```
65+
3566
## References
3667

3768
- https://json-schema.org/implementations.html

docs/compiler.md

Lines changed: 55 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# LambdaBuffers _Compiler_ Spec & Design
1+
# LambdaBuffers Compiler
22

33
The _Compiler_ component sits between the _Frontend_ component and the code
44
generation component named _Codegen_. The purpose of the _Compiler_ is to
@@ -12,7 +12,7 @@ The end goal of the _Compiler_ is to ensure that the _Codegen_ component is
1212
capable of processing the _Compiler Output_ by providing correct and complete
1313
information.
1414

15-
## _Compiler_ interface
15+
## Compiler Interface
1616

1717
The _Compiler_ operates on the _Compiler Input_ message specified in the
1818
[compiler.proto](../lambda-buffers-proto/compiler.proto) [Google Protocol
@@ -28,7 +28,7 @@ communicating via [Google Protocol Buffers](https://protobuf.dev/).
2828
Refer to the [Compiler Proto
2929
documentation](../lambda-buffers-proto/compiler-proto.md) for more information.
3030

31-
## Checking type definitions (kind checking)
31+
## Checking Type Definitions
3232

3333
The first step the Compiler performs is _kind checking and inference_ on [type
3434
definitions](../lambda-buffers-proto/compiler-proto.md#lambdabuffers-compiler-TyDef)
@@ -40,9 +40,9 @@ term](../lambda-buffers-proto/compiler-proto.md#lambdabuffers-compiler-Ty) with
4040
[kind](../lambda-buffers-proto/compiler-proto.md#lambdabuffers-compiler-Kind)
4141
information.
4242

43-
In standard _type checking_ terminology LambdaBuffers terms are [abstract data
43+
In standard _type checking_ terminology LambdaBuffers 'terms' are [abstract data
4444
type](https://en.wikipedia.org/wiki/Abstract_data_type) declarations and their
45-
types are kinds.
45+
'types' are _kinds_.
4646

4747
Currently, the _Compiler_ accepts:
4848

@@ -64,7 +64,54 @@ terms must be monomorphically kinded, with polymorphic kinds defaulting to
6464
monomorphic ones. For example `Phantom a = Phantom` would resolve to the
6565
monomorphic kind `Type → Type` rather than the polymorphic kind `∀a. a → Type`.
6666

67-
## Checking type cardinality
67+
### Kind Checker
68+
69+
The kind checker is designed around a simply typed lambda calculus type system
70+
with inference via unification (_John Alan Robinson's_ unification algorithm is
71+
being currently used). We've also introduced a `let` binding rule that allows
72+
later additions to the typing context. The typing rules are the following:
73+
74+
```text
75+
x : σ ∈ Γ
76+
----------- [Variable]
77+
Γ ⊢ x : σ
78+
79+
80+
Γ,x:σ ⊢ e:τ
81+
------------------------ [Abstraction]
82+
Γ ⊢ (λ x:σ. e):(σ → τ)
83+
84+
85+
Γ ⊢ x:(σ → τ) Γ ⊢ y:σ
86+
------------------------- [Application]
87+
Γ ⊢ x y : τ
88+
89+
90+
Γ ⊢ e₁:σ Γ, e₁ : σ ⊢ e₂:τ
91+
----------------------------- [Let]
92+
Γ ⊢ let x = e₁ in e₂ : τ
93+
```
94+
95+
The type checking strategy is as follows:
96+
97+
1. A context is built from the type definitions. Type variables which are not
98+
annotated with any further kind information are defaulted to be of kind
99+
`Type`.
100+
101+
2. The RHS of the type terms are converted into their _Sums of Products_
102+
canonical representation. The variables from the left hand side of the term
103+
are introduced to the right hand side as abstractions.
104+
105+
3. The derivation for each term is built.
106+
107+
4. Then the unification tries to find a solution.
108+
109+
Terms for which unification cannot find a consistent derivation are deemed
110+
incorrect and a kind checking error is thrown. Note that currently all of the
111+
inferred kinds have a restriction to be monomorphic - therefore no free or
112+
universally quantified variables can appear in the final kind signature.
113+
114+
## Checking Type Cardinality
68115

69116
In addition to _kind checking_, the Compiler could perform a special check for
70117
types to determine their cardinality. This is especially useful to catch and
@@ -78,7 +125,7 @@ ill-defined.
78125
This problem is equivalent to a problem of [calculating graph
79126
components](https://en.wikipedia.org/wiki/Component_(graph_theory)).
80127

81-
## Normalizing type definitions
128+
## Normalizing Type Definitions
82129

83130
Finally, the compiler should be able to _normalize_ expressions. For example, it
84131
may be possible to define a data type in the schema language in a form similar
@@ -87,7 +134,7 @@ the order of application within the term. The example term would normalize to
87134
`data G a = G (Either (Maybe a) Int)` - resulting in a cleaner (and more
88135
performant) code generation.
89136

90-
## Checking typeclass definitions and instance clauses
137+
## Checking Typeclass Definitions and Instance Clauses
91138

92139
The _Compiler_ should, if possible, ensure that all instance declarations for
93140
schemata are derivable using hard-coded derivation axioms.
@@ -132,56 +179,4 @@ sufficiently rich to express typeclass relations, we will generate instances
132179
using idiomatic language features. (The details will depend on the particular
133180
language.)
134181

135-
## Kind Checker
136-
137-
The kind checker is designed around a simply typed lambda calculus type system
138-
with inference via unification (_John Alan Robinson's_ unification algorithm is
139-
being currently used). We've also introduced a `let` binding rule that allows
140-
later additions to the typing context. The typing rules are the following:
141-
142-
```text
143-
x : σ ∈ Γ
144-
----------- [Variable]
145-
Γ ⊢ x : σ
146-
147-
148-
Γ,x:σ ⊢ e:τ
149-
------------------------ [Abstraction]
150-
Γ ⊢ (λ x:σ. e):(σ → τ)
151-
152-
153-
Γ ⊢ x:(σ → τ) Γ ⊢ y:σ
154-
------------------------- [Application]
155-
Γ ⊢ x y : τ
156-
157-
158-
Γ ⊢ e₁:σ Γ, e₁ : σ ⊢ e₂:τ
159-
----------------------------- [Let]
160-
Γ ⊢ let x = e₁ in e₂ : τ
161-
```
162-
163-
The type checking strategy is as follows:
164-
165-
1. A context is built from the type definitions. Type variables which are not
166-
annotated with any further kind information are defaulted to be of kind
167-
`Type`.
168-
169-
2. The RHS of the type terms are converted into their _Sums of Products_
170-
canonical representation. The variables from the left hand side of the term
171-
are introduced to the right hand side as abstractions.
172-
173-
3. The derivation for each term is built.
174-
175-
4. Then the unification tries to find a solution.
176-
177-
Terms for which unification cannot find a consistent derivation are deemed
178-
incorrect and a kind checking error is thrown. Note that currently all of the
179-
inferred kinds have a restriction to be monomorphic - therefore no free or
180-
universally quantified variables can appear in the final kind signature.
181-
182-
## Unsolved Problems
183-
184-
- [ ] How would cardinality checking be integrated within our current checking
185-
strategy?
186-
187182
## Missing link

docs/design.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# LambdaBuffers design
1+
# LambdaBuffers Design
22

33
The goal of the LambdaBuffers project is to enable software developers to
44
specify their application types in a common format that can be conveniently
55
shared and their values effectively communicated across language barriers.
66

7-
## Problem statement
7+
## Problem Statement
88

99
Software projects that span multiple language environments often interact in a
1010
sub-optimal manner. Significant effort is spent in making application messages
@@ -27,7 +27,7 @@ costs to the business and unsustainable technical debt.
2727
5. Universally consistent semantics,
2828
6. Modular API architecture.
2929

30-
### Expressive types
30+
### Expressive Types
3131

3232
Application types that users can define should be expressive enough to
3333
facilitate type driven domain modeling and to express application
@@ -43,7 +43,7 @@ parameterized, effectively enabling generic types. LambdaBuffers also supports
4343
recursive type definitions, which allow users to succinctly define elegant and
4444
expressive data structures.
4545

46-
### Expressive semantics annotation
46+
### Expressive Semantics Annotation
4747

4848
Enabling users to manage the *semantics* associated with their types is
4949
essential for adapting LambdaBuffers to a variety of different domains and use
@@ -82,7 +82,7 @@ document for a given type class.
8282
For each new type class declared, code generation tooling must be updated to
8383
handle the new type class.
8484

85-
### Extensible to new types
85+
### Extensible to New Types
8686

8787
Enabling users to introduce new *built-in* types allows LambdaBuffers to be
8888
adapted in many different domains and use cases.
@@ -105,7 +105,7 @@ equipped with rich libraries that work with them. Redefining them *ab ovo* would
105105
be counterproductive as users would have to re-implement and reinvent the rich
106106
support for such types.
107107

108-
### Extensible to new semantics
108+
### Extensible to New Semantics
109109

110110
Enabling users to introduce new *type semantics* facilitates LambdaBuffers to be
111111
adapted in many different domains and use cases.
@@ -134,7 +134,7 @@ provide code generation modules for a set of officially supported language
134134
environments. However, modular design will hopefully facilitate community
135135
contributions in a sustainable fashion.
136136

137-
### Universally consistent semantics
137+
### Universally Consistent Semantics
138138

139139
The types specified by users must be handled in a compatible manner across
140140
language environments. This is a critical requirement that underpins this
@@ -150,7 +150,7 @@ LambdaBuffers does not provide a way to formally verify consistency across langu
150150
however, a comprehensive test suite will be developed to ensure that new code
151151
generation modules are indeed implemented correctly.
152152

153-
### Modular API architecture
153+
### Modular API Architecture
154154

155155
LambdaBuffers establishes three separate components of the architecture, namely
156156
*Frontend*, *Compiler* and *Codegen**.

docs/feedback/interview-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1. Introduction - what is Lambda Buffers and what is Lambda Buffers' aim.
1515
2. Interviews
1616

17-
## Meeting minutes
17+
## Meeting Minutes
1818

1919
1. Drazen introduces what Lambda Buffers is, and how it relates to the target languages. Points touched on:
2020
1. Tooling

0 commit comments

Comments
 (0)