Documentation ¶
Index ¶
- Constants
- func MapKeys(ctx context.Context, input []types.Value) (types.Value, error)
- func MapValues(ctx context.Context, input []types.Value) (types.Value, error)
- type MapLookupFunc
- func (obj *MapLookupFunc) ArgGen(index int) (string, error)
- func (obj *MapLookupFunc) Build(typ *types.Type) (*types.Type, error)
- func (obj *MapLookupFunc) Copy() interfaces.Func
- func (obj *MapLookupFunc) FuncInfer(partialType *types.Type, partialValues []types.Value) (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *MapLookupFunc) Function(ctx context.Context, input []types.Value) (types.Value, error)
- func (obj *MapLookupFunc) Info() *interfaces.Info
- func (obj *MapLookupFunc) String() string
- func (obj *MapLookupFunc) Validate() error
Constants ¶
const ( // MapLookupFuncName is the name this function is registered as. MapLookupFuncName = "lookup" // map.lookup )
const (
// ModuleName is the prefix given to all the functions in this module.
ModuleName = "map"
)
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
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.