feat: implement Schema module for versioned types
Add Schema module with functions for creating and migrating versioned values. This provides the runtime foundation for schema evolution. Schema module functions: - Schema.versioned(typeName, version, value) - create versioned value - Schema.migrate(value, targetVersion) - migrate to new version - Schema.getVersion(value) - get version number Changes: - Add Versioned, Migrate, GetVersion builtins to interpreter - Add Schema module to global environment - Add Schema module type to type environment - Add 4 tests for schema operations - Add examples/versioning.lux demonstrating usage Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
23
src/types.rs
23
src/types.rs
@@ -1115,6 +1115,29 @@ impl TypeEnv {
|
||||
TypeScheme::mono(Type::function(vec![Type::var()], Type::String)),
|
||||
);
|
||||
|
||||
// Schema module for versioned types
|
||||
let schema_module_type = Type::Record(vec![
|
||||
(
|
||||
"versioned".to_string(),
|
||||
Type::function(
|
||||
vec![Type::String, Type::Int, Type::var()],
|
||||
Type::var(), // Returns Versioned (treated as Any for now)
|
||||
),
|
||||
),
|
||||
(
|
||||
"migrate".to_string(),
|
||||
Type::function(
|
||||
vec![Type::var(), Type::Int],
|
||||
Type::var(), // Returns Versioned
|
||||
),
|
||||
),
|
||||
(
|
||||
"getVersion".to_string(),
|
||||
Type::function(vec![Type::var()], Type::Int),
|
||||
),
|
||||
]);
|
||||
env.bind("Schema", TypeScheme::mono(schema_module_type));
|
||||
|
||||
env
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user