funcs

package
v0.0.0-...-453cd44 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: GPL-3.0 Imports: 10 Imported by: 36

Documentation

Overview

Package funcs provides a framework for functions that change over time.

Index

Constants

View Source
const (
	// ModuleSep is the character used for the module scope separation. For
	// example when using `fmt.printf` or `math.sin` this is the char used.
	// It is included here for convenience when importing this package.
	ModuleSep = interfaces.ModuleSep

	// ReplaceChar is a special char that is used to replace ModuleSep when
	// it can't be used for some reason. This currently only happens in the
	// golang template library. Even with this limitation in that library,
	// we don't want to allow this as the first or last character in a name.
	// NOTE: the template library will panic if it is one of: .-#
	ReplaceChar = "_"

	// CoreDir is the directory prefix where core mcl code is embedded.
	CoreDir = "core/"

	// ConcatFuncName is the name the concat function is registered as. It
	// is listed here because it needs a well-known name that can be used by
	// the string interpolation code.
	ConcatFuncName = "concat"
)
View Source
const (
	// ContainsFuncName is the name this function is registered as. This
	// starts with an underscore so that it cannot be used from the lexer.
	// XXX: change to _contains and add syntax in the lexer/parser
	ContainsFuncName = "contains"
)
View Source
const (
	// HistoryFuncName is the name this function is registered as.
	// TODO: move this into a separate package
	HistoryFuncName = "history"
)
View Source
const (
	// ListLookupDefaultFuncName is the name this function is registered as.
	ListLookupDefaultFuncName = "list_lookup_default"
)
View Source
const (
	// ListLookupFuncName is the name this function is registered as.
	ListLookupFuncName = "list_lookup"
)
View Source
const (
	// LookupDefaultFuncName is the name this function is registered as.
	// This starts with an underscore so that it cannot be used from the
	// lexer.
	LookupDefaultFuncName = "_lookup_default"
)
View Source
const (
	// LookupFuncName is the name this function is registered as.
	// This starts with an underscore so that it cannot be used from the
	// lexer.
	LookupFuncName = "_lookup"
)
View Source
const (
	// MapLookupDefaultFuncName is the name this function is registered as.
	MapLookupDefaultFuncName = "map_lookup_default"
)
View Source
const (
	// MapLookupFuncName is the name this function is registered as.
	MapLookupFuncName = "map_lookup"
)
View Source
const (
	// OperatorFuncName is the name this function is registered as. This
	// starts with an underscore so that it cannot be used from the lexer.
	OperatorFuncName = "_operator"
)
View Source
const (
	// StructLookupFuncName is the name this function is registered as. This
	// starts with an underscore so that it cannot be used from the lexer.
	StructLookupFuncName = "_struct_lookup"
)
View Source
const (
	// StructLookupOptionalFuncName is the name this function is registered
	// as. This starts with an underscore so that it cannot be used from the
	// lexer.
	StructLookupOptionalFuncName = "_struct_lookup_optional"
)

Variables

View Source
var OperatorFuncs = make(map[string][]*types.FuncValue) // must initialize

OperatorFuncs maps an operator to a list of callable function values.

Functions

func Lookup

func Lookup(name string) (interfaces.Func, error)

Lookup returns a pointer to the function's struct. It may be convertible to a PolyFunc if the particular function implements those additional methods.

func LookupOperator

func LookupOperator(operator string, size int) ([]*types.Type, error)

LookupOperator returns a list of type strings for each operator. An empty operator string means return everything. If you specify a size that is less than zero, we don't filter by arg length, otherwise we only return signatures which have an arg length equal to size.

func LookupOperatorShort

func LookupOperatorShort(operator string, size int) ([]*types.Type, error)

LookupOperatorShort is similar to LookupOperator except that it returns the "short" (standalone) types of the direct functions that are attached to each operator. IOW, if you specify "+" and 2, you'll get the sigs for "a" + "b" and 1 + 2, without the third "op" as the first argument.

func LookupPrefix

func LookupPrefix(prefix string) map[string]func() interfaces.Func

LookupPrefix returns a map of names to functions that start with a module prefix. This search automatically adds the period separator. So if you want functions in the `fmt` package, search for `fmt`, not `fmt.` and it will find all the correctly registered functions. This removes that prefix from the result in the map keys that it returns. If you search for an empty prefix, then this will return all the top-level functions that aren't in a module.

func Map

func Map() map[string]func() interfaces.Func

Map returns a map from all registered function names to a function to return that one. We return a copy of our internal registered function store so that this result can be manipulated safely. We return the functions that produce the Func interface because we might use this result to create multiple functions, and each one must have its own unique memory address to work properly.

func ModuleRegister

func ModuleRegister(module, name string, fn func() interfaces.Func)

ModuleRegister is exactly like Register, except that it registers within a named module.

func PureFuncExec

func PureFuncExec(handle interfaces.Func, args []types.Value) (types.Value, error)

PureFuncExec is usually used to provisionally speculate about the result of a pure function, by running it once, and returning the result. Pure functions are expected to only produce one value that depends only on the input values. This won't run any slow functions either.

func Register

func Register(name string, fn func() interfaces.Func)

Register takes a func and its name and makes it available for use. It is commonly called in the init() method of the func at program startup. There is no matching Unregister function. You may also register functions which satisfy the PolyFunc interface. To register a function which lives in a module, you must join the module name to the function name with the ModuleSep character. It is defined as a const and is probably the period character.

func RegisterOperator

func RegisterOperator(operator string, fn *types.FuncValue)

RegisterOperator registers the given string operator and function value implementation with the mini-database for this generalized, static, polymorphic operator implementation.

Types

type ContainsFunc

type ContainsFunc struct {
	Type *types.Type // this is the type of value stored in our list
	// contains filtered or unexported fields
}

ContainsFunc returns true if a value is found in a list. Otherwise false.

func (*ContainsFunc) ArgGen

func (obj *ContainsFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*ContainsFunc) Build

func (obj *ContainsFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*ContainsFunc) Info

func (obj *ContainsFunc) Info() *interfaces.Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*ContainsFunc) Init

func (obj *ContainsFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*ContainsFunc) Polymorphisms

func (obj *ContainsFunc) Polymorphisms(partialType *types.Type, partialValues []types.Value) ([]*types.Type, error)

Polymorphisms returns the list of possible function signatures available for this static polymorphic function. It relies on type and value hints to limit the number of returned possibilities.

func (*ContainsFunc) Stream

func (obj *ContainsFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*ContainsFunc) String

func (obj *ContainsFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*ContainsFunc) Unify

func (obj *ContainsFunc) Unify(expr interfaces.Expr) ([]interfaces.Invariant, error)

Unify returns the list of invariants that this func produces.

func (*ContainsFunc) Validate

func (obj *ContainsFunc) Validate() error

Validate tells us if the input struct takes a valid form.

type HistoryFunc

type HistoryFunc struct {
	Type *types.Type // type of input value (same as output type)
	// contains filtered or unexported fields
}

HistoryFunc is special function which returns the Nth oldest value seen. It must store up incoming values until it gets enough to return the desired one. A restart of the program, will expunge the stored state. This obviously takes more memory, the further back you wish to index. A change in the index var is generally not useful, but it is permitted. Moving it to a smaller value will cause older index values to be expunged. If this is undesirable, a max count could be added. This was not implemented with efficiency in mind. Since some functions might not send out un-changed values, it might also make sense to implement a *time* based hysteresis, since this only looks at the last N changed values. A time based hysteresis would tick every precision-width, and store whatever the latest value at that time is.

func (*HistoryFunc) ArgGen

func (obj *HistoryFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*HistoryFunc) Build

func (obj *HistoryFunc) Build(typ *types.Type) (*types.Type, error)

Build takes the now known function signature and stores it so that this function can appear to be static. That type is used to build our function statically.

func (*HistoryFunc) Info

func (obj *HistoryFunc) Info() *interfaces.Info

Info returns some static info about itself.

func (*HistoryFunc) Init

func (obj *HistoryFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*HistoryFunc) Polymorphisms

func (obj *HistoryFunc) Polymorphisms(partialType *types.Type, partialValues []types.Value) ([]*types.Type, error)

Polymorphisms returns the possible type signature for this function. In this case, since the number of possible types for the first arg can be infinite, it returns the final precise type only if it can be gleamed statically. If not, it returns that unknown as a variant, which is hopefully solved during unification.

func (*HistoryFunc) Stream

func (obj *HistoryFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*HistoryFunc) String

func (obj *HistoryFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*HistoryFunc) Unify

func (obj *HistoryFunc) Unify(expr interfaces.Expr) ([]interfaces.Invariant, error)

Unify returns the list of invariants that this func produces.

func (*HistoryFunc) Validate

func (obj *HistoryFunc) Validate() error

Validate makes sure we've built our struct properly. It is usually unused for normal functions that users can use directly.

type ListLookupDefaultFunc

type ListLookupDefaultFunc struct {
	Type *types.Type // Kind == List, that is used as the list we lookup in
	// contains filtered or unexported fields
}

ListLookupDefaultFunc is a list index lookup function. If you provide a negative index, then it will return the default value you specified for this function.

func (*ListLookupDefaultFunc) ArgGen

func (obj *ListLookupDefaultFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*ListLookupDefaultFunc) Build

func (obj *ListLookupDefaultFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*ListLookupDefaultFunc) Info

func (obj *ListLookupDefaultFunc) Info() *interfaces.Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*ListLookupDefaultFunc) Init

func (obj *ListLookupDefaultFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*ListLookupDefaultFunc) Stream

func (obj *ListLookupDefaultFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*ListLookupDefaultFunc) String

func (obj *ListLookupDefaultFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*ListLookupDefaultFunc) Unify

Unify returns the list of invariants that this func produces.

func (*ListLookupDefaultFunc) Validate

func (obj *ListLookupDefaultFunc) Validate() error

Validate tells us if the input struct takes a valid form.

type ListLookupFunc

type ListLookupFunc struct {
	Type *types.Type // Kind == List, that is used as the list we lookup in
	// contains filtered or unexported fields
}

ListLookupFunc is a list index lookup function. If you provide a negative index, then it will return the zero value for that type.

func (*ListLookupFunc) ArgGen

func (obj *ListLookupFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*ListLookupFunc) Build

func (obj *ListLookupFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*ListLookupFunc) Info

func (obj *ListLookupFunc) Info() *interfaces.Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*ListLookupFunc) Init

func (obj *ListLookupFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*ListLookupFunc) Stream

func (obj *ListLookupFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*ListLookupFunc) String

func (obj *ListLookupFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*ListLookupFunc) Unify

func (obj *ListLookupFunc) Unify(expr interfaces.Expr) ([]interfaces.Invariant, error)

Unify returns the list of invariants that this func produces.

func (*ListLookupFunc) Validate

func (obj *ListLookupFunc) Validate() error

Validate tells us if the input struct takes a valid form.

type LookupDefaultFunc

type LookupDefaultFunc struct {
	Type *types.Type // Kind == List OR Map, that is used as the list/map we lookup in
	// contains filtered or unexported fields
}

LookupDefaultFunc is a list index or map key lookup function. It does both because the current syntax in the parser is identical, so it's convenient to mix the two together. This calls out to some of the code in the ListLookupDefaultFunc and MapLookupDefaultFunc implementations. If the index or key for this input doesn't exist, then it will return the default value you specified for this function.

func (*LookupDefaultFunc) ArgGen

func (obj *LookupDefaultFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*LookupDefaultFunc) Build

func (obj *LookupDefaultFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*LookupDefaultFunc) Info

func (obj *LookupDefaultFunc) Info() *interfaces.Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*LookupDefaultFunc) Init

func (obj *LookupDefaultFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*LookupDefaultFunc) Stream

func (obj *LookupDefaultFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*LookupDefaultFunc) String

func (obj *LookupDefaultFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*LookupDefaultFunc) Unify

Unify returns the list of invariants that this func produces.

func (*LookupDefaultFunc) Validate

func (obj *LookupDefaultFunc) Validate() error

Validate tells us if the input struct takes a valid form.

type LookupFunc

type LookupFunc struct {
	Type *types.Type // Kind == List OR Map, that is used as the list/map we lookup in
	// contains filtered or unexported fields
}

LookupFunc is a list index or map key lookup function. It does both because the current syntax in the parser is identical, so it's convenient to mix the two together. This calls out to some of the code in the ListLookupFunc and MapLookupFunc implementations. If the index or key for this input doesn't exist, then it will return the zero value for that type.

func (*LookupFunc) ArgGen

func (obj *LookupFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*LookupFunc) Build

func (obj *LookupFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*LookupFunc) Info

func (obj *LookupFunc) Info() *interfaces.Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*LookupFunc) Init

func (obj *LookupFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*LookupFunc) Stream

func (obj *LookupFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*LookupFunc) String

func (obj *LookupFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*LookupFunc) Unify

func (obj *LookupFunc) Unify(expr interfaces.Expr) ([]interfaces.Invariant, error)

Unify returns the list of invariants that this func produces.

func (*LookupFunc) Validate

func (obj *LookupFunc) Validate() error

Validate tells us if the input struct takes a valid form.

type MapLookupDefaultFunc

type MapLookupDefaultFunc struct {
	Type *types.Type // Kind == Map, that is used as the map we lookup
	// contains filtered or unexported fields
}

MapLookupDefaultFunc is a key map lookup function. If you provide a missing key, then it will return the default value you specified for this function.

func (*MapLookupDefaultFunc) ArgGen

func (obj *MapLookupDefaultFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*MapLookupDefaultFunc) Build

func (obj *MapLookupDefaultFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*MapLookupDefaultFunc) Info

func (obj *MapLookupDefaultFunc) Info() *interfaces.Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*MapLookupDefaultFunc) Init

func (obj *MapLookupDefaultFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*MapLookupDefaultFunc) Polymorphisms

func (obj *MapLookupDefaultFunc) Polymorphisms(partialType *types.Type, partialValues []types.Value) ([]*types.Type, error)

Polymorphisms returns the list of possible function signatures available for this static polymorphic function. It relies on type and value hints to limit the number of returned possibilities.

func (*MapLookupDefaultFunc) Stream

func (obj *MapLookupDefaultFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*MapLookupDefaultFunc) String

func (obj *MapLookupDefaultFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*MapLookupDefaultFunc) Unify

Unify returns the list of invariants that this func produces.

func (*MapLookupDefaultFunc) Validate

func (obj *MapLookupDefaultFunc) Validate() error

Validate tells us if the input struct takes a valid form.

type MapLookupFunc

type MapLookupFunc struct {
	Type *types.Type // Kind == Map, that is used as the map we lookup
	// contains filtered or unexported fields
}

MapLookupFunc is a key map lookup function. If you provide a missing key, then it will return the zero value for that type.

func (*MapLookupFunc) ArgGen

func (obj *MapLookupFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*MapLookupFunc) Build

func (obj *MapLookupFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*MapLookupFunc) Info

func (obj *MapLookupFunc) Info() *interfaces.Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*MapLookupFunc) Init

func (obj *MapLookupFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*MapLookupFunc) Stream

func (obj *MapLookupFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*MapLookupFunc) String

func (obj *MapLookupFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*MapLookupFunc) Unify

func (obj *MapLookupFunc) Unify(expr interfaces.Expr) ([]interfaces.Invariant, error)

Unify returns the list of invariants that this func produces.

func (*MapLookupFunc) Validate

func (obj *MapLookupFunc) Validate() error

Validate tells us if the input struct takes a valid form.

type OperatorFunc

type OperatorFunc struct {
	Type *types.Type // Kind == Function, including operator arg
	// contains filtered or unexported fields
}

OperatorFunc is an operator function that performs an operation on N values.

func (*OperatorFunc) ArgGen

func (obj *OperatorFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*OperatorFunc) Build

func (obj *OperatorFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*OperatorFunc) Info

func (obj *OperatorFunc) Info() *interfaces.Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*OperatorFunc) Init

func (obj *OperatorFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*OperatorFunc) Polymorphisms

func (obj *OperatorFunc) Polymorphisms(partialType *types.Type, partialValues []types.Value) ([]*types.Type, error)

Polymorphisms returns the list of possible function signatures available for this static polymorphic function. It relies on type and value hints to limit the number of returned possibilities.

func (*OperatorFunc) Stream

func (obj *OperatorFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*OperatorFunc) String

func (obj *OperatorFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*OperatorFunc) Unify

func (obj *OperatorFunc) Unify(expr interfaces.Expr) ([]interfaces.Invariant, error)

Unify returns the list of invariants that this func produces.

func (*OperatorFunc) Validate

func (obj *OperatorFunc) Validate() error

Validate tells us if the input struct takes a valid form.

type StructLookupFunc

type StructLookupFunc struct {
	Type *types.Type // Kind == Struct, that is used as the struct we lookup
	Out  *types.Type // type of field we're extracting
	// contains filtered or unexported fields
}

StructLookupFunc is a struct field lookup function.

func (*StructLookupFunc) ArgGen

func (obj *StructLookupFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*StructLookupFunc) Build

func (obj *StructLookupFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*StructLookupFunc) Info

func (obj *StructLookupFunc) Info() *interfaces.Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*StructLookupFunc) Init

func (obj *StructLookupFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*StructLookupFunc) Polymorphisms

func (obj *StructLookupFunc) Polymorphisms(partialType *types.Type, partialValues []types.Value) ([]*types.Type, error)

Polymorphisms returns the list of possible function signatures available for this static polymorphic function. It relies on type and value hints to limit the number of returned possibilities.

func (*StructLookupFunc) Stream

func (obj *StructLookupFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*StructLookupFunc) String

func (obj *StructLookupFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*StructLookupFunc) Unify

func (obj *StructLookupFunc) Unify(expr interfaces.Expr) ([]interfaces.Invariant, error)

Unify returns the list of invariants that this func produces.

func (*StructLookupFunc) Validate

func (obj *StructLookupFunc) Validate() error

Validate tells us if the input struct takes a valid form.

type StructLookupOptionalFunc

type StructLookupOptionalFunc struct {
	Type *types.Type // Kind == Struct, that is used as the struct we lookup
	Out  *types.Type // type of field we're extracting (also the type of optional)
	// contains filtered or unexported fields
}

StructLookupOptionalFunc is a struct field lookup function. It does a special trick in that it will unify on a struct that doesn't have the specified field in it, but in that case, it will always return the optional value. This is a bit different from the "default" mechanism that is used by list and map lookup functions.

func (*StructLookupOptionalFunc) ArgGen

func (obj *StructLookupOptionalFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*StructLookupOptionalFunc) Build

func (obj *StructLookupOptionalFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*StructLookupOptionalFunc) Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*StructLookupOptionalFunc) Init

func (obj *StructLookupOptionalFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*StructLookupOptionalFunc) Stream

func (obj *StructLookupOptionalFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*StructLookupOptionalFunc) String

func (obj *StructLookupOptionalFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*StructLookupOptionalFunc) Unify

Unify returns the list of invariants that this func produces.

func (*StructLookupOptionalFunc) Validate

func (obj *StructLookupOptionalFunc) Validate() error

Validate tells us if the input struct takes a valid form.

Directories

Path Synopsis
Package dage implements a DAG function engine.
Package dage implements a DAG function engine.
Package facts provides a framework for language values that change over time.
Package facts provides a framework for language values that change over time.
util
Package util provides some functions to be imported by the generated file.
Package util provides some functions to be imported by the generated file.
Package ref implements reference counting for the graph API and function engine.
Package ref implements reference counting for the graph API and function engine.
Package txn contains the implementation of the graph transaction system.
Package txn contains the implementation of the graph transaction system.
Package vars provides a framework for language vars.
Package vars provides a framework for language vars.

Jump to

Keyboard shortcuts

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