alegen
Generates Aleph source code from an AlephTree.
The native round-trip generator: parse Aleph → transform → emit Aleph.
Installation
[]
= "0.2"
Usage
let code = generate;
Example
let ast = Add ;
let code = generate;
// 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
aleph-syntax-tree— AST definitionaleparser— Aleph parseralephc— uses this generator with--features ale_gen