types

package
v0.0.0-...-f195b84 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(this MalType, that MalType) (int8, error)

Compare compares values

func Equals

func Equals(this MalType, that MalType) bool

Equals compares values

func Hash

func Hash(value MalType) uint32

Hash computes a murmur3 hash of the given value

Types

type Applicable

type Applicable interface {
	Sequential
	Applicable()
}

Applicable - a list-y form that applies the rest to the first when evaluated

type Atom

type Atom struct {
	Value MalType
}

Atom - mal atom values

func (*Atom) Set

func (a *Atom) Set(value MalType)

Set the value of an atom

func (*Atom) ValueEquals

func (a *Atom) ValueEquals(that MalType) bool

ValueEquals checks pointer equality

type Boolean

type Boolean bool

Boolean - mal boolean values

func (Boolean) ValueEquals

func (boolean Boolean) ValueEquals(that MalType) bool

ValueEquals compares booleans

type Concatenation

type Concatenation struct {
	Seqs []Seq
	Meta Map
}

Concatenation is not empty

func (Concatenation) Applicable

func (Concatenation) Applicable()

Applicable are concatenations

func (Concatenation) Conj

func (c Concatenation) Conj(value MalType) (Conjable, error)

Conj to a concatenation prepends as a cons

func (Concatenation) Metadata

func (c Concatenation) Metadata() Map

Metadata for a concatenation

func (Concatenation) Next

func (c Concatenation) Next() (bool, MalType, Seq)

Next of a concatention finds the first nonempty value

func (Concatenation) Seq

func (c Concatenation) Seq() Seq

Seq of a concatenation is itself

func (Concatenation) Sequential

func (Concatenation) Sequential()

Sequential are concatenations

func (Concatenation) WithMetadata

func (c Concatenation) WithMetadata(m Map) HasMetadata

WithMetadata for a concatenation

type Conjable

type Conjable interface {
	Conj(MalType) (Conjable, error)
}

Conjable - collection supports conjoining

type ConsCell

type ConsCell struct {
	Head MalType
	Tail Seq
	Meta Map
}

ConsCell - a seq of a head prepended to a tail seq

func (ConsCell) Applicable

func (ConsCell) Applicable()

Applicable are cons

func (ConsCell) Conj

func (c ConsCell) Conj(value MalType) (Conjable, error)

Conj prepends a cons

func (ConsCell) Metadata

func (c ConsCell) Metadata() Map

Metadata for a cons

func (ConsCell) Next

func (c ConsCell) Next() (bool, MalType, Seq)

Next of a cons just decomposes it

func (ConsCell) Seq

func (c ConsCell) Seq() Seq

Seq of a cons is itself

func (ConsCell) Sequential

func (ConsCell) Sequential()

Sequential are cons

func (ConsCell) WithMetadata

func (c ConsCell) WithMetadata(m Map) HasMetadata

WithMetadata for a cons

type Counted

type Counted interface {
	Count() int
}

Counted - collections that have finite, known size

type Env

type Env struct {
	Outer    *Env
	Bindings *immutable.Map
}

Env binds names to values

func BuildEnv

func BuildEnv() *Env

BuildEnv builds a new env

func DeriveEnv

func DeriveEnv(Outer *Env, binds, exprs []MalType) (*Env, error)

DeriveEnv derives an env

func (*Env) Get

func (env *Env) Get(name string) (MalType, error)

Get gets the value of a symbol

func (*Env) Set

func (env *Env) Set(name string, value MalType)

Set sets the value of a symbol

type Function

type Function struct {
	Fn      func(...MalType) (MalType, error)
	Body    MalType
	Binds   []MalType
	Env     *Env
	IsMacro bool
	Meta    Map
}

Function - functions of values to value

func (Function) Metadata

func (fn Function) Metadata() Map

Metadata for a fn

func (Function) WithMetadata

func (fn Function) WithMetadata(m Map) HasMetadata

WithMetadata for a fn

type HasMetadata

type HasMetadata interface {
	Metadata() Map
	WithMetadata(m Map) HasMetadata
}

HasMetadata - the type has metadata

type HasSimpleValueEquality

type HasSimpleValueEquality interface {
	ValueEquals(MalType) bool
	// contains filtered or unexported methods
}

HasSimpleValueEquality - is a type which can compare itself to other values

type Indexed

type Indexed interface {
	Lookup(MalType) (MalType, bool)
}

Indexed - collection supports lookup by key

type Integer

type Integer int64

Integer - mal integer values

func (Integer) ValueEquals

func (i Integer) ValueEquals(that MalType) bool

ValueEquals compares integers

type Keyword

type Keyword struct {
	Name string
}

Keyword - mal keyword values

func NewKeyword

func NewKeyword(name string) Keyword

NewKeyword builds a new keyword

func (Keyword) ValueEquals

func (keyword Keyword) ValueEquals(that MalType) bool

ValueEquals compares keywords

type List

type List struct {
	Imm  *immutable.List
	Meta Map
}

List - sequences of mal values

func NewList

func NewList(items ...MalType) List

NewList builds a new list

func (List) Applicable

func (List) Applicable()

Applicable lists

func (List) Conj

func (list List) Conj(value MalType) (Conjable, error)

Conj prepends to lists

func (List) Count

func (list List) Count() int

Count counts list items

func (List) Metadata

func (list List) Metadata() Map

Metadata for a list

func (List) Seq

func (list List) Seq() Seq

Seq traverses list items

func (List) Sequential

func (List) Sequential()

Sequential lists

func (List) WithMetadata

func (list List) WithMetadata(m Map) HasMetadata

WithMetadata for a list

type ListIteratorSeq

type ListIteratorSeq struct {
	Imm       *immutable.List
	NextIndex int
	Meta      Map
}

ListIteratorSeq seqs over immutable Lists

func (ListIteratorSeq) Metadata

func (seq ListIteratorSeq) Metadata() Map

Metadata for a list

func (ListIteratorSeq) Next

func (seq ListIteratorSeq) Next() (bool, MalType, Seq)

Next for a list

func (ListIteratorSeq) WithMetadata

func (seq ListIteratorSeq) WithMetadata(m Map) HasMetadata

WithMetadata seqs have metadata

type MalError

type MalError struct {
	Reason MalType
}

MalError contains any mal reason

func (MalError) Error

func (err MalError) Error() string

type MalType

type MalType interface{}

MalType - the root type of all mal values

type Map

type Map struct {
	Imm  *immutable.Map
	Meta *Map
}

Map is an immutable map

func NewMap

func NewMap(values ...MalType) Map

NewMap builds a new map

func (Map) Count

func (m Map) Count() int

Count counts map entries

func (Map) Lookup

func (m Map) Lookup(index MalType) (MalType, bool)

Lookup in a map returns the value

func (Map) Metadata

func (m Map) Metadata() Map

Metadata for a map

func (Map) Seq

func (m Map) Seq() Seq

Seq traverses map entries

func (Map) WithMetadata

func (m Map) WithMetadata(md Map) HasMetadata

WithMetadata for a map

type Nil

type Nil struct{}

Nil - mal nil value

func (Nil) Conj

func (malnil Nil) Conj(value MalType) (Conjable, error)

Conj onto nil returns a list

func (Nil) Count

func (malnil Nil) Count() int

Count of nothing is 0

func (Nil) Lookup

func (malnil Nil) Lookup(value MalType) (MalType, bool)

Lookup in nil always fails

func (Nil) Next

func (malnil Nil) Next() (bool, MalType, Seq)

Next of a nil seq is empty

func (Nil) Seq

func (Nil) Seq() Seq

Seq traverses nothing

func (Nil) ValueEquals

func (malnil Nil) ValueEquals(that MalType) bool

ValueEquals compares nils

type Range

type Range struct {
	Lower  int64
	Upper  int64
	Step   int64
	Finite bool
}

Range is a seq over integers

func (Range) Next

func (r Range) Next() (bool, MalType, Seq)

Next of a range increments Lower unless it's finite and finished

func (Range) Seq

func (r Range) Seq() Seq

Seq of a range is itself

type Rune

type Rune rune

Rune - mal rune values

func (Rune) ValueEquals

func (r Rune) ValueEquals(that MalType) bool

ValueEquals compares runes

type Seq

type Seq interface {
	// Next returns a tuple of emptiness, the first item if non-empty, and the tail seq
	Next() (bool, MalType, Seq)
}

Seq - a traversal of a sequence

type Seqable

type Seqable interface {
	Seq() Seq
}

Seqable - collections that can produce a traversing sequence, or are empty

type Sequential

type Sequential interface {
	Seqable
	Sequential()
}

Sequential - collections that have an order

type SliceSeq

type SliceSeq struct {
	Items []MalType
	Meta  Map
}

SliceSeq traverses slices of items

func (SliceSeq) Count

func (seq SliceSeq) Count() int

Count counts the items in a slice

func (SliceSeq) Metadata

func (seq SliceSeq) Metadata() Map

Metadata seqs have metadata

func (SliceSeq) Next

func (seq SliceSeq) Next() (bool, MalType, Seq)

Next from a slice seq

func (SliceSeq) WithMetadata

func (seq SliceSeq) WithMetadata(m Map) HasMetadata

WithMetadata seqs have metadata

type String

type String string

String - mal string values

func (String) Seq

func (s String) Seq() Seq

Seq of string is a seq of runes

func (String) ValueEquals

func (s String) ValueEquals(that MalType) bool

ValueEquals compared strings

type Symbol

type Symbol struct {
	Name string
	Meta Map
}

Symbol - mal symbol values

func NewSymbol

func NewSymbol(name string) Symbol

NewSymbol builds a new symbol

func (Symbol) Metadata

func (symbol Symbol) Metadata() Map

Metadata for a symbol

func (Symbol) ValueEquals

func (symbol Symbol) ValueEquals(that MalType) bool

ValueEquals compares symbols

func (Symbol) WithMetadata

func (symbol Symbol) WithMetadata(m Map) HasMetadata

WithMetadata symbols

type Undefined

type Undefined struct {
	Name string
}

Undefined errors

func (Undefined) Error

func (err Undefined) Error() string

type Vector

type Vector struct {
	Imm  *immutable.List
	Meta Map
}

Vector - sequences of mal values

func NewVector

func NewVector(items ...MalType) Vector

NewVector builds a new vector

func (Vector) Conj

func (vector Vector) Conj(value MalType) (Conjable, error)

Conj appends to a vector

func (Vector) Count

func (vector Vector) Count() int

Count counts vector items

func (Vector) Lookup

func (vector Vector) Lookup(index MalType) (MalType, bool)

Lookup looks up in a vector by position

func (Vector) Metadata

func (vector Vector) Metadata() Map

Metadata for a vector

func (Vector) Seq

func (vector Vector) Seq() Seq

Seq traverses vector items

func (Vector) Sequential

func (Vector) Sequential()

Sequential vectors

func (Vector) WithMetadata

func (vector Vector) WithMetadata(m Map) HasMetadata

WithMetadata for a vector

Jump to

Keyboard shortcuts

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