What would this kind of type system be classified under? [code]
- User
What would this kind of type system be classified under?
type Even Integer = n => n%2==0 type Even.error = n => "value {n} is not even" type Le<V> Numeric = n => n<=V type Le<V>.error = n => "value {n} is not less than or equal to {V}" type Ge<V> Numeric = n => n>=V type Ge<V>.error = n => "value {n} is not greater than or equal to {V}" type Between<min, max> = Ge<min> + Le<max> type Between<min, max>.error = val => "value {val} is not between {min} and {max}" func example(val: Even | Between<1.0, 2.0>) { return val+1 } example(2) // Ok(3) example(3) // Err("value 3 is not even") example("hi") // Err("value 'hi' is of type string and does not match Even or Between<1.0, 2.0>") example(1.9) // Ok(2.9) example(1.0) // Ok(2.0) example(2.1) // Err("value 2.1 is not between 1.0 and 2.0") Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.