Documentation
¶
Index ¶
- Constants
- Variables
- func ModuleRegister(module, name string, fns []*types.FuncValue)
- func Register(name string, fns []*types.FuncValue)
- type WrappedFunc
- func (obj *WrappedFunc) ArgGen(index int) (string, error)
- func (obj *WrappedFunc) Build(typ *types.Type) error
- func (obj *WrappedFunc) Close() error
- func (obj *WrappedFunc) Info() *interfaces.Info
- func (obj *WrappedFunc) Init(init *interfaces.Init) error
- func (obj *WrappedFunc) Polymorphisms(partialType *types.Type, partialValues []types.Value) ([]*types.Type, error)
- func (obj *WrappedFunc) Stream() error
- func (obj *WrappedFunc) Validate() error
Constants ¶
const ( // DirectInterface specifies whether we should use the direct function // API or not. If we don't use it, then these simple functions are // wrapped with the struct below. DirectInterface = false // XXX: fix any bugs and set to true! )
Variables ¶
var RegisteredFuncs = make(map[string][]*types.FuncValue) // must initialize
RegisteredFuncs maps a function name to the corresponding static, pure funcs.
Functions ¶
func ModuleRegister ¶
ModuleRegister is exactly like Register, except that it registers within a named module. This is a helper function.
func Register ¶
Register registers a simple, static, pure, polymorphic function. It is easier to use than the raw function API, but also limits you to small, finite numbers of different polymorphic type signatures per function name. You can also register functions which return types containing variants, if you want automatic matching based on partial types as well. Some complex patterns are not possible with this API. Implementing a function like `printf` would not be possible. Implementing a function which counts the number of elements in a list would be.
Types ¶
type WrappedFunc ¶
type WrappedFunc struct { Fns []*types.FuncValue // list of possible functions // contains filtered or unexported fields }
WrappedFunc is a scaffolding function struct which fulfills the boiler-plate for the function API, but that can run a very simple, static, pure, polymorphic function.
func (*WrappedFunc) ArgGen ¶
func (obj *WrappedFunc) ArgGen(index int) (string, error)
ArgGen returns the Nth arg name for this function.
func (*WrappedFunc) Build ¶
func (obj *WrappedFunc) Build(typ *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.
func (*WrappedFunc) Close ¶
func (obj *WrappedFunc) Close() error
Close runs some shutdown code for this function and turns off the stream.
func (*WrappedFunc) Info ¶
func (obj *WrappedFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*WrappedFunc) Init ¶
func (obj *WrappedFunc) Init(init *interfaces.Init) error
Init runs some startup code for this function.
func (*WrappedFunc) Polymorphisms ¶
func (obj *WrappedFunc) 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 (*WrappedFunc) Stream ¶
func (obj *WrappedFunc) Stream() error
Stream returns the changing values that this func has over time.
func (*WrappedFunc) Validate ¶
func (obj *WrappedFunc) Validate() error
Validate makes sure we've built our struct properly. It is usually unused for normal functions that users can use directly.