2019-08-29 20:46:42 -07:00
# James Martin's Lambda Calculus
2020-04-06 15:02:56 -07:00
This project is a tool for me to learn about implementing various concepts from programming language theory, in particular those that relate to the lambda calculus.
I also hope to equip it with enough useful features that it is a usable for real programming tasks, at least as a toy.
Ideally, this will also be a useful tool for *others* to learn about the lambda calculus through experimentation.
2019-08-15 10:42:24 -07:00
## Usage
Type in your expression at the prompt: `>> ` .
The result of the evaluation of that expression will then be printed out.
Exit the prompt with `Ctrl-C` (or however else you kill a program in your terminal).
Bound variables will be printed followed by a number representing the number of binders
between it and its definition for disambiguation.
2019-08-19 15:08:45 -07:00
2019-08-21 15:18:25 -07:00
### Example session
2019-08-15 10:42:24 -07:00
```
2019-08-21 15:18:25 -07:00
>> let D = (\x. x x) in let F = (\f. f (f y)) in D (F ())
2019-08-15 10:42:24 -07:00
y y
2019-08-21 15:18:25 -07:00
>> let T = (\f x. f (f x)) in (\f x. T (T (T (T T))) f x) () y
2019-08-15 13:11:17 -07:00
y
2019-08-15 10:42:24 -07:00
>> \x. \y. y x
\x. \y. y:0 x:1
2019-08-21 15:18:25 -07:00
>> ^C
2019-08-15 10:42:24 -07:00
```
2019-08-21 15:18:25 -07:00
## Notation
[Conventional Lambda Calculus notation applies ](https://en.wikipedia.org/wiki/Lambda_calculus_definition#Notation ),
with the exception that variable names are mmultiple characters long,
and `\` is used in lieu of `λ` for convenience.
* Variable names are alphanumeric, beginning with a letter.
* Outermost parentheses may be dropped: `M N` is equivalent to `(M N)` .
* Applications are left-associative: `M N P` may be written instead of `((M N) P)` .
* The body of an abstraction extends as far right as possible: `\x. M N` means `\x.(M N)` and not ``(\x. M) N`.
* A sequence of abstractions may be contracted: `\foo. \bar. \baz. N` may be abbreviated as `\foo bar baz. N` .
* Variables may be bound using let expressions: `let x = N in M` abbreviates `(\x. N) M` .
### Violations of convention
* I use spaces to separate variables in abstractions instead of commas because I think it looks better.
### Additional extensions to notation
Since `\x. x` is the left identity of applications and application syntax is left-associative,
I (syntactically) permit unary and nullary applications so that `()` is `\x. x` , and `(x)` is `x` .
2019-08-15 10:42:24 -07:00
2019-08-21 15:18:25 -07:00
On the same principle, the syntax of a lambda of no variables `\. e` is `e` .
2019-08-29 20:46:42 -07:00
## Roadmap
### Complete
* Type systems:
* Untyped
* Representations:
* The syntax tree
* Reverse de Bruijn
* Syntax:
* Basic syntax
* Let expressions
* Evaluation strategies:
* Lazy (call-by-name to normal form)
### Planned
2020-04-06 15:02:56 -07:00
Not all of these will necessarily (or even probably) be implemented.
This is more-or-less a wishlist of things I'd like to try to implement some day.
2019-08-29 20:46:42 -07:00
* Built-ins:
* Integers
2020-04-06 15:02:56 -07:00
* Characters
* Strings
* Lists
2019-08-29 20:46:42 -07:00
* Type systems:
2020-04-06 15:02:56 -07:00
* all of the systems of the Lambda Cube
2019-08-29 20:46:42 -07:00
* Hindley-Milner
2020-04-06 15:02:56 -07:00
* and the calculus of (co)inductive constructions
* and something based on cubical TT
* and something with universe polymorphism
* and something with insanely dependent types
* and support for tactics
* and something with non-trivial subtyping
* and something with row polymorphism
* and something with typeclasses/constraints
* and something with irrelevance (runtime, true irrelevance, prop)
* and something with iso/equirecursive types?
* (classical?) linear types
* something with lifetimes, like Rust
* something that would work on a quantum computer, at least in theory
* something with proof nets?
* Macros, fexprs
* (Delimited) continuations
* Something based on lambda-mu?
* Effects:
* A (co)effects system.
* Call-by-push-value.
2019-08-29 20:46:42 -07:00
* Representations:
* A more conservative syntax tree that would allow for better error messages
* Evaluation strategies:
2020-04-06 15:02:56 -07:00
* The evaluation strategies documented by Thierry(?)
* Full laziness
* Complete laziness
2019-08-29 20:46:42 -07:00
* Optimal
* Syntax:
* Top-level definitions
* Type annotations
* `let*` , `letrec`
* Pretty-printing mode.
* Indentation-based syntax.
* Features:
* A better REPL (e.g. the ability to edit the line buffer)
* The ability to import external files
2020-04-06 15:02:56 -07:00
* A good module system?
2019-08-29 20:46:42 -07:00
* The ability to choose the type system or evaluation strategy
* Better error messages for parsing and typechecking
* Reduction stepping