CueValue
A CUE value representing a compiled CUE expression.
CueValue wraps a CUE evaluator value and provides methods for validation, unification, field lookup, iteration, and conversion to native Maggie types. CueValues are immutable — operations like unify: and fillPath:with: return new CueValues.
| ctx <CueContext> val <CueValue> |
ctx := CueContext new.
val := (ctx compileString: 'x: 1, y: 2') value.
val lookup: 'x'
"Convert CUE struct to Maggie Dictionary"
| ctx <CueContext> val <CueValue> |
ctx := CueContext new.
val := (ctx compileString: 'a: 1, b: "hello"') value.
val toMaggie
Instance Methods
primitives
uncategorized
Return the error string if this value has an error, nil otherwise.
Return true if this value exists (is not a CUE bottom value).
Return a Dictionary mapping field names to CueValues. Only works on struct-kinded values.
| ctx <CueContext> val <CueValue> |
ctx := CueContext new.
val := (ctx compileString: 'a: 1, b: 2') value.
val fields value
Fill a path with a value, returning a new CueValue. Useful for injecting concrete values into CUE templates.
| ctx <CueContext> val <CueValue> filled <CueValue> |
ctx := CueContext new.
val := (ctx compileString: 'x: _, result: x') value.
filled := (val fillPath: 'x' with: 42) value.
(filled lookup: 'result') value toMaggie
Return true if this CUE value is fully resolved (concrete), false if it still has constraints or placeholders.
Return the CUE kind of this value as a string symbol (e.g., 'struct', 'int', 'string', 'list', 'bool').
Look up a field by dot-separated path string. Returns a Result wrapping the field's CueValue.
| ctx <CueContext> val <CueValue> |
ctx := CueContext new.
val := (ctx compileString: 'a: {b: {c: 42}}') value.
((val lookup: 'a.b.c') value toMaggie) >>> 42
Test whether this CUE value (as a template/schema) matches an object. Projects the object's instance variables into a CUE struct and unifies with this value. Returns true if unification succeeds (no bottom).
ctx := CueContext new.
intSchema := (ctx compileString: 'int') value.
intSchema matchesObject: 42 >>> true
intSchema matchesObject: 'hello' >>> false
strSchema := (ctx compileString: 'string') value.
strSchema matchesObject: 'hello' >>> true
strSchema matchesObject: 42 >>> false
Return a human-readable string representation.
Check if this CUE value is subsumed by (is more specific than) another. Returns true if other is a valid constraint that self satisfies.
ctx := CueContext new.
concrete := (ctx compileString: '42') value.
intType := (ctx compileString: 'int') value.
concrete subsumedBy: intType >>> true
intType subsumedBy: concrete >>> false
Check if this CUE value subsumes (is more general than) another. Returns true if self is a valid constraint that other satisfies. The argument can be a CueValue or any Maggie object (projected via asCueValue).
ctx := CueContext new.
intType := (ctx compileString: 'int') value.
concrete := (ctx compileString: '42') value.
intType subsumes: concrete >>> true
concrete subsumes: intType >>> false
rangeType := (ctx compileString: '>0 & <100') value.
fifty := (ctx compileString: '50') value.
rangeType subsumes: fifty >>> true
twoHundred := (ctx compileString: '200') value.
rangeType subsumes: twoHundred >>> false
Serialize this CUE value to a JSON string. Returns a Result wrapping the JSON string.
| ctx <CueContext> val <CueValue> |
ctx := CueContext new.
val := (ctx compileString: 'x: 1, y: 2') value.
val toJSON value
Convert this CUE value to a native Maggie value. - CUE int -> SmallInt - CUE float -> Float - CUE string -> String - CUE bool -> true/false - CUE null -> nil - CUE struct -> Dictionary - CUE list -> Array - CUE constraint -> CueValue (unchanged)
| ctx <CueContext> val <CueValue> |
ctx := CueContext new.
val := (ctx compileString: '42') value.
val toMaggie >>> 42
Unify this CUE value with another CueValue. Returns a Result wrapping the unified CueValue. Unification fails if the values have conflicting constraints.
| ctx <CueContext> schema <CueValue> data <CueValue> |
ctx := CueContext new.
schema := (ctx compileString: 'name: string') value.
data := (ctx compileString: 'name: "Alice"') value.
(schema unify: data) value toMaggie
Validate this CUE value. Returns a Success Result if valid, Failure with error details if the value has constraint violations.
| ctx <CueContext> val <CueValue> |
ctx := CueContext new.
val := (ctx compileString: 'x: 42') value.
val validate isSuccess >>> true