package corelist

import "github.com/purpleidea/mgmt/lang/core/list"

Index

Constants

const (
	// ListConcatFuncName is the name this function is registered as.
	ListConcatFuncName = "concat" // list.lookup
)
const (
	// ListLookupFuncName is the name this function is registered as.
	ListLookupFuncName = "lookup" // list.lookup

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

Types

type ListConcatFunc

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

	Type *types.Type // Kind == List, that is used as every list type
	// contains filtered or unexported fields
}

ListConcatFunc is a function which combines a number of lists into one list. It can take one or more arguments. It combines them in argument order.

func (*ListConcatFunc) ArgGen

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

ArgGen returns the Nth arg name for this function.

func (*ListConcatFunc) Build

func (obj *ListConcatFunc) 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 (*ListConcatFunc) Copy

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

Copy is implemented so that the obj.length 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 (*ListConcatFunc) FuncInfer

func (obj *ListConcatFunc) 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 (*ListConcatFunc) Function

func (obj *ListConcatFunc) 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 (*ListConcatFunc) Info

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

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

func (*ListConcatFunc) String

func (obj *ListConcatFunc) String() string

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

func (*ListConcatFunc) Validate

func (obj *ListConcatFunc) Validate() error

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

type ListLookupFunc

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

	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. It can take either two or three arguments. The first argument is the list to lookup a value in. The second is the integer index. If you specify a third argument, then this value will be returned if the list index is not present. If the third argument is omitted, then this function errors if the list index is not present. Passing a negative index will always result in an error.

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

func (obj *ListLookupFunc) 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 (*ListLookupFunc) FuncInfer

func (obj *ListLookupFunc) 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 (*ListLookupFunc) Function

func (obj *ListLookupFunc) 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 (*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) 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) Validate

func (obj *ListLookupFunc) Validate() error

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

Source Files

list.go list_concat.go list_lookup.go

Version
v0.0.0-20250322185616-c50a578426f1 (latest)
Published
Mar 22, 2025
Platform
linux/amd64
Imports
10 packages
Last checked
4 days ago

Tools for package owners.