Documentation
¶
Overview ¶
Package vuka is the runtime of Vuka programs: Result and Option.
Vuka code writes Result[User], Ok(u), Err(e), Some(x) and None unqualified; the transpiler points them here. Go code uses the package like any other.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶ added in v0.2.0
As converts a value held in an any back to T; nil is T's zero value. It panics, naming both types, when a decorator put something else there.
Types ¶
type Call ¶ added in v0.2.0
type Call struct {
Name string
Receiver any // the receiver, for a method
Args []any // the arguments; a variadic parameter is one slice
Results []any // the results, once Next has run (or Return was called)
// contains filtered or unexported fields
}
Call is one call of a decorated function, passed down its decorators.
func NewCall ¶ added in v0.2.0
NewCall starts a call through chain, ending in invoke. Generated code calls it.
func (*Call) Attr ¶ added in v0.2.0
Attr fills ptr with the declaration's typed attribute of ptr's element type, reporting whether there is one: var r Route; c.Attr(&r).
func (*Call) Context ¶ added in v0.2.0
Context is the call's context.Context argument, or context.Background().
func (*Call) Next ¶ added in v0.2.0
func (c *Call) Next()
Next runs the rest of the chain: the next decorator, or the function itself. It can be called more than once.
func (*Call) Return ¶ added in v0.2.0
Return sets the results without running the function; the rest of the chain is skipped unless Next is called.
type Decorated ¶
type Decorated[F any] struct { // contains filtered or unexported fields }
Decorated holds a decorated function, built from its decorators on first use. Vuka generates one per decorated function or method.
type Decorator ¶ added in v0.2.0
type Decorator func(c *Call)
Decorator wraps a call of any function: it runs code around c.Next(), may change c.Args before it, read or replace c.Results after it, call it again (retries) or not at all (caches). Written once, it decorates any function or method:
func logged(c *vuka.Call) {
fmt.Println("calling", c.Name, c.Args)
c.Next()
}
A decorator with parameters is a function returning one; it runs once per decorated function, so state it keeps isn't shared between functions.
type Func ¶ added in v0.2.0
type Func struct {
Name string // "main.charge", "Store.Save"
Attrs []any // the declaration's typed attributes
ErrIndex int // the trailing error result's index, or -1
CtxIndex int // the context.Context argument's index, or -1
Zero func() []any
}
Func describes a decorated function. Vuka generates one per function.
type Instances ¶
type Instances struct {
// contains filtered or unexported fields
}
Instances holds a generic decorated function's instantiations, each built from its decorators on first use.
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
Option is a value that may be absent. The zero Option is None.
func None ¶
None is an absent value. Vuka code writes plain None; the transpiler fills in T from where the value goes.
func (Option[T]) Unwrap ¶
func (o Option[T]) Unwrap() T
Unwrap is the value; it panics when o is None.
type Result ¶
type Result[T any] struct { // contains filtered or unexported fields }
Result is a value or an error. It is Ok when it holds no error; the zero Result is Ok with T's zero value.
func (Result[T]) Unwrap ¶
func (r Result[T]) Unwrap() T
Unwrap is the value; it panics when r failed.
type Static ¶ added in v0.2.0
type Static[V any] struct { V V }
Static is the storage of a static field of a generic type: one per instantiation, so Model[User] and Model[Order] each have their own.
type Statics ¶ added in v0.2.0
type Statics struct {
// contains filtered or unexported fields
}
Statics holds one generic static field's instantiations.
type Type ¶ added in v0.2.0
type Type struct {
Name string // "main.User"
Reflect reflect.Type
Attrs []any // the declaration's typed attributes
}
Type describes a decorated type, for a type decorator:
func Model(t *vuka.Type) { registry[t.Name] = t.Reflect }
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
vuka
command
Command vuka transpiles Vuka source to Go and runs the go command over it.
|
Command vuka transpiles Vuka source to Go and runs the go command over it. |
|
vukavet
module
|
|
|
internal
|
|
|
load
Package load finds Vuka packages in a module and supplies what transpiling them needs from the go command: build-context file selection, export data for imports, and the overlay that puts generated files in front of the compiler.
|
Package load finds Vuka packages in a module and supplies what transpiling them needs from the go command: build-context file selection, export data for imports, and the overlay that puts generated files in front of the compiler. |
|
Package transpile turns Vuka source into Go.
|
Package transpile turns Vuka source into Go. |
