types

package
v0.0.0-...-005c154 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2016 License: MPL-2.0 Imports: 7 Imported by: 2

README

EDN Types

A library that contains the data types used by the EDN library.

Considerations

  • Currently the Map type is an alias to map[Value]Value (Value being an interface provided by this library). In Go, maps do not support all type as keys.

    Since Sets are currently backed by map[Value]bool, the same restriction applies to set elements.

    Notably, Vector, Set, Map, etc., can not be map keys or set elements, despite being a valid expression in EDN.

    • Consider using the hash-set and hash-map implementations from [gohash][gohash]. The trade-off here will be further departure from native types as well as requiring all EDN types to meet the [Hasher and Equalser interfaces][gohash interfaces].

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BigInt

type BigInt big.Int

BigInt represents EDN arbitrary precision integers.

func ParseBigInt

func ParseBigInt(s string) *BigInt

func (*BigInt) Equals

func (this *BigInt) Equals(other Value) bool

func (*BigInt) String

func (this *BigInt) String() string

type Bool

type Bool bool

func (Bool) Equals

func (this Bool) Equals(other Value) bool

func (Bool) String

func (this Bool) String() string

type Character

type Character rune // TODO: possibly move out of string file

Character represents an EDN character: \a, \b, \c, \newline, etc...

func (Character) Equals

func (this Character) Equals(other Value) bool

Equals compares the Character to another Value for equality.

func (Character) String

func (this Character) String() string

String returns the EDN string representation of the Character.

type Float

type Float float64

Float represents EDN floats: 1.234, -1.2925e+9

func ParseFloat

func ParseFloat(s string) Float

func (Float) Equals

func (this Float) Equals(other Value) bool

Equals compares the Float to another Value for equality.

func (Float) String

func (this Float) String() string

String returns the EDN string representation of the Float.

type Int

type Int int64

Int represents EDN integers: 1, -5, 1000.

func ParseInt

func ParseInt(s string) Int

func (Int) Equals

func (this Int) Equals(other Value) bool

Equals compares the Int to another Value for equality.

func (Int) String

func (this Int) String() string

String returns the EDN string representation of the Int.

type Keyword

type Keyword string

Keyword represents an EDN keyword: :foo/bar or :baz

func (Keyword) Equals

func (this Keyword) Equals(other Value) bool

Equals compares the Keyword to another Value for equality.

func (Keyword) String

func (this Keyword) String() string

String returns the EDN string representation of the Keyword.

type List

type List linked.List

List is a type that represents an EDN list, such as: (1 2 3)

func (*List) Each

func (this *List) Each(f func(Value, int))

Each calls the provided function once for each item in its collection.

The provided function is passed the item and its index: f(item, index).

func (*List) Equals

func (this *List) Equals(other Value) bool

Equals compares the List to another Value for equality.

func (*List) Insert

func (this *List) Insert(values ...Value) *List

Insert inserts N Value items to the List and returns a pointer to the List.

func (*List) Into

func (this *List) Into(other Sequence) Sequence

Into returns a new Sequence (backed by a List) with the items from both the current List and the other Sequence.

func (*List) Length

func (this *List) Length() int

Length provides the current item count from the List.

func (*List) String

func (this *List) String() string

String returns the EDN string representation of the List.

type Map

type Map map[Value]Value

Map represents an EDN map: {:a "b", 123 true}

func (Map) Equals

func (this Map) Equals(other Value) bool

Equals compares the Map to another Value for equality.

func (Map) String

func (this Map) String() string

String returns the EDN string representation of the Map.

type Rational

type Rational big.Rat

Rational represents EDN rationals: 1/100, -7/5

func ParseRational

func ParseRational(s string) *Rational

func (*Rational) Equals

func (this *Rational) Equals(other Value) bool

func (*Rational) String

func (this *Rational) String() string

type Sequence

type Sequence interface {
	Value

	Into(Sequence) Sequence
	Each(func(Value, int))
	Length() int
}

Sequence is a Value interface that provides a common abstraction for working with all EDN sequences (Lists, Maps, Sets, and Vectors)

type Set

type Set map[Value]bool

Set represents an EDN set: #{1 2 3}

func (Set) Each

func (this Set) Each(f func(Value, int))

Each calls the provided function once for each item in its collection.

The provided function is passed the item and its index: f(item, index).

func (Set) Equals

func (this Set) Equals(other Value) bool

Equals compares the Set to another Value for equality.

func (Set) Insert

func (this Set) Insert(value Value) Sequence

Insert adds a non-present Value into the Set and returns the Set. Adding an existing Value will have no effect.

func (Set) Into

func (this Set) Into(other Sequence) Sequence

Into returns a new Sequence (backed by a Set) with the items from both the current Set and the other Sequence.

func (Set) Length

func (this Set) Length() int

Length provides the current item count from the Set.

func (Set) String

func (this Set) String() string

String returns the EDN string representation of the Set.

type String

type String string

String represents an EDN string: "abc"

func (String) Equals

func (this String) Equals(other Value) bool

Equals compares the String to another Value for equality.

func (String) String

func (this String) String() string

String returns the EDN string representation of the String.

type Symbol

type Symbol string

func (Symbol) Equals

func (this Symbol) Equals(other Value) bool

func (Symbol) String

func (this Symbol) String() string

type TaggedValue

type TaggedValue struct {
	Tag   string
	Value Value
}

func (TaggedValue) Equals

func (this TaggedValue) Equals(other Value) bool

func (TaggedValue) String

func (this TaggedValue) String() string

type Value

type Value interface {
	String() string
	Equals(Value) bool
}

Value is a generic interface to which all data returned by this library comply.

type Vector

type Vector []Value

Vector represents an EDN vector: [1 2 3]

func (Vector) Each

func (this Vector) Each(f func(Value, int))

Each calls the provided function once for each item in its collection.

The provided function is passed the item and its index: f(item, index).

func (Vector) Equals

func (this Vector) Equals(other Value) bool

Equals compares the Vector to another Value for equality.

func (Vector) Into

func (this Vector) Into(other Sequence) Sequence

Into returns a new Sequence (backed by a Vector) with the items from both the current Vector and the other Sequence.

func (Vector) Length

func (this Vector) Length() int

Length provides the current item count from the Vector.

func (Vector) String

func (this Vector) String() string

String returns the EDN string representation of the Vector.

Jump to

Keyboard shortcuts

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