alegen 0.2.0

Aleph generator.
Documentation

alegen

Generates Aleph source code from an AlephTree. The native round-trip generator: parse Aleph → transform → emit Aleph.

Installation

[dependencies]

alegen = "0.2"

Usage

let code = alegen::generate(ast);

Example

let ast = AlephTree::Add {
    number_expr1: Box::new(AlephTree::Int { value: "3".into() }),
    number_expr2: Box::new(AlephTree::Int { value: "4".into() }),
};
let code = alegen::generate(ast);
// produces: "3 + 4"

Typed, effect-annotated functions and sum types (0.2+)

Prints AlephTree::TypeDef/Typed/WithEffects nodes (new in aleph-syntax-tree 0.2) as typed function signatures and sum-type declarations:

// AlephTree::TypeDef{name: "Shape", variants: [...]}
// -> "type Shape = Circle(Float) | Rect(Float, Float)"

// AlephTree::WithEffects{inner: Typed{LetRec, Fun}, effects}
// -> "fun square(n: Int) -> Int | pure = {\n    n * n\n}"

Round-trips byte-for-byte with aleparser for these forms when effects are already written in Effect's declared enum order (pure, io, net, mut, act) — EffectSet is a BTreeSet, so a different insertion order still normalizes to that same output.

Related