lean4-htt/doc
Henrik Böving 52b1b342ab
feat: zero cost BaseIO (#10625)
This PR implements zero cost `BaseIO` by erasing the `IO.RealWorld`
parameter from argument lists and structures. This is a **major breaking
change for FFI**.

Concretely:
- `BaseIO` is defined in terms of `ST IO.RealWorld`
- `EIO` (and thus `IO`) is defined in terms of `EST IO.RealWorld`
- The opaque `Void` type is introduced and the trivial structure
optimization updated to account for it. Furthermore, arguments of type
`Void s` are removed from the argument lists of the C functions.
- `ST` is redefined as `Void s -> ST.Out s a` where `ST.Out` is a pair
of `Void s` and `a`

This together has the following major effects on our generated code:
- Functions that return `BaseIO`/`ST`/`EIO`/`IO`/`EST` now do not take
the dummy world parameter anymore. To account for this FFI code needs to
delete the dummy world parameter from the argument lists.
- Functions that return `BaseIO`/`ST` now return their wrapped value
directly. In particular `BaseIO UInt32` now returns a `uint32_t` instead
of a `lean_object*`. To account for this FFI code might have to change
the return type and does not need to call `lean_io_result_mk_ok` anymore
but can instead just `return` values right away (same with extracting
values from `BaseIO` computations.
- Functions that return `EIO`/`IO`/`EST` now only return the equivalent
of an `Except` node which reduces the allocation size. The
`lean_io_result_mk_ok`/`lean_io_result_mk_error` functions were updated
to account for this already so no change is required.

Besides improving performance by dropping allocation (sizes) we can now
also do fun new things such as:
```lean
@[extern "malloc"]
opaque malloc (size : USize) : BaseIO USize
```
2025-10-22 10:55:12 +02:00
..
dev feat: zero cost BaseIO (#10625) 2025-10-22 10:55:12 +02:00
examples chore: eliminate uses of intros x y z (#9983) 2025-08-19 06:09:13 +00:00
images doc: update quickstart guide for new display name (#5193) 2024-08-28 13:29:16 +00:00
latex doc: upstream the Lean4 pygments lexer (#3125) 2024-05-20 11:40:24 +00:00
make doc: fix broken "quickstart" and "supported editors" link (#8785) 2025-09-02 12:45:04 +00:00
std chore: Grove: bump version (#9419) 2025-07-17 15:02:17 +00:00
.gitignore doc: mdbook init 2020-10-30 14:23:47 +01:00
BoolExpr.lean chore: Std -> Batteries renaming (#4108) 2024-05-08 05:04:25 +00:00
metaprogramming-arith.lean refactor: remove some unnecessary antiquotation kind annotations 2022-07-23 17:09:32 +02:00
perf.md doc: add basic perf documentation 2021-09-06 07:12:36 -07:00
README.md chore: remove old documentation site (#7974) 2025-05-14 14:31:33 +00:00
style.md doc: add documentation style guide (#8199) 2025-05-02 13:05:18 +00:00
syntax_example.lean doc: fix example style 2022-04-22 16:26:16 +02:00

Developer Documentation and Examples

This directory contains documentation that describes how to work on Lean itself, as well as examples that are included in documentation that's hosted on the Lean website. The make directory contains information on building Lean, and the dev directory describes how to work on Lean.

The documentation section has links to documentation that describes how to use Lean itself.