Developer Tools
vgenerics
Generic functions with type constraints, checked when they run.
Released v1.0.0 · 2026-09-28use "stdlib/generics.ven"
A runtime checked way to declare a type constraint on a function's arguments, wrapping the function so a call is checked against the constraint before it runs, distinct from Venutian's ordinary containers, which accept any value. It gives a function a stated, enforced shape without adding a new construct to the language itself.
print TypeParam("T", ["Integer", "Text"])
Reference (6 functions)
API reference
type_param(name, allowed_kinds)
Declares a named, constrained type parameter for use with generic.
type_param("T", ["Integer", "Text"])kind_allowed(actual_kind, allowed_kinds)
Tests whether actual_kind satisfies one of allowed_kinds.
kind_allowed("Integer", ["Integer", "Text"])is_instance_of_kind(actual_kind, allowed_kind)
Tests whether shape actual_kind descends from allowed_kind.
is_instance_of_kind("Dog", "Animal")is_type_param_value(spec)
Tests whether spec is a TypeParam value, for use as one param_specs entry.
is_type_param_value(type_param("T", []))check_generic_call(args, param_specs, label)
Checks one call's arguments against param_specs, raising on the first violation.
check_generic_call([1, 2], ["Integer", "Integer"], "add")generic(fn, param_specs, label)
Wraps fn so every call is checked against param_specs before fn itself runs.
add_same = generic(add_fn, [pair, pair], "add_same")