lean4-htt/stage0/stdlib/Init
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
..
Control feat: zero cost BaseIO (#10625) 2025-10-22 10:55:12 +02:00
Data feat: zero cost BaseIO (#10625) 2025-10-22 10:55:12 +02:00
Grind feat: zero cost BaseIO (#10625) 2025-10-22 10:55:12 +02:00
GrindInstances chore: update stage0 2025-10-19 23:45:51 +00:00
Internal feat: zero cost BaseIO (#10625) 2025-10-22 10:55:12 +02:00
Meta chore: update stage0 2025-10-19 23:45:51 +00:00
Omega chore: update stage0 2025-10-19 23:45:51 +00:00
System feat: zero cost BaseIO (#10625) 2025-10-22 10:55:12 +02:00
BinderNameHint.c chore: update stage0 2025-10-19 23:45:51 +00:00
BinderPredicates.c chore: update stage0 2025-09-29 14:24:13 +00:00
ByCases.c chore: update stage0 2025-09-29 14:24:13 +00:00
Classical.c chore: update stage0 2025-09-29 14:24:13 +00:00
Coe.c chore: update stage0 2025-09-29 14:24:13 +00:00
Control.c chore: update stage0 2025-09-29 14:24:13 +00:00
Conv.c chore: update stage0 2025-09-29 14:24:13 +00:00
Core.c chore: update stage0 2025-10-19 23:45:51 +00:00
Data.c chore: update stage0 2025-09-30 01:46:26 +00:00
Dynamic.c chore: update stage0 2025-09-29 14:24:13 +00:00
Ext.c chore: update stage0 2025-09-29 14:24:13 +00:00
GetElem.c chore: update stage0 2025-09-29 14:24:13 +00:00
Grind.c chore: update stage0 2025-09-29 14:24:13 +00:00
GrindInstances.c chore: update stage0 2025-09-29 14:24:13 +00:00
Guard.c chore: update stage0 2025-10-19 23:45:51 +00:00
Hints.c chore: update stage0 2025-09-29 14:24:13 +00:00
Internal.c chore: update stage0 2025-09-29 14:24:13 +00:00
LawfulBEqTactics.c chore: update stage0 2025-10-19 23:45:51 +00:00
MacroTrace.c chore: update stage0 2025-09-29 14:24:13 +00:00
Meta.c chore: update stage0 2025-10-19 23:45:51 +00:00
MetaTypes.c chore: update stage0 2025-10-01 12:32:50 +00:00
MethodSpecsSimp.c chore: update stage0 2025-09-29 14:24:13 +00:00
Notation.c chore: update stage0 2025-09-29 14:24:13 +00:00
NotationExtra.c feat: zero cost BaseIO (#10625) 2025-10-22 10:55:12 +02:00
Omega.c chore: update stage0 2025-09-29 14:24:13 +00:00
Prelude.c feat: zero cost BaseIO (#10625) 2025-10-22 10:55:12 +02:00
PropLemmas.c chore: update stage0 2025-10-19 23:45:51 +00:00
RCases.c chore: update stage0 2025-10-19 23:45:51 +00:00
ShareCommon.c chore: update stage0 2025-10-19 23:45:51 +00:00
SimpLemmas.c chore: update stage0 2025-09-29 14:24:13 +00:00
Simproc.c feat: zero cost BaseIO (#10625) 2025-10-22 10:55:12 +02:00
SizeOf.c chore: update stage0 2025-09-29 14:24:13 +00:00
SizeOfLemmas.c chore: update stage0 2025-10-19 23:45:51 +00:00
Syntax.c chore: update stage0 2025-09-29 14:24:13 +00:00
System.c chore: update stage0 2025-09-29 14:24:13 +00:00
Tactics.c chore: update stage0 2025-09-29 14:24:13 +00:00
TacticsExtra.c chore: update stage0 2025-10-19 23:45:51 +00:00
Task.c chore: update stage0 2025-10-19 23:45:51 +00:00
Try.c chore: update stage0 2025-09-29 14:24:13 +00:00
Util.c chore: update stage0 2025-09-29 14:24:13 +00:00
WF.c chore: update stage0 2025-10-19 23:45:51 +00:00
WFTactics.c chore: update stage0 2025-10-19 23:45:51 +00:00
While.c chore: update stage0 2025-09-29 14:24:13 +00:00