Expand description
Type Synthesis for Eure Documents
This module infers types from Eure document values without requiring a schema. The synthesized types can be used for:
- Generating schema definitions from example data
- Type checking across multiple files
- Editor tooling (hover types, completions)
§Example
ⓘ
use eure_document::document::{EureDocument, NodeId};
use eure_schema::synth::{synth, SynthType};
let doc = eure!({ name = "Alice", age = 30 });
let ty = synth(&doc, doc.get_root_id());
// ty = Record { name: Text, age: Integer }§Unification
When synthesizing arrays, element types are unified:
ⓘ
// [ { a = 1 }, { a = "x", b = "y" } ]
// Result: Array<{ a: Integer } | { a: Text, b: Text }>Holes are absorbed during unification:
ⓘ
// [1, !, 3]
// Result: Array<Integer> (not Array<Integer | Hole>)Structs§
- Synth
Field - A field in a record type
- Synth
Record - A record type with named fields
- Synth
Union - A structural union of types
Enums§
- Synth
Type - A synthesized type inferred from document values.