Crate lean_sys

source ·
Expand description

Rust bindings to Lean 4’s C API

Functions and comments manually translated from those in the lean.h header provided with Lean 4

Re-exports

pub use array::*;
pub use closure::*;
pub use constructor::*;
pub use dbg::*;
pub use external::*;
pub use init::*;
pub use int::*;
pub use io::*;
pub use nat::*;
pub use primitive::*;
pub use sarray::*;
pub use string::*;
pub use task::*;
pub use thunk::*;

Modules

Closures
Constructor objects
Debugging helper functions
External objects
Utilities for initializing Lean’s runtime
Integers
IO Helper functions
Natural numbers
Primitive operations
Array of scalars
Strings
Tasks
Thunks

Structs

Array arrays
Lean object header.
Scalar arrays
Object of type Task _. The lifetime of a lean_task object can be represented as a state machine with atomic state transitions.
Data required for executing a Lean task. It is released as soon as the task terminates even if the task object itself is still referenced.

Constants

Functions

Box a usize into a lean_object
Just free memory
Whether an object is reference counted
Whether an object is multi-threaded
Whether this lean object is a scalar
Whether an object is single-threaded
The object size may be slightly bigger for constructor objects. The runtime does not track the size of the scalar size area. All constructor objects are “small”, and allocated into pages. We retrieve their size by accessing the page header. The size of small objects is a multiple of LEAN_OBJECT_SIZE_DELTA
Remark: we don’t need a reference counter for objects that are not stored in the heap. Thus, we use the area to store the object size for small objects.
lean_set_non_heap_header for (potentially) big objects such as arrays and strings.
Enable/disable panic messages
Unbox a lean_object into a usize
Perform a relaxed load of the reference counter of o, which must be a pointer into a valid lean_object

Type Definitions

Borrowed object argument
Borrowed object result
Standard object argument
Standard object result
Unique (aka non shared) object argument