Skip to main content

olean_export/
lib.rs

1//! Read Lean 4 `.olean` files directly and emit the lean4export stream, as NDJSON or in a
2//! compact binary form (blean), without starting Lean.
3#![allow(
4    clippy::missing_errors_doc,
5    clippy::redundant_pub_crate,
6    clippy::too_many_lines,
7    clippy::missing_panics_doc,
8    clippy::module_name_repetitions,
9    clippy::similar_names,
10    clippy::many_single_char_names
11)]
12
13pub mod blean;
14mod env;
15mod error;
16mod export;
17pub mod info;
18mod inspect;
19pub mod ndjson;
20mod olean;
21pub mod record;
22
23pub use env::{
24    resolve, search_path, Binder, Body, Const, Ctor, Defn, Env, Expr, ExprId, Exprs, Hints, Id,
25    Inductive, Kind, Level, LevelId, Name, NameId, QuotKind, Rec, Rule, Table, ANON, ZERO,
26};
27pub use error::{Error, Result};
28pub use export::Exporter;
29pub use info::Info;
30pub use inspect::{Decl, Import, Section, Summary};
31pub use olean::{Header, SUPPORTED};
32pub use record::{Counts, Record, Sink};
33
34const STACK: usize = 1 << 30;
35
36/// Run `f` on a thread with a stack deep enough for long application spines and binder chains,
37/// re-raising its panic if it has one. [`Exporter`] recurses over terms, so run it inside this.
38pub fn with_big_stack<T: Send>(f: impl FnOnce() -> T + Send) -> T {
39    std::thread::scope(|s| {
40        std::thread::Builder::new()
41            .stack_size(STACK)
42            .spawn_scoped(s, f)
43            .expect("spawn")
44            .join()
45            .unwrap_or_else(|e| std::panic::resume_unwind(e))
46    })
47}