types

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package types provides type system implementation

Index

Constants

This section is empty.

Variables

View Source
var (
	BasicBoolean   = makeBasic("boolean")
	BasicBytes     = makeBasic("bytes")
	BasicKeyword   = makeBasic("keyword")
	BasicProcedure = makeBasic("procedure")
	BasicNull      = makeBasic("null")
	BasicNumber    = makeBasic("number")
	BasicString    = makeBasic("string")
	BasicSymbol    = makeBasic("symbol")
	BasicList      = makeBasic("list")
	BasicObject    = makeBasic("object")
	BasicCons      = makeBasic("cons")
	BasicVector    = makeBasic("vector")
	BasicUnion     = makeBasic("union")
)
View Source
var BasicAny = &Any{
	basic: makeBasic("any"),
}

Functions

func Equal

func Equal(l, r ale.Type) bool

func MakeApplicable

func MakeApplicable(first Signature, rest ...Signature) ale.Type

MakeApplicable declares an ApplicableType that will only allow an applicable value capable of the provided signature set

func MakeCons

func MakeCons(left, right ale.Type) ale.Type

MakeCons declares a new PairType that will only allow a List with elements of the provided elem Type

func MakeListOf

func MakeListOf(elem ale.Type) ale.Type

MakeListOf declares a new PairType that will only allow a BasicList with elements of the provided elem Type

func MakeObject

func MakeObject(key ale.Type, value ale.Type) ale.Type

MakeObject declares a new ObjectType that will only allow keys and values of the provided types

func MakeRecord

func MakeRecord(fields ...Field) ale.Type

MakeRecord declares a new RecordType that only allows a fixed set of Field entries, each being identified by a BasicKeyword and having a specified Type

func MakeTuple

func MakeTuple(elems ...ale.Type) ale.Type

MakeTuple declares a new Type that will only allow a List or Vector with positional elements of the provided Types

func MakeUnion

func MakeUnion(first ale.Type, rest ...ale.Type) ale.Type

MakeUnion declares a *Union based on at least one provided Type. If any of the provided types is a types.Any, then types.Any will be returned

func MakeVectorOf

func MakeVectorOf(elem ale.Type) ale.Type

MakeVectorOf declares a new VectorType that will only allow a BasicVector with elements of the provided elem Type

Types

type Any

type Any struct {
	// contains filtered or unexported fields
}

Any accepts a Value of any other Type

func (*Any) Accepts

func (*Any) Accepts(ale.Type) bool

func (*Any) Equal

func (a *Any) Equal(other ale.Type) bool

func (Any) ID added in v0.3.0

func (b Any) ID() ID

func (Any) Name added in v0.3.0

func (b Any) Name() string

type Applicable

type Applicable struct {
	Basic
	// contains filtered or unexported fields
}

Applicable describes a Type that can be the target of a function application. Such application may expose multiple Signatures to describe the various ways that the type can be applied

func (*Applicable) Accepts

func (a *Applicable) Accepts(other ale.Type) bool

func (*Applicable) Equal

func (a *Applicable) Equal(other ale.Type) bool

func (*Applicable) Name

func (a *Applicable) Name() string

func (*Applicable) Signatures

func (a *Applicable) Signatures() []Signature

type Basic

type Basic interface {
	ale.Type

	// ID returns the unique identifier for this basic type
	ID() ID
}

func MakeBasic

func MakeBasic(name string) Basic

type Field

type Field struct {
	Value ale.Type
	Name  string
}

Field describes one of the fields of a RecordType

type ID added in v0.3.0

type ID uint64

ID uniquely identifies a Type within a process

type Literal added in v0.3.0

type Literal struct {
	Basic
	// contains filtered or unexported fields
}

func MakeLiteral added in v0.3.0

func MakeLiteral(b Basic, v ale.Value) *Literal

func (*Literal) Accepts added in v0.3.0

func (l *Literal) Accepts(other ale.Type) bool

func (*Literal) Equal added in v0.3.0

func (l *Literal) Equal(other ale.Type) bool

func (*Literal) Name added in v0.3.0

func (l *Literal) Name() string

func (*Literal) Type added in v0.3.0

func (l *Literal) Type() ale.Type

func (*Literal) Value added in v0.3.0

func (l *Literal) Value() ale.Value

type Object

type Object struct {
	Basic
	// contains filtered or unexported fields
}

Object describes a typed set of Key/Value Pairs

func (*Object) Accepts

func (o *Object) Accepts(other ale.Type) bool

func (*Object) Equal

func (o *Object) Equal(other ale.Type) bool

func (*Object) Key

func (o *Object) Key() ale.Type

func (*Object) Name

func (o *Object) Name() string

func (*Object) Value

func (o *Object) Value() ale.Type

type Pair

type Pair struct {
	Basic
	// contains filtered or unexported fields
}

Pair describes a pair of typed Values

func (*Pair) Accepts

func (p *Pair) Accepts(other ale.Type) bool

func (*Pair) Car

func (p *Pair) Car() ale.Type

func (*Pair) Cdr

func (p *Pair) Cdr() ale.Type

func (*Pair) Equal

func (p *Pair) Equal(other ale.Type) bool

func (*Pair) Name

func (p *Pair) Name() string

type Record

type Record struct {
	Basic
	// contains filtered or unexported fields
}

Record describes an Object that allows a fixed set of fields, each of which has a keyword

func (*Record) Accepts

func (r *Record) Accepts(other ale.Type) bool

func (*Record) Equal

func (r *Record) Equal(other ale.Type) bool

func (*Record) Fields

func (r *Record) Fields() []Field

func (*Record) Name

func (r *Record) Name() string

type Signature

type Signature struct {
	Result    ale.Type
	Params    []ale.Type
	TakesRest bool
}

Signature describes an ApplicableType calling signature

type Union

type Union struct {
	Basic
	// contains filtered or unexported fields
}

Union describes a Type that can accept any of a set of Types

func (*Union) Accepts

func (u *Union) Accepts(other ale.Type) bool

func (*Union) Equal

func (u *Union) Equal(other ale.Type) bool

func (*Union) Name

func (u *Union) Name() string

func (*Union) Options

func (u *Union) Options() []ale.Type

Jump to

Keyboard shortcuts

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