Skip to content

Commit e60c521

Browse files
nos1dot618claude
andcommitted
docs: add home, install, reference, philosophy, tooling and about pages
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent e14dc02 commit e60c521

6 files changed

Lines changed: 510 additions & 0 deletions

File tree

‎content/about.md‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: About
3+
description: Where Lambda Discipline comes from, how it is built, and how to take part.
4+
---
5+
6+
# About
7+
8+
Lambda Discipline is an open-source functional programming language: lazy,
9+
statically typed and built directly on the lambda calculus. It is developed in
10+
the open by the [lambda-discipline](https://github.com/lambda-discipline)
11+
organization on GitHub.
12+
13+
## History
14+
15+
The language has been implemented more than once, and each version has
16+
learned from the last:
17+
18+
* A first [Rust implementation](https://github.com/lambda-discipline/lambda-discipline-rust-legacy),
19+
now archived.
20+
* A [C++ interpreter](https://github.com/lambda-discipline/lambda-discipline-cpp)
21+
with a REPL, also archived.
22+
* The [current implementation](https://github.com/lambda-discipline/lambda-discipline),
23+
a rewrite in Rust with full Hindley-Milner inference, call-by-need
24+
evaluation, immutable lists, a redesigned set of builtins and a compiler
25+
pipeline built to grow new backends.
26+
27+
## Taking part
28+
29+
Bug reports, language proposals and pull requests are welcome. Start with the
30+
[contributing guide](https://github.com/lambda-discipline/lambda-discipline/blob/master/CONTRIBUTING.md),
31+
and please follow the
32+
[code of conduct](https://github.com/lambda-discipline/lambda-discipline/blob/master/CODE_OF_CONDUCT.md).
33+
Security issues should be reported as described in the
34+
[security policy](https://github.com/lambda-discipline/lambda-discipline/blob/master/SECURITY.md).
35+
36+
## This website
37+
38+
The site is built by a small Python script from the
39+
[lambda-discipline.github.io](https://github.com/lambda-discipline/lambda-discipline.github.io)
40+
repository. Every day it checks the language repository for new commits, and
41+
when there are any it rebuilds: the [builtin reference](/builtins/) comes from
42+
`lbd docs --json`, and every [example](/examples/) is run by the current
43+
interpreter so the output you see is the output you'll get.
44+
45+
## License
46+
47+
Lambda Discipline and this website are released under the
48+
[MIT license](https://github.com/lambda-discipline/lambda-discipline/blob/master/LICENSE.txt).

‎content/index.md‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Lambda Discipline
3+
template: home.html
4+
---
5+
6+
```lbd
7+
-- Types are inferred; annotations are checked.
8+
fibonacci : Number -> Number = \n.
9+
(if (lt n 2) n (add (fibonacci (sub n 1)) (fibonacci (sub n 2))))
10+
11+
compose = \f. \g. \x. (f (g x)) -- (a -> b) -> (c -> a) -> c -> b
12+
13+
(println (map fibonacci (range 0 10))) -- [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
14+
(println ((compose show (mul 2)) 21)) -- 42
15+
```
16+
17+
<ul class="features">
18+
<li><strong>Lambdas, and little else</strong>Programs are applications of <code>\x. body</code> functions, written as S-expressions. The whole grammar fits on a postcard.</li>
19+
<li><strong>Inferred types</strong>Hindley-Milner inference with let-polymorphism. Write annotations when they help you; the checker holds them to their word.</li>
20+
<li><strong>Lazy by default</strong>Call-by-need evaluation: arguments are evaluated only when used, and at most once. Tail calls run in constant space.</li>
21+
<li><strong>Immutable data</strong>Lists are persistent vectors. Every operation returns a new list and leaves the old one exactly as it was.</li>
22+
<li><strong>Errors that help</strong>Several diagnostics per run, each pointing at the code that caused it, with "did you mean" suggestions.</li>
23+
<li><strong>A real compiler</strong>Parser, resolver, type checker and a Core IR in front of a lazy abstract machine, with room for more backends.</li>
24+
</ul>
25+
26+
## A first program
27+
28+
Save this as `hello.lbd`:
29+
30+
```lbd
31+
greet : String -> String = \name. (concat "Hello, " name)
32+
33+
(println (greet "World"))
34+
```
35+
36+
and run it:
37+
38+
```text
39+
$ lbd run hello.lbd
40+
Hello, World
41+
```
42+
43+
Or start `lbd` with no arguments for a REPL, where `:type` shows the type of
44+
any expression:
45+
46+
```text
47+
λ> :type (map (add 1))
48+
(map (add 1)) : List<Number> -> List<Number>
49+
```
50+
51+
## Where to next
52+
53+
* [Install](/install/) the interpreter.
54+
* Read the [language reference](/reference/) and the [builtins](/builtins/).
55+
* Browse the [examples](/examples/), from Hello World to Advent of Code.
56+
* Find out [why the language looks the way it does](/philosophy/).

‎content/install.md‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: Install
3+
description: Install the lbd interpreter with Cargo, or build it from source.
4+
---
5+
6+
# Install
7+
8+
Lambda Discipline is a single binary, `lbd`, that runs programs, type-checks
9+
them and hosts the REPL.
10+
11+
## With Cargo
12+
13+
You need [Rust](https://www.rust-lang.org/tools/install) 1.85 or newer.
14+
15+
```bash
16+
cargo install --git https://github.com/lambda-discipline/lambda-discipline
17+
```
18+
19+
This puts `lbd` in `~/.cargo/bin`, which `rustup` already added to your `PATH`.
20+
21+
## Prebuilt binaries
22+
23+
Tagged versions are published on the
24+
[releases page](https://github.com/lambda-discipline/lambda-discipline/releases)
25+
for Linux (x86-64), macOS (Apple silicon) and Windows (x86-64). Download the
26+
archive for your platform, extract it, and put `lbd` somewhere on your `PATH`.
27+
28+
## From source
29+
30+
```bash
31+
git clone https://github.com/lambda-discipline/lambda-discipline
32+
cd lambda-discipline
33+
cargo build --release
34+
```
35+
36+
The binary is `target/release/lbd`. Run the test suite with `cargo test`.
37+
38+
## Check that it works
39+
40+
```bash
41+
lbd --version
42+
```
43+
44+
```bash
45+
lbd run examples/hello_world.lbd
46+
```
47+
48+
## Using it
49+
50+
| Command | What it does |
51+
| --- | --- |
52+
| `lbd run <file>` | Type-check and run a program. The exit code is 1 on any error. |
53+
| `lbd check <file>` | Type-check without running. |
54+
| `lbd check <file> --emit <stage>` | Print an intermediate representation: `tokens`, `ast`, `types` or `core`. |
55+
| `lbd repl`, or just `lbd` | Start an interactive session. |
56+
| `lbd docs [name] [--json]` | Show the [builtin reference](/builtins/). |
57+
58+
Next, set up your [editor](/tooling/) or start with the
59+
[language reference](/reference/).

‎content/philosophy.md‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: Philosophy
3+
description: The ideas behind Lambda Discipline, and why the language looks the way it does.
4+
---
5+
6+
# Philosophy
7+
8+
> A language should be small enough to hold in your head, and strict enough
9+
> that what you hold there is true.
10+
11+
Lambda Discipline begins with the lambda calculus, the smallest language that
12+
can express any computation: variables, functions of one argument, and
13+
application. Everything else is there to make that core pleasant to write and
14+
safe to run. Where convenience and coherence disagree, coherence wins.
15+
16+
## The lambda is the unit of thought
17+
18+
There are no statements, no loops and no special forms. A program is
19+
definitions and applications of `\x. body` functions, and each application is
20+
an S-expression whose shape *is* its meaning: `(f x y)` applies `f` to `x`,
21+
then to `y`. A grammar this small has no corners to memorize. You learn it once
22+
and then think only about your problem.
23+
24+
Functions take one argument at a time, so partial application is free. The
25+
builtins are designed for it: the data a function works on always comes last,
26+
which makes `(map (add 1))`, `(filter (lt 0))` and `(split ",")` complete,
27+
meaningful functions on their own.
28+
29+
## Discipline means types
30+
31+
The *discipline* is the type system. Every program is checked with
32+
Hindley-Milner inference before a single expression runs, and a program that
33+
doesn't type-check doesn't run. There are no warnings to ignore.
34+
35+
Inference keeps the discipline from becoming bureaucracy. You write
36+
annotations where they say something useful to a reader, and the checker works
37+
out the rest, always finding the most general type. When you do write an
38+
annotation, it is a contract: its type variables are rigid, so a function
39+
can't quietly claim to be more general than it is.
40+
41+
## Laziness is the honest default
42+
43+
Arguments are evaluated when they are needed, and only once. With laziness,
44+
`if`, `and` and `or` need no special treatment: they are ordinary functions
45+
that simply don't touch the branch they don't take. Control flow is just
46+
another thing you can define, pass around and partially apply.
47+
48+
Laziness asks for a runtime that respects it, so tail calls run in constant
49+
space, deep recursion is bounded by memory rather than a fixed stack, and a
50+
value that depends on itself is reported instead of hanging.
51+
52+
## Values don't change
53+
54+
Lists are immutable persistent vectors. Adding, removing or reading an element
55+
returns a new list in logarithmic time and leaves the original exactly as it
56+
was. A name means one thing for its whole life, which is what makes laziness,
57+
sharing and equational reasoning safe.
58+
59+
## Errors are part of the interface
60+
61+
A language is used mostly while it is telling you that you're wrong. Lambda
62+
Discipline reports every independent error it finds in one run, points at the
63+
exact code responsible, and suggests the name you probably meant. Runtime
64+
errors point at the call that failed. Nothing crashes with a stack trace from
65+
the implementation.
66+
67+
## Built like a compiler
68+
69+
Under the interpreter is a conventional compiler pipeline, the shape of rustc
70+
or GHC: a lexer and parser, name resolution, type inference, and a Core IR that
71+
is closure-converted and uncurried. Today that IR feeds a lazy abstract
72+
machine. Tomorrow it can feed a transpiler, a virtual machine or native code
73+
without the front end changing. Builtins are declared once, with their type and
74+
documentation, and every stage reads that one declaration. The
75+
[builtin reference](/builtins/) on this site is generated from it.
76+
77+
## Free to improve
78+
79+
Lambda Discipline is young, and it isn't bound by compatibility with its own
80+
past. Its current implementation is a ground-up rewrite that renamed builtins,
81+
tightened the type system and changed the syntax wherever doing so made the
82+
language more coherent. It will keep doing that while it's young.

0 commit comments

Comments
 (0)