mixin

Namespace

@Js
const mixin Namespace

Library namespace is a pinned manifest of specific library versions. Namespaces may lazily load their libs, in which case not all operations are supported. Create a new namespace via XetoEnv.createNamespace.

methods instance

Get an instance by the given qualified name

lib

Get the given library by name

type

Get a type spec by the given qualified name

instantiate

Create default instance for the given spec

mixinsFor

Get all the mixins inherited into the given type

spec

Get a spec by the given qualified name

hasLib

Return if this namespace contains the given lib name

eachInstance

Iterate all the instances in libs

specx

Compute the extended type spec by merging all meta and slots from mixins

validateAll

Validate a graph of records using their configured spec tag

digest

Base64 digest for this namespace based on its lib versions Note

libStatus

Return load status for the given library name

eachSubtype

Iterate all the direct subtypes of given type

validate

Validate a single value against a spec

libErr

Exception for a library with lib status of err, or null otherwise

metas

Get the effective spec metadata slots

specOf

Spec for Fantom Type or the typeof given object

io

Access I/O operations using this namespace

env

Environment used to create this namespace

fits

Return if the given instance fits the spec via structural typing

version

Lookup the version info for a library name in this namespace

eachTypeWhile

Iterate all top-level types in libs until callback returns non-null

versions

List the library name and versions in this namespace

hasSubtypes

Return if given type has at least one direct subtype

funcs

Get the effective map of all functions

choice

Return choice API for given spec

libs

List all libraries

eachType

Iterate all the top-level types in libs

choice abstract SpecChoice choice(Spec spec)

Return choice API for given spec. Callers should prefer the slot over the type since the slot determines maybe and multi-choice flags. Raise exception if Spec.isChoice is false.

digest abstract Str digest()

Base64 digest for this namespace based on its lib versions Note: this digest only changes when the libs and/or versions are modified. It is not a digest of the lib contents.

eachInstance abstract Void eachInstance(|Dict| f)

Iterate all the instances in libs

eachSubtype abstract Void eachSubtype(Spec base, |Spec| f)

Iterate all the direct subtypes of given type

eachType abstract Void eachType(|Spec| f)

Iterate all the top-level types in libs.

eachTypeWhile abstract Obj? eachTypeWhile(|Spec->Obj?| f)

Iterate all top-level types in libs until callback returns non-null.

env abstract XetoEnv env()

Environment used to create this namespace

fits abstract Bool fits(Obj? val, Spec spec, Dict? opts)

Return if the given instance fits the spec via structural typing. Options:

  • graph: marker to also check graph of references such as required points
  • ignoreRefs: marker to ignore if refs resolve to valid target
  • haystack: marker tag to use Haystack level data fidelity

funcs abstract SpecMap funcs()

Get the effective map of all functions. This is semantically equivalent to specx(Funcs).slots.

hasLib abstract Bool hasLib(Str name)

Return if this namespace contains the given lib name. This is true if version will return non-null regardless of libStatus.

hasSubtypes abstract Bool hasSubtypes(Spec base)

Return if given type has at least one direct subtype.

instance abstract Dict? instance(Str qname, Bool checked)

Get an instance by the given qualified name

instantiate abstract Obj? instantiate(Spec spec, Dict? opts)

Create default instance for the given spec. Raise exception if spec is abstract.

Options:

  • graph: marker tag to instantiate graph of recs (will auto-generate ids)
  • abstract: marker to supress error if spec is abstract
  • id: Ref tag to include in new instance
  • haystack: marker tag to use Haystack level data fidelity

io abstract XetoIO io()

Access I/O operations using this namespace

lib abstract Lib? lib(Str name, Bool checked)

Get the given library by name. If the library is not in the namesapce or could be compiled then raise an exception unless checked is false.

libErr abstract Err? libErr(Str name, Bool checked)

Exception for a library with lib status of err, or null otherwise. Return null/exception if library not included

libStatus abstract LibStatus? libStatus(Str name, Bool checked)

Return load status for the given library name:

  • ok: library is included and loaded successfully
  • err: library is included but could not be loaded
  • null/exception if library not included

libs abstract Lib[] libs()

List all libraries. Any libs which cannot be compiled are excluded.

metas abstract SpecMap metas()

Get the effective spec metadata slots. This is semantically equivalent to specx(Spec).slots.

mixinsFor abstract Spec[] mixinsFor(Spec type)

Get all the mixins inherited into the given type. This operation can be expensive.

spec abstract Spec? spec(Str qname, Bool checked)

Get a spec by the given qualified name:

  • type/mixin: "foo.bar::Baz"
  • slot/global: "foo.bar::Baz.qux"

specOf abstract Spec? specOf(Obj? val, Bool checked)

Spec for Fantom Type or the typeof given object

specx abstract Spec specx(Spec type)

Compute the extended type spec by merging all meta and slots from mixins. This call can be quite expensive; so cache and reuse the result for your operation.

type abstract Spec? type(Str qname, Bool checked)

Get a type spec by the given qualified name.

validate abstract ValidateReport validate(Obj? val, Spec? spec, Dict? opts)

Validate a single value against a spec. If spec is null, then validate against specOf(val). Should be called within an XetoContext context to verify external refs.

validateAll abstract ValidateReport validateAll(Dict[] subjects, Dict? opts)

Validate a graph of records using their configured spec tag. Should be called within an XetoContext context to verify external refs.

version abstract LibVersion? version(Str name, Bool checked)

Lookup the version info for a library name in this namespace.

versions abstract LibVersion[] versions()

List the library name and versions in this namespace.

Haxall 4.0.5 ∙ 24-Feb-2026 14:33 EST