nustack
ReferenceNu

lang

Nu the language, layer 1 on the engine.

Module nu.lang.

Nu the language, layer 1 on the engine.

lang is Nu defined on top of nu.engine. Top-level vocabulary:

  • nu - the Nu base class.
  • kinds - the kind taxonomy (Ref / Interaction / ScalarQuery / ...).
  • args - argument type aliases (IntArg, StrArg, ...) for kind signatures.
  • sentinels - EMPTY / INVALID and their guards.
  • attributes - the attribute concerns (sort, cardinality, effects, execution).
  • laws - LAWS and the predicate library.
  • runtime - Runtime, Context, Budget, lifecycle helpers.
  • helpers - top-level user-facing entries (run, eval, astream, ...).

A Term is built from the kind taxonomy, compiled against the schema, then gated or validated, then driven through an entry.

Modules

ModuleWhat
nu.lang.runtimeRuntime: how Nu programs run.

kinds

Module nu.lang.kinds.

The Nu kind taxonomy: the user-facing Term classes that declare each sort.

Full entries

NameSortCallMeaning
ActionAction()Abstract: a dual-citizen Interaction. Mutates Context and yields a value.
BracketbracketBracket()A Span that governs a body's lifecycle.
Commandscalar_commandCommand()A mutating Interaction. Yields nothing; its only sub-shape is scalar.
ControlcontrolControl()A Flow that composes Commands under Query parameters.
FlowFlow()Abstract: a Command-composing Interaction. Yields nothing.
InteractionInteraction()Abstract: a node that interacts with the Context. Never instantiated.
PolicypolicyPolicy()A Span that governs a body's execution on failure.
QueryQuery()Abstract: a value-producing Interaction.
ReductionreductionReduction()A ScalarQuery that folds a stream child down to one value.
ScalarActionscalar_actionScalarAction()An Action that mutates and yields exactly one value.
ScalarQueryscalar_queryScalarQuery()A Query that yields exactly one value.
SpanSpan()Abstract: a transparent Interaction; yields what its body yields.
StrategystrategyStrategy()A Flow that composes Commands directly.
StreamActionstream_actionStreamAction()An Action that mutates and yields zero or more values.
StreamQuerystream_queryStreamQuery()A Query that yields zero or more values.

literal

Module nu.lang.literal.

Literal: wraps a raw Python value as a Nu term.

Full entries

NameSortCallMeaning
Literalscalar_queryLiteral(value)A constant value wrapped as a term.

forms

Module nu.lang.forms.

Form and TypedNu - the type-wrapping layer.

Full entries

NameSortCallMeaning
TypedNuscalar_queryTypedNu()Transparent ScalarQuery passthrough carrying a python type tag T.

args

Module nu.lang.args.

Argument type aliases for Nu kind class signatures.

Full entries

NameCallMeaning
Arglang.Arg()Create named, parameterized type aliases.
DictArglang.DictArg()Create named, parameterized type aliases.
FrozenSetArglang.FrozenSetArg()Create named, parameterized type aliases.
ListArglang.ListArg()Create named, parameterized type aliases.
SetArglang.SetArg()Create named, parameterized type aliases.
TupleArglang.TupleArg()Create named, parameterized type aliases.

helpers.evaluation

Module nu.lang.helpers.evaluation.

Drive entries: run a compiled Program through the Runtime.

Full entries

NameCallMeaning
acollectlang.acollect(program, ctx=None, max_parallel=1)Async sibling of collect.
aevallang.aeval(program, ctx=None, max_parallel=1)Drive a Program asynchronously; return (value, ctx).
afirstlang.afirst(program, ctx=None, max_parallel=1)Async sibling of first.
alastlang.alast(program, ctx=None, max_parallel=1)Drain a stream-rooted Program and return the last item; (value, ctx).
collectlang.collect(program, ctx=None, max_parallel=1)Materialize a stream-rooted Program to a list; (values, ctx).
evallang.eval(program, ctx=None, max_parallel=1)Drive a Program synchronously; return (value, ctx).
eval_in_looplang.eval_in_loop(program, ctx=None, max_parallel=1)Drive an async-only Program from sync code by spinning a loop.
firstlang.first(program, ctx=None, max_parallel=1)Return the first item of a stream-rooted Program; (value, ctx).

helpers.run

Module nu.lang.helpers.run.

All-in-one entries: compile, validate, drive in one call.

Full entries

NameCallMeaning
arunlang.arun(term, ctx=None, max_parallel=1)Async sibling of run: compile, validate, then aeval.
runlang.run(term, ctx=None, max_parallel=1)Compile a Term, validate it, evaluate it; return (value, ctx).
run_in_looplang.run_in_loop(term, ctx=None, max_parallel=1)Compile, validate, then drive on a fresh loop from sync code.

attributes

Module nu.lang.attributes.

Nu's attributes: one module per concern, plus the schema that assembles them.

Full entries

NameCallMeaning
build_schemalang.build_schema()Build and finalize the Nu schema from every concern's attributes.

helpers.compilation

Module nu.lang.helpers.compilation.

Nu-specialized compile: binds the finalized Nu SCHEMA.

Full entries

NameCallMeaning
compilelang.compile(term)Compile a Nu Term against the Nu schema; return a runnable Program.

nu.engine.validation.law

Module nu.engine.validation.law.

Law: a declarative validity rule, plus the verdict primitives and runners.

Full entries

NameCallMeaning
gatelang.gate(program)Run every law over every node and return every Violation found.

sentinels

Module nu.lang.sentinels.

Sentinels - EMPTY and INVALID.

Full entries

NameCallMeaning
is_emptylang.is_empty(value)True if value is the EMPTY sentinel.
is_invalidlang.is_invalid(value)True if value is the INVALID sentinel.
is_sentinellang.is_sentinel(value)True if value is any Sentinel.

attributes.sort

Module nu.lang.attributes.sort.

Sort attribute: the structural taxonomy of a Term.

Full entries

NameCallMeaning
matrix_sortlang.matrix_sort(sort)Resolve sort to the matrix sort it slot-fits as, or None.
subsortlang.subsort(sort, ancestor)Return whether sort is ancestor or descends from it in the tree.

nu.engine.validation.predicate

Module nu.engine.validation.predicate.

Predicate: a composable (program, path) -> bool test.

Full entries

NameCallMeaning
predicatelang.predicate(test)Wrap a (program, path) -> bool function as a composable Predicate.

helpers.validation

Module nu.lang.helpers.validation.

Nu-specialized validate: binds the Nu LAWS.

Full entries

NameCallMeaning
validatelang.validate(program)Validate a compiled Program against the Nu law set.

typeinfo

Module nu.lang.typeinfo.

Recursive type info for shape slots.

Full entries

NameCallMeaning
value_type_forlang.value_type_for(python_type)Map a Python primitive type to its Form class (Any fallback).

On this page