types

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package types contains target-independent semantic types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assignable

func Assignable(target, value Type) bool

func Equivalent

func Equivalent(left, right Type) bool

Equivalent compares semantic types while ignoring binding-level readonly state. Mutable generic containers use it to avoid unsound argument widening.

Types

type Kind

type Kind string
const (
	Invalid Kind = "invalid"
	// Never is the compiler-internal bottom type for expressions that cannot
	// produce a value because control leaves the current flow.
	Never         Kind = "never"
	Any           Kind = "any"
	Void          Kind = "void"
	Bool          Kind = "bool"
	Int           Kind = "int"
	Float         Kind = "float"
	String        Kind = "string"
	Bytes         Kind = "bytes"
	StringBuilder Kind = "string_builder"
	Array         Kind = "array"
	Range         Kind = "range"
	Iterable      Kind = "iterable"
	Hash          Kind = "hash"
	Union         Kind = "union"
	Named         Kind = "named"
	Nil           Kind = "nil"
)

type Type

type Type struct {
	Kind     Kind
	Name     string
	Args     []Type
	Nullable bool
	Readonly bool
}

func CommonType added in v0.1.8

func CommonType(left, right Type) (Type, bool)

CommonType returns the most-specific type that can represent both inputs through portable implicit conversions. It deliberately does not fall back to Any: callers choose whether a missing common type is an error, a union, or a dynamic boundary.

func FromName

func FromName(name string) Type

func UnionOf added in v0.1.8

func UnionOf(input ...Type) Type

UnionOf constructs a canonical union. Nested unions are flattened, equivalent alternatives are removed, and Integer is subsumed by Float because portable Integer-to-Float widening is safe.

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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