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 ¶
- Variables
- func Arg[T any](c *Call, i int) T
- func As[T any](v any) T
- func AttrOf[T any](c *Call) (T, bool)
- func DeclareWith(b Bundle, d *Decl)deprecated
- func DecorateType(b Bundle, t *Type)deprecated
- func FieldAttrs[T any]() map[string][]any
- func FieldAttrsOf(t reflect.Type) map[string][]any
- func Instance[F any](s *Instances, build func() F) F
- func ObserveCalls(fn CallObserver) (stop func())
- func RegisterAdapter[F any](adapt func(next F, call Caller) F)
- func RegisterFields[T any](attrs map[string][]any)
- func RegisterFunc(fn any, attrs ...any)
- func RegisterType[T any](attrs ...any)
- func SortBy[T any](xs []T, orders ...Order[T])
- func Wrap[F any](fn F, info FuncInfo, chain ...Decorator) F
- type Attrs
- type Bundle
- type Call
- type CallObserver
- type Caller
- type CompareRef
- type Decl
- type Decorated
- type Decorator
- type Field
- type FieldAttrsDeclarer
- type FieldPath
- func (p FieldPath) Attr(ptr any) bool
- func (p FieldPath) Attrs() []any
- func (p FieldPath) Fields() []reflect.StructField
- func (p FieldPath) Index() [][]int
- func (p FieldPath) Names() []string
- func (p FieldPath) Root() reflect.Type
- func (p FieldPath) String() string
- func (p FieldPath) Value(root any) (any, bool)
- type File
- type Funcdeprecated
- type FuncInfo
- type FuncRef
- type Instances
- type NoAdvice
- type NullableRef
- type Op
- type Option
- type Order
- type OrderedRef
- type Param
- type Pred
- type Ref
- func (r Ref[T, V]) Asc() Order[T]
- func (r Ref[T, V]) Attr(ptr any) bool
- func (r Ref[T, V]) Attrs() []any
- func (r Ref[T, V]) Desc() Order[T]
- func (r Ref[T, V]) Eq(v V) Pred[T]
- func (r Ref[T, V]) FieldPath() FieldPath
- func (r Ref[T, V]) Get(t T) V
- func (r Ref[T, V]) In(vs ...V) Pred[T]
- func (r Ref[T, V]) Lookup(t T) (V, bool)
- func (r Ref[T, V]) Name() string
- func (r Ref[T, V]) Ne(v V) Pred[T]
- func (r Ref[T, V]) Path() []string
- type Related
- type Result
- type Static
- type Statics
- type StringRef
- type Targets
- type Type
Constants ¶
This section is empty.
Variables ¶
var ErrNotFunc = errors.New("vuka: not a function")
ErrNotFunc is FuncOf's error for a value that is no function, or nil.
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.
func DeclareWith
deprecated
added in
v0.10.0
func DecorateType
deprecated
added in
v0.10.0
func FieldAttrs ¶ added in v0.7.0
FieldAttrs is the typed attributes of T's fields, by field name: for
type Post struct {
Title string @Char{Max: 200}
}
FieldAttrs[Post]()["Title"] is []any{Char{Max: 200}}. It is nil for a type whose fields carry none. It holds the attributes RegisterFields recorded and those a FieldAttrsDeclarer declares: a model's Schema method's (s.Field(&p.Title, orm.Char{Max: 200})), with its model attributes on its embedded orm.Model field, where a Vuka model writes them.
func FieldAttrsOf ¶ added in v0.7.0
FieldAttrsOf is FieldAttrs for a reflect.Type.
func Instance ¶
Instance returns the instantiation of a generic decorated function whose type is F, building it the first time.
func ObserveCalls ¶ added in v0.14.0
func ObserveCalls(fn CallObserver) (stop func())
ObserveCalls has fn see the steps of every decorated call of the program: the hook of a tracer, or of a web framework's development toolbar timing each decorator. It returns what stops it.
func RegisterAdapter ¶ added in v1.0.0
RegisterAdapter has Wrap call functions of type F through adapt instead of reflection: adapt packs a call's arguments for call and unpacks its results. The vuka command writes one per signature a package decorates, in vuka_calls_gen.go:
vuka.RegisterAdapter(func(next func(int, int) int, call vuka.Caller) func(int, int) int {
invoke := func(a []any) []any { return []any{next(vuka.As[int](a[0]), vuka.As[int](a[1]))} }
return func(a0, a1 int) int {
r := call([]any{a0, a1}, invoke)
return vuka.As[int](r[0])
}
})
The first adapter registered for F is kept.
func RegisterFields ¶ added in v0.7.0
RegisterFields records the typed attributes of T's fields, by field name, for FieldAttrs to read: Vuka's field attributes on a struct with no schema method to hold them (orm.Base's Schema, ui.Live's LiveSchema), written at init.
func init() {
vuka.RegisterFields[Address](map[string][]any{"City": {Char{Max: 50}}})
}
func RegisterFunc ¶ added in v0.16.0
RegisterFunc records the typed attributes of a function, or of a method given as its method expression ((*Board).Clear). Generated code calls it at init; Go code may too, for a declaration it writes by hand.
func RegisterType ¶ added in v0.16.0
RegisterType records the typed attributes of type T. Generated code calls it at init.
func SortBy ¶ added in v0.7.0
SortBy sorts xs by the orders, the first deciding, the next breaking ties; the sort is stable.
func Wrap ¶ added in v1.0.0
Wrap is fn with chain around each of its calls, outermost first: what a call decorator on a function is, written by hand.
var save = vuka.Wrap(saveOrder, vuka.FuncInfo{Name: "orders.save"}, logged, retry(3))
A method keeps its name and calls the wrapped method expression, built on first use (a package-level var can't refer to itself):
var storeSave vuka.Decorated[func(*Store, context.Context, Order) error]
func (s *Store) Save(ctx context.Context, o Order) error {
return storeSave.Get(func() func(*Store, context.Context, Order) error {
return vuka.Wrap((*Store).save, vuka.FuncInfo{Name: "Store.Save", Method: true}, logged)
})(s, ctx, o)
}
The call goes through reflection unless an adapter for F is registered (RegisterAdapter), which the vuka command generates for a package's decorated functions. With no decorators Wrap is fn.
Types ¶
type Attrs ¶ added in v0.16.0
type Attrs []any
Attrs are a declaration's typed attributes, as the lookups return them.
func MethodAttrs ¶ added in v0.16.0
MethodAttrs are the typed attributes declared on method name of t (or of the type t points to), its bundles' included; not its type's, which TypeAttrs has. None for a method Vuka registered nothing for.
type Bundle ¶ added in v0.10.0
type Bundle struct {
// contains filtered or unexported fields
}
Bundle is a composed decorator: decorators and attributes applied as one, as Spring's @RestController stands for @Controller and @ResponseBody.
decorator ApiRoute(path string) = @web.Get(path) @web.Use(auth) @timed
declares a function returning a Bundle; @ApiRoute("/pets") on a function applies each of them, in order, as if written there. Plain Go builds one with Compose.
func Compose ¶ added in v0.10.0
Compose bundles decorators and attributes: each item is a call decorator (func(*Call)), a declarer (func(*Decl)), a type decorator (func(*Type)), another Bundle (its items, in place), or an attribute (any other value).
func Dual ¶ added in v0.30.0
Dual is a decorator for a function and for a type alike: written on a function it runs decl, on a type typ. web.Get is one: a route on a handler, a page on a component type.
func (Bundle) Declare ¶ added in v1.0.0
Declare runs the bundle's declarers with d, as when it is written on the function d describes: b.Declare(vuka.DeclOf(ShowPet)).
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 (*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) Attrs ¶ added in v0.16.0
Attrs are the declaration's typed attributes, its bundles' included: on a method, its own (a type's call decorators advising it see the method's, not the type's).
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) ParamAttr ¶ added in v0.10.0
ParamAttr fills ptr with parameter i's typed attribute of ptr's element type, reporting whether there is one. i indexes c.Args:
func Create(@Valid in NewPet) error
for i := range c.Args {
var v Valid
if c.ParamAttr(i, &v) { … }
}
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 CallObserver ¶ added in v0.14.0
CallObserver sees a decorated call go through its steps, on the goroutine of the call: each decorator (d), and the function itself (d nil). What it returns, when not nil, is called once the step returns.
type Caller ¶ added in v1.0.0
Caller runs a call through its decorators: args are the call's, the receiver first for a method, and invoke calls the function with the arguments the decorators leave; it returns the results they leave.
type CompareRef ¶ added in v0.7.0
CompareRef is a reference to a field whose type orders itself, such as time.Time.
func CompareRefOf ¶ added in v0.7.0
func CompareRefOf[T any, V interface{ Compare(V) int }](index [][]int, _ func(*T)) CompareRef[T, V]
func CompareRefTo ¶ added in v1.0.0
func CompareRefTo[T any, V interface{ Compare(V) int }](field func(*T) *V) CompareRef[T, V]
func (CompareRef[T, V]) Asc ¶ added in v0.7.0
func (r CompareRef[T, V]) Asc() Order[T]
func (CompareRef[T, V]) Desc ¶ added in v0.7.0
func (r CompareRef[T, V]) Desc() Order[T]
func (CompareRef[T, V]) Ge ¶ added in v0.7.0
func (r CompareRef[T, V]) Ge(v V) Pred[T]
Ge is the predicate field >= v, by V's Compare.
func (CompareRef[T, V]) Gt ¶ added in v0.7.0
func (r CompareRef[T, V]) Gt(v V) Pred[T]
Gt is the predicate field > v, by V's Compare.
func (CompareRef[T, V]) Le ¶ added in v0.7.0
func (r CompareRef[T, V]) Le(v V) Pred[T]
Le is the predicate field <= v, by V's Compare.
func (CompareRef[T, V]) Lt ¶ added in v0.7.0
func (r CompareRef[T, V]) Lt(v V) Pred[T]
Lt is the predicate field < v, by V's Compare.
type Decl ¶ added in v0.6.0
type Decl struct {
Name string // "main.ShowPet", "PetAdmin.Index"
Pkg string // the package's import path
File string // the source file's base name, and the line of the name, for messages
Line int
Attrs []any // the declaration's typed attributes
// Func is the function, wrapped by the declaration's other decorators, so
// calling it runs them too. For a method it is the method expression:
// func(recv, args…).
Func any
Recv reflect.Type // the receiver type, for a method
Params []Param // the parameters, receiver excluded
Results []reflect.Type
Variadic bool
}
Decl describes a declaration for a declarer: a decorator of type func(d *vuka.Decl), which runs once at program start rather than around each call. Declarers register things — routes, commands, jobs — from the declarations they decorate:
func Get(path string) func(*vuka.Decl) {
return func(d *vuka.Decl) { routes[path] = d.Func }
}
func DeclOf ¶ added in v1.0.0
DeclOf describes a function, or a method by its method expression ((*Store).Save), for its declarers, which are called with it:
Get("/pets/{id}")(vuka.DeclOf(ShowPet, vuka.Param{Name: "id"}))
params name its parameters and give their attributes, in order, the receiver excluded (reflection can't see names). Its attributes are those registered for it (RegisterFunc), its file and line where the compiler puts it, and its Name the runtime's: the package is its import path's last element ("main" in a program, though a main package's tests build it under its path).
func MethodDecl
deprecated
added in
v0.6.0
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 Field ¶ added in v0.3.0
type Field struct {
Name string
Type reflect.Type
Tag reflect.StructTag
Attrs []any // the field's typed attributes
Injected bool // not blank, not tagged inject:"-": a parameter of New, when a pointer or interface for a type declaring a schema
}
Field is a field of a struct.
type FieldAttrsDeclarer ¶ added in v1.0.0
type FieldAttrsDeclarer interface {
DeclaredFieldAttrs(t reflect.Type, registered map[string][]any) map[string][]any
}
FieldAttrsDeclarer is a struct whose fields' attributes are declared another way than RegisterFields: by a library's schema method, as a model's are in its Schema method (orm.Model and orm.Base implement it). FieldAttrsOf asks it for t's — t being the struct or one embedding it — given what RegisterFields recorded for t, which it returns with the attributes it declares after them, or as they are when t isn't its own. It is asked of a zero t: a method of a pointer receiver it doesn't read is safe behind a nil embedded pointer.
type FieldPath ¶ added in v0.7.0
type FieldPath struct {
// contains filtered or unexported fields
}
FieldPath is where a field reference leads from its root struct: one step per field written (Post.Author.Name has two), each step an index path that passes through embedded structs. Between steps it goes through a pointer or a Related value.
func (FieldPath) Attr ¶ added in v0.7.0
Attr fills ptr with the last field's typed attribute of ptr's element type.
func (FieldPath) Fields ¶ added in v0.7.0
func (p FieldPath) Fields() []reflect.StructField
Fields are the struct fields of each step.
type File ¶ added in v0.6.0
type File string
File names a file of the program's source tree. A string literal written where a decorator or typed attribute takes a File is checked when the program is compiled (it must exist, in the package's directory or below) and embedded into the binary; the File then holds "importpath:relative/path" and Bytes returns the embedded content:
func Template(view vuka.File) func(*vuka.Decl) { … view.Bytes() … }
@Template("views/pet.html")
func showPet(id int) Pet { … }
A .templ file may be in a subdirectory that is a package of its own (views/pets.templ with `package views`): its File is then that package's ("module/views:pets.templ"). With templ and github.com/vuka-lang/ui, the file's components are registered too: templx.Components(f).
func (File) Bytes ¶ added in v0.6.0
Bytes is the file's content: embedded, or for a File Vuka didn't embed (a conversion such as vuka.File("x.txt")) read from disk.
type Func
deprecated
added in
v0.2.0
type Func struct {
Name string // "main.charge", "Store.Save"
Attrs []any // the declaration's typed attributes
// ParamAttrs are each parameter's typed attributes, receiver excluded:
// func Show(@Path("id") id int) has [][]any{{Path("id")}}. Nil when no
// parameter has any.
ParamAttrs [][]any
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 for NewCall.
Deprecated: use Wrap and FuncInfo; code generated by older versions of the vuka command builds a Func.
type FuncInfo ¶ added in v1.0.0
FuncInfo describes a function for its call decorators: the name they see (c.Name), whether its first parameter is a receiver (a method expression, (*Store).save), and the typed attributes c.Attr and c.ParamAttr read, the receiver's excluded.
type FuncRef ¶ added in v0.16.0
type FuncRef struct {
Name string // the runtime's name for the code: "example.com/app.(*Board).Clear-fm"
// Recv is a method's receiver type as declared (Board for *Board) when
// Vuka registered the type or one of its methods; Method is the
// method's name.
Recv reflect.Type
Method string
// Attrs are the declaration's typed attributes: a method's own (its
// type's are TypeAttrs(Recv)).
Attrs Attrs
// Literal says fn is a function literal ("…(*Board).Render.func1"): it
// is no declaration and has no attributes, and what it calls is found
// only when it runs.
Literal bool
}
FuncRef is the declaration a function value's code belongs to, as FuncOf finds it.
func FuncOf ¶ added in v0.16.0
FuncOf finds the declaration fn's code belongs to: a function, a method expression ((*Board).Clear) or a method value (b.Clear). A function literal is reported as one (Literal); a function or method nothing registered has no Attrs. A method value made by reflection (reflect.Value.Method) names no declaration either: look it up with MethodAttrs. Answers are cached per function, so a lookup costs a map read after the first.
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 NoAdvice ¶ added in v0.10.0
type NoAdvice struct{}
NoAdvice, on a method, leaves it out of its type's advice: the call decorators written on the type, which wrap its other exported methods.
@logged
type Store struct{ … }
@vuka.NoAdvice
func (s *Store) Dump() string { … }
type NullableRef ¶ added in v0.7.0
NullableRef is a reference to a field that can be nil or None.
func NullableRefOf ¶ added in v0.7.0
func NullableRefOf[T, V any](index [][]int, _ func(*T)) NullableRef[T, V]
func NullableRefTo ¶ added in v1.0.0
func NullableRefTo[T, V any](field func(*T) *V) NullableRef[T, V]
func (NullableRef[T, V]) IsNil ¶ added in v0.7.0
func (r NullableRef[T, V]) IsNil() Pred[T]
IsNil is the predicate that the field is nil or None (or that a nil pointer or relation is on the way).
func (NullableRef[T, V]) NotNil ¶ added in v0.7.0
func (r NullableRef[T, V]) NotNil() Pred[T]
NotNil is the predicate that the field is neither nil nor None.
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 Order ¶ added in v0.7.0
Order is an ordering of Ts by a field: Post.Views.Desc().
type OrderedRef ¶ added in v0.7.0
OrderedRef is a reference to a number field (or any cmp.Ordered type).
func OrderedRefOf ¶ added in v0.7.0
func OrderedRefOf[T any, V cmp.Ordered](index [][]int, _ func(*T)) OrderedRef[T, V]
func OrderedRefTo ¶ added in v1.0.0
func OrderedRefTo[T any, V cmp.Ordered](field func(*T) *V) OrderedRef[T, V]
func (OrderedRef[T, V]) Asc ¶ added in v0.7.0
func (r OrderedRef[T, V]) Asc() Order[T]
func (OrderedRef[T, V]) Desc ¶ added in v0.7.0
func (r OrderedRef[T, V]) Desc() Order[T]
func (OrderedRef[T, V]) Ge ¶ added in v0.7.0
func (r OrderedRef[T, V]) Ge(v V) Pred[T]
Ge is the predicate field >= v.
func (OrderedRef[T, V]) Gt ¶ added in v0.7.0
func (r OrderedRef[T, V]) Gt(v V) Pred[T]
Gt is the predicate field > v.
func (OrderedRef[T, V]) Le ¶ added in v0.7.0
func (r OrderedRef[T, V]) Le(v V) Pred[T]
Le is the predicate field <= v.
func (OrderedRef[T, V]) Lt ¶ added in v0.7.0
func (r OrderedRef[T, V]) Lt(v V) Pred[T]
Lt is the predicate field < v.
type Param ¶ added in v0.6.0
Param is a parameter of a declared function: its name as written ("" when unnamed), type, and the typed attributes written before it:
func Show(@Path("pet_id") id int)
type Pred ¶ added in v0.7.0
type Pred[T any] struct { Op Op Path FieldPath // the field tested; zero for and, or and not Value any // the operand: a V, a []V for in; nil for isnil, notnil and the combinations Preds []Pred[T] // the operands of and, or and not // contains filtered or unexported fields }
Pred is a condition on a T, built from field references — Post.Views.Gt(100), vuka.Or(…) — and kept as data, so a query builder can translate it (Op, the field's Path and attributes, the Value) or Match can test it in memory. Being typed by T, a Pred[User] can't be passed where a Pred[Post] is wanted.
type Ref ¶ added in v0.7.0
type Ref[T, V any] struct { // contains filtered or unexported fields }
Ref is a field reference: Post.Title in Vuka source, a typed handle on the Title field of Post, of type V. Through pointer, struct and Related fields it reaches further: Post.Author.Name. Its methods build predicates and orderings over T, or read the field.
Vuka picks the most capable kind for the field's type: StringRef for strings, OrderedRef for numbers, CompareRef for types with a Compare method (time.Time), NullableRef for pointers, slices, maps, interfaces and Options, and Ref for the rest.
func RefOf
deprecated
added in
v0.7.0
RefOf, OrderedRefOf, StringRefOf, CompareRefOf and NullableRefOf make references from index paths. The function is never called: it is there so the compiler and the editor see the fields the reference names.
Deprecated: use RefTo and its kinds, which name the field by address; code generated by older versions of the vuka command calls these.
func RefTo ¶ added in v1.0.0
RefTo is a reference to the field whose address field returns, the way a field reference is written in Go, Post.Title in Vuka source:
title := vuka.StringRefTo(func(p *Post) *string { return &p.Title })
city := vuka.StringRefTo(func(p *Post) *string { return &p.Home.City })
name := vuka.StringRefTo(func(p *Post) *string { return &p.Author.Related().Name })
The path goes through embedded structs, pointers and Related values. The compiler checks the fields; field runs once per instantiation, on a value of T made for it (nil pointers filled in), and must only select fields. OrderedRefTo, StringRefTo, CompareRefTo and NullableRefTo make the other kinds (see Ref).
func (Ref[T, V]) Attr ¶ added in v0.7.0
Attr fills ptr with the field's typed attribute of ptr's element type.
func (Ref[T, V]) Get ¶ added in v0.7.0
func (r Ref[T, V]) Get(t T) V
Get is the field's value in t, or V's zero value when a nil pointer or relation is on the way.
func (Ref[T, V]) Lookup ¶ added in v0.7.0
Lookup is the field's value in t; false when a nil pointer or relation is on the way.
type Related ¶ added in v0.7.0
type Related[T any] interface{ Related() *T }
Related is implemented by a field type that refers to a T held elsewhere, such as a foreign key. A field reference continues through it into T's fields: with Author of a type implementing Related[User], Post.Author.Name is a Ref[Post, string]. Related returns nil when there is no T.
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.
func StaticOf ¶ added in v0.2.0
StaticOf returns the static field of the instantiated type K, built by init on first use: a package-level value per instantiation, which Go has no variable for. Vuka's static of a generic type, static Objects = &Store[Self]{} in Model[Self], is
var modelObjectsStatics vuka.Statics
func ModelObjects[Self any]() *vuka.Static[*Store[Self]] {
return vuka.StaticOf[Model[Self]](&modelObjectsStatics, func() *Store[Self] { return &Store[Self]{} })
}
type Statics ¶ added in v0.2.0
type Statics struct {
// contains filtered or unexported fields
}
Statics holds one generic static field's instantiations.
type StringRef ¶ added in v0.7.0
type StringRef[T any, V ~string] struct{ OrderedRef[T, V] }
StringRef is a reference to a string field.
func StringRefOf ¶ added in v0.7.0
func StringRefTo ¶ added in v1.0.0
func (StringRef[T, V]) Contains ¶ added in v0.7.0
Contains is the predicate that the field contains s.
func (StringRef[T, V]) EndsWith ¶ added in v0.7.0
EndsWith is the predicate that the field ends with s.
func (StringRef[T, V]) StartsWith ¶ added in v0.7.0
StartsWith is the predicate that the field starts with s.
type Targets ¶ added in v0.10.0
type Targets uint16
Targets restricts where an attribute type may be written, as Java's @Target does. Written on the type, it makes any other use a compile error at the attribute:
@vuka.Targets(vuka.OnField)
type Char struct{ Max int }
Go code declares the same with a method whose result's length is the targets: func (Char) vukaTargets() [vuka.OnField]struct{} { return {} }.
type Type ¶ added in v0.2.0
type Type struct {
Name string // "main.User"
Reflect reflect.Type
Attrs []any // the declaration's typed attributes
New any // the constructor, for a struct; nil otherwise
Fields []Field // the struct's fields
}
Type describes a decorated type, for a type decorator:
func Model(t *vuka.Type) { registry[t.Name] = t.Reflect }
For a struct, New is a constructor taking each dependency field as a parameter (or the type's own static New, when it declares one), which is the shape dependency-injection containers take:
func Component(t *vuka.Type) { providers = append(providers, t.New) }
func TypeFor ¶ added in v1.0.0
TypeFor describes T for its type decorators, which are called with it:
component(vuka.TypeFor[UserService](NewUserService))
ctor is T's constructor (NewUserService), nil when it has none; attrs are its typed attributes, a Bundle's own included (its other decorators are not). Name is T as reflect writes it ("main.UserService").
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
vuka
module
|
|
|
vukavet
module
|
|
|
Package diag is the shape of every diagnostic the vuka toolchain reports: the transpiler, vuka vet, the editor and the libraries' boot-time checks.
|
Package diag is the shape of every diagnostic the vuka toolchain reports: the transpiler, vuka vet, the editor and the libraries' boot-time checks. |
|
Package docs holds the diagnostic catalogue: docs/errors/<code>.md, one page per code, rendered by the docs site and printed by `vuka explain`.
|
Package docs holds the diagnostic catalogue: docs/errors/<code>.md, one page per code, rendered by the docs site and printed by `vuka explain`. |
|
internal
|
|
|
format
Package format formats Vuka source: the Go in it exactly as gofmt does, and its JSX the way Prettier lays out markup, without changing what it renders.
|
Package format formats Vuka source: the Go in it exactly as gofmt does, and its JSX the way Prettier lays out markup, without changing what it renders. |
|
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. |
|
tsprops
Package tsprops reads the props a client component declares — a Vue SFC's defineProps/defineModel/defineEmits, a React component's props parameter, a Svelte component's $props(), a vanilla island's mount(el, props, ctx) — from its source, without Node: a small reader of the TypeScript types people write for props.
|
Package tsprops reads the props a client component declares — a Vue SFC's defineProps/defineModel/defineEmits, a React component's props parameter, a Svelte component's $props(), a vanilla island's mount(el, props, ctx) — from its source, without Node: a small reader of the TypeScript types people write for props. |
|
Package transpile turns Vuka source into Go.
|
Package transpile turns Vuka source into Go. |
