coremap

package
v0.0.0-...-2561dba Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MapLookupFuncName is the name this function is registered as.
	MapLookupFuncName = "lookup" // map.lookup

)
View Source
const (
	// ModuleName is the prefix given to all the functions in this module.
	ModuleName = "map"
)

Variables

This section is empty.

Functions

func MapKeys

func MapKeys(ctx context.Context, input []types.Value) (types.Value, error)

MapKeys returns a list of keys from the map.

func MapValues

func MapValues(ctx context.Context, input []types.Value) (types.Value, error)

MapValues returns a list of values from the map.

Types

type MapLookupFunc

type MapLookupFunc struct {
	*wrapped.Func // *wrapped.Func as a type alias to pull in the base impl.

	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. It can take either two or three arguments. The first argument is the map to lookup a value by key in. The second is the key to use. If you specify a third argument, then this value will be returned if the map key is not present. If the third argument is omitted, then this function errors if the map key is not present.

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) Copy

func (obj *MapLookupFunc) Copy() interfaces.Func

Copy is implemented so that the obj.hasDefault value is not lost if we copy this function. That value is learned during FuncInfer, and previously would have been lost by the time we used it in Build.

func (*MapLookupFunc) FuncInfer

func (obj *MapLookupFunc) FuncInfer(partialType *types.Type, partialValues []types.Value) (*types.Type, []*interfaces.UnificationInvariant, error)

FuncInfer takes partial type and value information from the call site of this function so that it can build an appropriate type signature for it. The type signature may include unification variables.

func (*MapLookupFunc) Function

func (obj *MapLookupFunc) Function(ctx context.Context, input []types.Value) (types.Value, error)

Function is the actual implementation here. This is used in lieu of the Stream function which we'd have these contents within.

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) 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) Validate

func (obj *MapLookupFunc) Validate() error

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

Jump to

Keyboard shortcuts

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