Spec (Galvan by Example)
collections/index.md: [K: V] (ordered dictionary) maps to IndexMap<K, V> — the "currently BTreeMap" caveat was removed.
interop/liftings.md: Rust IndexMap<K, V> lifts to [K: V]; BTreeMap is no longer in the lifting table.
Ordered = insertion order (IndexMap), not key order (BTreeMap).
Current behavior
- Codegen emits
::std::collections::BTreeMap for both the type (galvan-transpiler/src/transpile_item/type.rs:17-22) and literals (codegen/expression.rs:738-739); indexmap is not a dependency anywhere.
- Lifting is inverted vs the book:
classify_wrapper lifts BTreeMap → ordered dict and leaves IndexMap nominal (galvan-rustdoc/src/interop/lift_wrappers.rs:150-174).
Implementation sketch
- Add
indexmap to the runtime crate (root Cargo.toml) and re-export from src/std/mod.rs
- Type lowering →
::galvan::std::IndexMap<K, V>; literal lowering → ::galvan::std::IndexMap::from([...])
- Lifting swap in
lift_wrappers.rs: indexmap::IndexMap (path-aware, like the std checks) → ordered dict; BTreeMap falls through to a nominal imported type
- Update
galvan-rustdoc/LIFTINGS.md (the authoritative contract) and its tests
Watch out
Iteration order changes from sorted to insertion order — audit existing ordered-dict e2e tests/examples for implicit sorted-order assumptions.
Docs
Remove the BTreeMap [!WARNING] in collections/ordered_dictionaries.md and regenerate its Generated Rust blocks.
Part of aligning the implementation with the Galvan by Example book (the book is the spec).
Spec (Galvan by Example)
collections/index.md:[K: V](ordered dictionary) maps toIndexMap<K, V>— the "currentlyBTreeMap" caveat was removed.interop/liftings.md: RustIndexMap<K, V>lifts to[K: V];BTreeMapis no longer in the lifting table.Ordered = insertion order (IndexMap), not key order (BTreeMap).
Current behavior
::std::collections::BTreeMapfor both the type (galvan-transpiler/src/transpile_item/type.rs:17-22) and literals (codegen/expression.rs:738-739);indexmapis not a dependency anywhere.classify_wrapperlifts BTreeMap → ordered dict and leaves IndexMap nominal (galvan-rustdoc/src/interop/lift_wrappers.rs:150-174).Implementation sketch
indexmapto the runtime crate (rootCargo.toml) and re-export fromsrc/std/mod.rs::galvan::std::IndexMap<K, V>; literal lowering →::galvan::std::IndexMap::from([...])lift_wrappers.rs:indexmap::IndexMap(path-aware, like the std checks) → ordered dict;BTreeMapfalls through to a nominal imported typegalvan-rustdoc/LIFTINGS.md(the authoritative contract) and its testsWatch out
Iteration order changes from sorted to insertion order — audit existing ordered-dict e2e tests/examples for implicit sorted-order assumptions.
Docs
Remove the BTreeMap
[!WARNING]incollections/ordered_dictionaries.mdand regenerate its Generated Rust blocks.Part of aligning the implementation with the Galvan by Example book (the book is the spec).