feat: add schema evolution type system integration and HTTP server effect
Schema Evolution: - Preserve version info in type resolution (Type::Versioned) - Track versioned type declarations in typechecker - Detect version mismatches at compile time (@v1 vs @v2 errors) - Support @v2+ (at least) and @latest version constraints - Store migrations for future auto-migration support - Fix let bindings to preserve declared type annotations HTTP Server Effect: - Add HttpServer effect with listen, accept, respond, respondWithHeaders, stop - Implement blocking request handling via tiny_http - Request record includes method, path, body, headers - Add http_server.lux example with routing via pattern matching - Add type-checking test for HttpServer effect Tests: 222 passing (up from 217) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
49
src/types.rs
49
src/types.rs
@@ -1074,6 +1074,55 @@ impl TypeEnv {
|
||||
},
|
||||
);
|
||||
|
||||
// Add HttpServer effect
|
||||
let http_request_type = Type::Record(vec![
|
||||
("method".to_string(), Type::String),
|
||||
("path".to_string(), Type::String),
|
||||
("body".to_string(), Type::String),
|
||||
("headers".to_string(), Type::List(Box::new(Type::Tuple(vec![Type::String, Type::String])))),
|
||||
]);
|
||||
env.effects.insert(
|
||||
"HttpServer".to_string(),
|
||||
EffectDef {
|
||||
name: "HttpServer".to_string(),
|
||||
type_params: Vec::new(),
|
||||
operations: vec![
|
||||
EffectOpDef {
|
||||
name: "listen".to_string(),
|
||||
params: vec![("port".to_string(), Type::Int)],
|
||||
return_type: Type::Unit,
|
||||
},
|
||||
EffectOpDef {
|
||||
name: "accept".to_string(),
|
||||
params: vec![],
|
||||
return_type: http_request_type.clone(),
|
||||
},
|
||||
EffectOpDef {
|
||||
name: "respond".to_string(),
|
||||
params: vec![
|
||||
("status".to_string(), Type::Int),
|
||||
("body".to_string(), Type::String),
|
||||
],
|
||||
return_type: Type::Unit,
|
||||
},
|
||||
EffectOpDef {
|
||||
name: "respondWithHeaders".to_string(),
|
||||
params: vec![
|
||||
("status".to_string(), Type::Int),
|
||||
("body".to_string(), Type::String),
|
||||
("headers".to_string(), Type::List(Box::new(Type::Tuple(vec![Type::String, Type::String])))),
|
||||
],
|
||||
return_type: Type::Unit,
|
||||
},
|
||||
EffectOpDef {
|
||||
name: "stop".to_string(),
|
||||
params: vec![],
|
||||
return_type: Type::Unit,
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
// Add Some and Ok, Err constructors
|
||||
// Some : fn(a) -> Option<a>
|
||||
let a = Type::var();
|
||||
|
||||
Reference in New Issue
Block a user