types

package
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: May 31, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package types declares data types for Rego values and helper functions to operate on these types.

Index

Constants

This section is empty.

Variables

View Source
var A = NewAny()

A represents the superset of all types.

B represents an instance of the boolean type.

N represents an instance of the number type.

S represents an instance of the string type.

Functions

func Compare

func Compare(a, b Type) int

Compare returns -1, 0, 1 based on comparison between a and b.

func Nil

func Nil(a Type) bool

Nil returns true if a's type is unknown.

func Sprint

func Sprint(x Type) string

Sprint returns the string representation of the type.

Types

type Any

type Any []Type

Any represents a dynamic type.

func NewAny

func NewAny(of ...Type) Any

NewAny returns a new Any type.

func (Any) Contains

func (t Any) Contains(other Type) bool

Contains returns true if t is a superset of other.

func (Any) Merge

func (t Any) Merge(other Type) Any

Merge return a new Any type that is the superset of t and other.

func (Any) String

func (t Any) String() string

func (Any) Union

func (t Any) Union(other Any) Any

Union returns a new Any type that is the union of the two Any types.

type Array

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

Array represents the array type.

func NewArray

func NewArray(static []Type, dynamic Type) *Array

NewArray returns a new Array type.

func (*Array) Dynamic

func (t *Array) Dynamic() Type

Dynamic returns the type of the array's dynamic elements.

func (*Array) Len

func (t *Array) Len() int

Len returns the number of static array elements.

func (*Array) Select

func (t *Array) Select(pos int) Type

Select returns the type of element at the zero-based pos.

func (*Array) String

func (t *Array) String() string

type Boolean

type Boolean struct{}

Boolean represents the boolean type.

func NewBoolean

func NewBoolean() Boolean

NewBoolean returns a new Boolean type.

func (Boolean) String

func (t Boolean) String() string

type Null

type Null struct{}

Null represents the null type.

func NewNull

func NewNull() Null

NewNull returns a new Null type.

func (Null) String

func (t Null) String() string

type Number

type Number struct{}

Number represents the number type.

func NewNumber

func NewNumber() Number

NewNumber returns a new Number type.

func (Number) String

func (Number) String() string

type Object

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

Object represents the object type.

func NewObject

func NewObject(static []*Property, dynamic Type) *Object

NewObject returns a new Object type.

func (*Object) Dynamic

func (t *Object) Dynamic() Type

Dynamic returns the type of the object's dynamic elements.

func (*Object) Keys

func (t *Object) Keys() []interface{}

Keys returns the keys of the object's static elements.

func (*Object) Select

func (t *Object) Select(name interface{}) Type

Select returns the type of the named property.

func (*Object) String

func (t *Object) String() string

type Property

type Property struct {
	Key   interface{}
	Value Type
}

Property represents a static object property.

func NewProperty

func NewProperty(key interface{}, value Type) *Property

NewProperty returns a new Property object.

type Set

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

Set represents the set type.

func NewSet

func NewSet(of Type) *Set

NewSet returns a new Set type.

func (*Set) String

func (t *Set) String() string

type String

type String struct{}

String represents the string type.

func NewString

func NewString() String

NewString returns a new String type.

func (String) String

func (t String) String() string

type Type

type Type interface {
	String() string
}

Type represents a type of a term in the language.

func Keys

func Keys(a Type) Type

Keys returns the type of keys that can be enumerated for a. For arrays, the keys are always number types, for objects the keys are always string types, and for sets the keys are always the type of the set element.

func Or

func Or(a, b Type) Type

Or returns a type that represents the union of a and b. If one type is a superset of the other, the superset is returned unchanged.

func Select

func Select(a Type, x interface{}) Type

Select returns a property or item of a.

func TypeOf

func TypeOf(x interface{}) Type

TypeOf returns the type of the Golang native value.

func Values

func Values(a Type) Type

Values returns the type of values that can be enumerated for a.

Jump to

Keyboard shortcuts

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