Element kinds

Every Element is one of the following kinds. The kind is the high 6 bits of the ElementId ; see the layout chapter. Trivial-kind Elements have no payload; payload-bearing kinds carry a &'static SomeInfo reference into the matching arena.

This is reference material, organised by family.

Trivial kinds (no payload)

KindPrelude constantDenotes
NullNULLThe value null.
NeverNEVERThe empty type ($\bot$).
VoidVOIDThe PHP void (absence of return value).
PlaceholderPLACEHOLDERInference-time hole.
BoolBOOLtrue or false.
TrueTRUEThe value true.
FalseFALSEThe value false.
ScalarSCALARbool | int | float | string.
NumericNUMERICint | float | numeric-string.
ArrayKeyARRAY_KEYint | string.
ObjectAnyOBJECT_ANYAny object, no class commitment.
MixedMIXED (vanilla)Universe top ($\top$), with optional axes via MixedInfo.

Mixed is technically payload-bearing (the MixedInfo carries the four axes), but the vanilla form (all axes default) is exposed as a constant and behaves trivially.

Scalar payload kinds

KindPayloadDenotes
IntIntInfoInteger (Unspecified, UnspecifiedLiteral, Literal(n), Range(IntRange)).
FloatFloatInfoFloat (Unspecified, Literal, NonZero).
StringStringInfoString with literal slot + refinement flags.
ClassLikeStringClassLikeStringInfoA string naming a class-like (kind + specifier).

See scalars and class-like strings.

Object family

KindPayloadDenotes
ObjectObjectInfoNamed class (with optional type args, intersections, modality flags).
EnumEnumInfoEnum (with optional case).
ObjectShapeObjectShapeInfoStructural object type (with known properties, sealed/unsealed).
HasMethodHasMethodInfoAnything declaring a method named m.
HasPropertyHasPropertyInfoAnything declaring a property named p.

See objects.

Collection family

KindPayloadDenotes
ArrayKeyedArrayInfoKeyed array (generic, sealed shape, or empty).
ListListInfoInt-keyed list (generic or sealed).
IterableIterableInfoiterable<K, V>.

See arrays and iterables and callables.

Resource

KindPayloadDenotes
ResourceResourceInfoPHP resource (open / closed, named kind).

See resources.

Callable

KindPayloadDenotes
CallableCallableInfoBare, signature, or closure form.

See iterables and callables.

Wrappers

KindPayloadDenotes
NegatedNegatedInfoSet complement: !T.
IntersectedIntersectedInfoHead + conjunct list: H & C1 & ... & Cn.

See wrappers.

Generics

KindPayloadDenotes
GenericParameterGenericParameterInfoFree template parameter (T).

See templates.

Unresolved

KindPayloadDenotes
AliasAliasInfoType alias (resolved via World::resolve_alias).
ReferenceSymbolReferenceName reference (class, alias, parameter, etc.).
MemberReferenceMemberReferenceClass-member type (Foo::T).
GlobalReferenceGlobalReferenceGlobal type variable.
ConditionalConditionalInfoT extends U ? X : Y.
DerivedDerivedInfoKeyOf<T>, ValueOf<T>, IndexAccess<T, K>, etc.
VariableVariableInfoAnalyser-introduced inference placeholder.

See unresolved elements and expand.

How to enumerate

use suffete::ElementKind;

// Every variant in declaration order.
for k in ElementKind::iter() {
    println!("{:?}", k);
}

The total count of variants is the size of core::mem::variant_count::<ElementKind>(). The maximum tag value is one less than the count.

Constructing each kind

For trivial kinds, use the prelude constants. For payload-bearing kinds, use the ElementId constructors when available, or interner().intern_* directly:

use suffete::{ElementId, prelude::INT};
use suffete::interner::interner;
use suffete::element::payload::*;
use mago_atom::atom;

// Trivial.
let _ = suffete::prelude::NULL;
let _ = INT;

// Convenience constructors.
let _ = ElementId::int_literal(7);
let _ = ElementId::string_literal("hello");
let _ = ElementId::named_object(atom("Foo"));
let _ = ElementId::named_object_with_args(atom("Box"), &[suffete::prelude::TYPE_INT]);
let _ = ElementId::enum_case(atom("Status"), atom("Active"));

// Direct interner.
let info = ResourceInfo { state: ResourceState::Open, kind: Some(atom("curl")) };
let _ = interner().intern_resource(info);

The full list of constructors is in src/element/id.rs; the per-kind interner methods are generated by the element_arena_methods! macro in src/interner/store.rs.

See also: Elements: the indivisible types for the conceptual overview; The ElementId tag layout for the bit layout; Prelude constants for the full prelude.