Object Types

An object is a unique mapping from strings (“properties”) to values. The most general object type is Obj<Any>. A more restrictive type can be specified for all values, e.g., Obj<Str>. If specific properties and their types are known, this can be part of the type too, e.g.: Obj<a: Num, b: Num, Str>. The type at the end then describes all other values.

ProgramTypeValueError
{}Obj<Void>{}
{a: 1}Obj<a: Num, Void>{a: 1}
{a: 1, b: "c"}Obj<a: Num, b: Str, Void>{a: 1, b: "c"}
for Any def f Obj<Num> as {a: 1, b: 2} ok fObj<Num>{a: 1, b: 2}
for Any def f Obj<Any> as {a: 1, b: "c"} ok fObj<Any>{a: 1, b: "c"}
for Any def f Obj<a: Num, b: Str, Any> as {a: 1, b: "c", d: false} ok fObj<a: Num, b: Str, Any>{a: 1, b: "c", d: false}