eval

package
v0.0.0-...-dc6f9f8 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const IdiomRootPkg = "idiom"

Variables

This section is empty.

Functions

func RefineMacro

func RefineMacro(span *model.Span, macro Macro) *model.Span

Types

type Arg

type Arg interface {
	Shape
}

type Bool

type Bool struct{ Value_ bool }

func (Bool) Augment

func (v Bool) Augment(span *model.Span, _ Fields) (Shape, Effect, error)

func (Bool) Invoke

func (v Bool) Invoke(span *model.Span) (Shape, Effect, error)
func (v Bool) Link(span *model.Span, name string, monadic bool) (Shape, Effect, error)

func (Bool) Select

func (v Bool) Select(span *model.Span, path model.Path) (Shape, Effect, error)

func (Bool) String

func (v Bool) String() string

type Boundary

type Boundary interface {
	Figure(*model.Span, Figure) (Shape, Effect, error)
	Enter(*model.Span, Arg) (Shape, Effect, error)
	Leave(*model.Span, Shape) (Return, Effect, error)
}

type Combiner

type Combiner interface {
	Interpret(Evaluator, *model.Func) Macro
	Combine(*model.Span, *model.Func, Arg, Return, StepResidues) (Effect, error)
}

type Effect

type Effect interface {
	String() string
}

type Empty

type Empty struct{}

func (Empty) Augment

func (e Empty) Augment(span *model.Span, _ Fields) (Shape, Effect, error)

func (Empty) Invoke

func (e Empty) Invoke(span *model.Span) (Shape, Effect, error)
func (e Empty) Link(span *model.Span, name string, monadic bool) (Shape, Effect, error)

func (Empty) Select

func (e Empty) Select(span *model.Span, path model.Path) (Shape, Effect, error)

func (Empty) String

func (e Empty) String() string

type Evaluator

type Evaluator interface {
	String() string
	EvalPar(*model.Span, *model.Func, Arg) (Return, Effect, error)
	EvalSeq(*model.Span, *model.Func, Arg) (Return, Effect, error)
	EvalIdiom() model.Repo
	EvalRepo() model.Repo
}

func SpanEvaluator

func SpanEvaluator(span *model.Span) Evaluator

type Faculty

type Faculty map[Ideal]Macro

func MergeFaculty

func MergeFaculty(f ...Faculty) Faculty

func MergeFacultyExclusive

func MergeFacultyExclusive(f ...Faculty) Faculty

func (Faculty) Add

func (f Faculty) Add(key Ideal, value Macro)

func (Faculty) AddExclusive

func (f Faculty) AddExclusive(key Ideal, value Macro)

func (Faculty) DocFunc

func (f Faculty) DocFunc(pkgPath, funcName string) (string, bool)

func (Faculty) DocPackage

func (f Faculty) DocPackage(pkgPath string) (string, bool)

func (Faculty) ID

func (f Faculty) ID() string

func (Faculty) PkgNames

func (f Faculty) PkgNames() []string

func (Faculty) SortedIdeals

func (f Faculty) SortedIdeals() (ideals Ideals)

func (Faculty) String

func (f Faculty) String() string

func (Faculty) StringTable

func (f Faculty) StringTable(header string) [][]string

type Field

type Field struct {
	Name  string `ko:"name=name"` // step label or arg name
	Shape Shape  `ko:"name=shape"`
}

func (Field) String

func (f Field) String() string

type Fields

type Fields []Field

func (Fields) Augment

func (v Fields) Augment(span *model.Span, _ Fields) (Shape, Effect, error)

Augment implements Shape.Augment.

func (Fields) FieldGroup

func (v Fields) FieldGroup() [][]Field

func (Fields) Fields

func (v Fields) Fields() []Field

func (Fields) Invoke

func (v Fields) Invoke(span *model.Span) (Shape, Effect, error)

Invoke implements Shape.Invoke.

func (Fields) IsEmpty

func (v Fields) IsEmpty() bool
func (v Fields) Link(span *model.Span, name string, monadic bool) (Shape, Effect, error)

Link implements Shape.Select. For eval_test.go only.

func (Fields) Names

func (v Fields) Names() []string

func (Fields) RestrictTo

func (v Fields) RestrictTo(name string) Fields

func (Fields) Select

func (v Fields) Select(span *model.Span, path model.Path) (Shape, Effect, error)

Select implements Shape.Select. For eval_test.go only.

func (Fields) String

func (v Fields) String() string

func (Fields) StringField

func (v Fields) StringField(label string) (string, error)

type Figure

type Figure interface{}

type Float

type Float struct{ Value_ float64 }

func (Float) Augment

func (v Float) Augment(span *model.Span, _ Fields) (Shape, Effect, error)

func (Float) Invoke

func (v Float) Invoke(span *model.Span) (Shape, Effect, error)
func (v Float) Link(span *model.Span, name string, monadic bool) (Shape, Effect, error)

func (Float) Select

func (v Float) Select(span *model.Span, path model.Path) (Shape, Effect, error)

func (Float) String

func (v Float) String() string

type GateMacro

type GateMacro interface {
	GateMacro(gate.Gate) Macro
}

type Ideal

type Ideal struct {
	Pkg  string `ko:"name=pkg"`
	Name string `ko:"name=name"`
}

func (Ideal) FullPath

func (ideal Ideal) FullPath() string

func (Ideal) String

func (ideal Ideal) String() string

type Ideals

type Ideals []Ideal

func (Ideals) Len

func (ss Ideals) Len() int

func (Ideals) Less

func (ss Ideals) Less(i, j int) bool

func (Ideals) Sort

func (ss Ideals) Sort()

func (Ideals) Swap

func (ss Ideals) Swap(i, j int)

type IdentityBoundary

type IdentityBoundary struct{}

func (IdentityBoundary) Enter

func (IdentityBoundary) Enter(_ *model.Span, arg Arg) (Shape, Effect, error)

func (IdentityBoundary) Figure

func (IdentityBoundary) Figure(_ *model.Span, figure Figure) (Shape, Effect, error)

func (IdentityBoundary) Leave

func (IdentityBoundary) Leave(_ *model.Span, shape Shape) (Return, Effect, error)

type IdentityCombiner

type IdentityCombiner struct{}

func (IdentityCombiner) Combine

func (IdentityCombiner) Combine(_ *model.Span, _ *model.Func, _ Arg, _ Return, effect StepResidues) (Effect, error)

func (IdentityCombiner) Interpret

func (IdentityCombiner) Interpret(eval Evaluator, f *model.Func) Macro

type Integer

type Integer struct{ Value_ int64 }

func (Integer) Augment

func (v Integer) Augment(span *model.Span, _ Fields) (Shape, Effect, error)

func (Integer) Invoke

func (v Integer) Invoke(span *model.Span) (Shape, Effect, error)
func (v Integer) Link(span *model.Span, name string, monadic bool) (Shape, Effect, error)

func (Integer) Select

func (v Integer) Select(span *model.Span, path model.Path) (Shape, Effect, error)

func (Integer) String

func (v Integer) String() string

type Macro

type Macro interface {
	Figure
	MacroID() string // MacroID uniquely identifies the meaning of this macro
	// The top-level circuit step in the frame argument is the circuit invocation step
	// corresponding to this operator invocation.
	Invoke(*model.Span, Arg) (Return, Effect, error)
	Label() string              // string identifier
	Help() string               // human-readable line of text, used in "ko list"
	MacroSheathString() *string // human-readable line ot text show in debug frames (if not nil)
	Doc() string
}

type MacroCases

type MacroCases []Macro

type MacroSheath

type MacroSheath struct {
	Macro Macro `ko:"name=macro"`
}

func (MacroSheath) SheathID

func (sh MacroSheath) SheathID() *model.ID

func (MacroSheath) SheathLabel

func (sh MacroSheath) SheathLabel() *string

func (MacroSheath) SheathString

func (sh MacroSheath) SheathString() *string

type Program

type Program struct {
	Idiom  model.Repo `ko:"name=idiom"`
	Repo   model.Repo `ko:"name=repo"` // function repository from user sources
	System `ko:"name=system"`
}

Program is an Evaluator.

func (Program) EvalIdiom

func (prog Program) EvalIdiom() model.Repo

func (Program) EvalPar

func (prog Program) EvalPar(span *model.Span, f *model.Func, arg Arg) (Return, Effect, error)

func (Program) EvalRepo

func (prog Program) EvalRepo() model.Repo

func (Program) EvalSeq

func (prog Program) EvalSeq(span *model.Span, f *model.Func, arg Arg) (Return, Effect, error)

func (Program) String

func (prog Program) String() string

type Registry

type Registry struct {
	sync.Mutex `ko:"name=mutex"`
	GateMacro  `ko:"name=gateMacro"`
	Faculty    Faculty `ko:"name=faculty"`
}

func NewRegistry

func NewRegistry(gateMacro GateMacro) *Registry

func (*Registry) RegisterGate

func (r *Registry) RegisterGate(stub interface{})

RegisterGate registers a gate with the name and package of the given stub.

func (*Registry) RegisterGateAt

func (r *Registry) RegisterGateAt(pkg, name string, stub interface{})

RegisterGateAt registers a gate with given name in the given package.

func (*Registry) RegisterMacro

func (r *Registry) RegisterMacro(name string, macro Macro)

func (*Registry) RegisterNamedGate

func (r *Registry) RegisterNamedGate(name string, stub interface{})

RegisterNamedGate registers a gate with the given name in the package of the given stub.

func (*Registry) RegisterPkgMacro

func (r *Registry) RegisterPkgMacro(pkg, name string, macro Macro)

func (*Registry) Snapshot

func (r *Registry) Snapshot() Faculty

type Return

type Return interface {
	Shape
}

type Shape

type Shape interface {
	String() string
	Select(*model.Span, model.Path) (Shape, Effect, error)
	Link(*model.Span, string, bool) (Shape, Effect, error)
	Augment(*model.Span, Fields) (Shape, Effect, error)
	Invoke(*model.Span) (Shape, Effect, error)
}

Shape is an interface implemented by figures (Integer, Float, String, Bool, Empty, Variety) and Fields.

type StepResidue

type StepResidue struct {
	Span   *model.Span `ko:"name=span"`
	Shape  Shape       `ko:"name=shape"`
	Effect Effect      `ko:"name=effect"`
}

func FlowResidues

func FlowResidues(stepFlow []flow.Flow) (stepResidue []*StepResidue)

type StepResidues

type StepResidues []*StepResidue

func (StepResidues) String

func (sr StepResidues) String() string

type String

type String struct{ Value_ string }

func (String) Augment

func (v String) Augment(span *model.Span, _ Fields) (Shape, Effect, error)

func (String) Invoke

func (v String) Invoke(span *model.Span) (Shape, Effect, error)
func (v String) Link(span *model.Span, name string, monadic bool) (Shape, Effect, error)

func (String) Select

func (v String) Select(span *model.Span, path model.Path) (Shape, Effect, error)

func (String) String

func (v String) String() string

type System

type System struct {
	Faculty  Faculty  `ko:"name=faculty"`  // operator logic
	Boundary Boundary `ko:"name=boundary"` // interprets literals
	Combiner Combiner `ko:"name=combiner"` // generates function effect/description
}

type Variety

type Variety struct {
	Macro Macro
	Arg   Arg
}

Variety is a gate shape.

func (Variety) Augment

func (v Variety) Augment(span *model.Span, arg Fields) (Shape, Effect, error)

func (Variety) Doc

func (v Variety) Doc() string

func (Variety) Invoke

func (v Variety) Invoke(span *model.Span) (Shape, Effect, error)
func (v Variety) Link(span *model.Span, name string, monadic bool) (Shape, Effect, error)

func (Variety) Select

func (v Variety) Select(span *model.Span, path model.Path) (Shape, Effect, error)

func (Variety) String

func (v Variety) String() string

Jump to

Keyboard shortcuts

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