types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BasicBoolean   = MakeBasic("boolean")
	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 Accepts

func Accepts(left, right Type) bool

func Equal

func Equal(l, r Type) bool

Types

type AcceptsWith

type AcceptsWith func(*Checker, Type) bool

type Any

type Any struct{ *Basic }

Any accepts a Value of any other Type

func (*Any) Accepts

func (*Any) Accepts(*Checker, Type) bool

func (*Any) Equal

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

type Applicable

type Applicable struct {
	// 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 MakeApplicable

func MakeApplicable(first Signature, rest ...Signature) *Applicable

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

func (*Applicable) Accepts

func (a *Applicable) Accepts(c *Checker, other Type) bool

func (*Applicable) Equal

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

func (*Applicable) Name

func (a *Applicable) Name() string

func (*Applicable) Signatures

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

type Basic

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

func MakeBasic

func MakeBasic(name string) *Basic

func (*Basic) Accepts

func (b *Basic) Accepts(_ *Checker, other Type) bool

func (*Basic) Equal

func (b *Basic) Equal(other Type) bool

func (*Basic) Kind

func (b *Basic) Kind() Kind

func (*Basic) Name

func (b *Basic) Name() string

type Checker

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

func Check

func Check(t Type) *Checker

func (*Checker) Accepts

func (c *Checker) Accepts(right Type) bool

func (*Checker) AcceptsChild

func (c *Checker) AcceptsChild(left, right Type) bool

func (*Checker) AcceptsChildWith

func (c *Checker) AcceptsChildWith(left, right Type, with AcceptsWith) bool

func (*Checker) AcceptsWith

func (c *Checker) AcceptsWith(right Type, with AcceptsWith) bool

func (*Checker) Receiver

func (c *Checker) Receiver() Type

type Field

type Field struct {
	Name  string
	Value Type
}

Field describes one of the fields of a RecordType

type Kind

type Kind uuid.UUID

Kind uniquely identifies a Type within a process

type Object

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

Object describes a typed set of Key/Value Pairs

func MakeObject

func MakeObject(key Type, value Type) *Object

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

func (*Object) Accepts

func (o *Object) Accepts(c *Checker, other Type) bool

func (*Object) Equal

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

func (*Object) Key

func (o *Object) Key() Type

func (*Object) Name

func (o *Object) Name() string

func (*Object) Value

func (o *Object) Value() Type

type Pair

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

Pair describes a pair of typed Values

func (*Pair) Accepts

func (p *Pair) Accepts(c *Checker, other Type) bool

func (*Pair) Car

func (p *Pair) Car() Type

func (*Pair) Cdr

func (p *Pair) Cdr() Type

func (*Pair) Equal

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

func (*Pair) Name

func (p *Pair) Name() string

type Record

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

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

func MakeRecord

func MakeRecord(fields ...Field) *Record

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 (*Record) Accepts

func (r *Record) Accepts(c *Checker, other Type) bool

func (*Record) Equal

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

func (*Record) Fields

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

func (*Record) Name

func (r *Record) Name() string

type Signature

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

Signature describes an ApplicableType calling signature

type Type

type Type interface {
	// Name identifies this Type
	Name() string

	// Accepts determines if this Type will accept the provided Type for
	// binding. This will generally mean that the provided Type satisfies
	// the contract of the receiver. A Checker is provided to track the
	// state of the Type checking
	Accepts(*Checker, Type) bool

	// Equal determines if the provided Type is an equivalent definition
	Equal(Type) bool
}

Type describes the type compatibility for a Value

func MakeCons

func MakeCons(left, right Type) Type

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

func MakeListOf

func MakeListOf(elem Type) Type

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

func MakeTuple

func MakeTuple(elems ...Type) Type

MakeTuple declares a new TupleType that will only allow a MakeListOf or MakeVectorOf with positional elements of the provided Types

func MakeUnion

func MakeUnion(first Type, rest ...Type) 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 Type) Type

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

type Union

type Union struct {
	// 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(c *Checker, other Type) bool

func (*Union) Equal

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

func (*Union) Name

func (u *Union) Name() string

func (*Union) Options

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

Jump to

Keyboard shortcuts

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