nustack

forms

Form and TypedNu - the type-wrapping layer.

Module nu.lang.forms.

Form and TypedNu - the type-wrapping layer.

Form is a mixin that contributes shared helpers (sentinel checks) to typed interfaces. The collection ABCs (MappingForm, SequenceForm, ...) and the primitive leaves (Int, Str, ...) inherit Form to get them.

TypedNu[T] is a transparent ScalarQuery passthrough: it wraps a single Nu child (any non-Term child is auto-wrapped as a Literal by Nu) and yields the child's value unchanged. Operand recursion lives in the child thunk; TypedNu just forwards. Leaf interfaces inherit both Form and TypedNu so they participate as Nu tree nodes:

Int(Add(a, b)) + 1  ->  Add(Int(Add(a, b)), Literal(1))

TypedNuStream[T] is its stream-shaped twin: a transparent StreamQuery passthrough over one stream child, so a stream form (Iterator) sits wherever the validator expects a stream.

Hierarchy:

Form                                    mixin (sentinel checks)
TypedNu[T]                              ScalarQuery passthrough
TypedNuStream[T]                        StreamQuery passthrough
Int(Form, TypedNu[int])            primitive leaf
Dict(MutableMappingForm, TypedNu[dict])   collection leaf

The sentinel-check helpers and Bool they return live in nu.forms; Form reaches them with a lazy import so this module keeps no import-time dependency on the forms package (it would be a cycle: forms imports Form).

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

TypedNu

Transparent ScalarQuery passthrough carrying a python type tag T.

TypedNu()

Path nu.lang.TypedNu. Kind ScalarQuery, sort scalar_query, cardinality scalar.

Wraps a single Nu child and yields its value unchanged - sentinels ride through untouched. The type tag is for the fluent surface only; it has no runtime effect.

Undocumented: yields, example.

TypedNuStream

Transparent StreamQuery passthrough carrying a python type tag T.

TypedNuStream()

Path nu.lang.TypedNuStream. Kind StreamQuery, sort stream_query, cardinality stream.

The stream twin of TypedNu: wraps a single stream child and yields its items unchanged, so a stream form is stream-sorted and every stream consumer (Collect, Map, ForEachDo, ...) accepts it. The type tag is for the fluent surface only; it has no runtime effect.

Undocumented: yields, example.

On this page