kind

package
v1.5.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package kind defines type kind enumeration for efficient type discrimination.

Kind values enable fast type classification without reflection, supporting switch-based dispatch throughout the type system. Each type in the typ package returns its Kind via the Kind() method.

Categories

Primitive kinds: Nil, Boolean, Number, Integer, String Represent base Lua types with value semantics.

Top/Bottom types: Any (top), Unknown (unresolved), Never (bottom) Special types for type system boundaries and error handling.

Composite kinds: Optional, Union, Intersection, Tuple, Function, Array, Map, Record Structural types built from other types.

Nominal kinds: Sum, Interface, Alias, Generic, Instantiated Named types with identity-based semantics.

Deferred kinds: Ref, TypeParam, TypeVar, FieldAccess, IndexAccess Types requiring resolution (forward references, generics, projections).

Other kinds: Platform, Literal, Self, Meta, Refined, Recursive Specialized types for platform APIs, literal values, and advanced features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind int

Kind identifies the structural category of a type for efficient dispatch. Returned by typ.Type.Kind() to enable type classification without casts.

const (
	Nil Kind = iota
	Boolean
	Number
	Integer
	String
	Any
	Unknown
	Never
	Optional
	Union
	Intersection
	Tuple
	Function
	Array
	Map
	Record
	Sum
	Interface
	Alias
	Generic
	Instantiated
	Platform
	Literal
	Self
	Ref
	Meta
	TypeParam
	TypeVar
	Refined
	FieldAccess
	IndexAccess
	Recursive
)

func FromString

func FromString(s string) Kind

FromString converts a Lua type() result string to a Kind. Returns Unknown for unrecognized strings.

func (Kind) IsComposite

func (k Kind) IsComposite() bool

IsComposite returns true for composite types (union, intersection, tuple, etc.).

func (Kind) IsConcrete

func (k Kind) IsConcrete() bool

IsConcrete returns true for types that are fully resolved (not Any, Unknown, or Never).

func (Kind) IsDeferred

func (k Kind) IsDeferred() bool

IsDeferred returns true for types that need resolution (ref, typeparam, typevar, fieldaccess, indexaccess).

func (Kind) IsNever

func (k Kind) IsNever() bool

IsNever returns true for the Never kind (bottom type).

func (Kind) IsPlaceholder

func (k Kind) IsPlaceholder() bool

IsPlaceholder returns true for Any or Unknown kinds. These represent unresolved or open type positions.

func (Kind) IsPrimitive

func (k Kind) IsPrimitive() bool

IsPrimitive returns true for primitive types (nil, boolean, number, integer, string).

func (Kind) IsTopOrBottom added in v1.5.6

func (k Kind) IsTopOrBottom() bool

IsTopOrBottom returns true for Any (top), Unknown (unresolved), or Never (bottom).

func (Kind) String

func (k Kind) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL