~/bend-docscommunity

ordinary_capture_query.bend checks

raw source on the hub · import bendvy-ecs-core@0.1.0.7/ordinary_capture_query.bend as Ordinary_capture_query

11 imports
import Base
import ./change_tick.bend as Tick
import ./world.bend as W
import ./compose.bend as Q
import ./capture_query.bend as Fold
import ./ordinary_query_declaration.bend as Decl
import ./ordinary_system.bend as Ordinary
import ./local.bend as Local
import ./captures.bend as Capture
import ./transaction.bend as T
import ./commands.bend as Cmd

Types

type Owner source · line 31 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0x7e321819d0ff210531780719c7674cef/ordinary_query_declaration.Declaration<S, 0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>, Ops(0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0x7e321819d0ff210531780719c7674cef/transaction.Outcome<U>, Out)))) -> Type

Runtime-bound captured-query owner: a Local instance owns affine capture L and a separate cursor tracks query lifecycle visibility. Keep both returned parts together across runs; raw constructors are trusted administration.

type Registration source · line 35 · raw

@World:Type -> @Owned:Type -> @L:Type -> Type

Registered returns World and captured-query owner; Rejected returns World and initial capture L without invoking the query body.

type Run source · line 41 · raw

@World:Type -> @Owned:Type -> @A:Data -> @Error:Data -> @Out:Data -> Type

Completed returns World, retained capture owner and ordered row outputs or query error. Refused returns World/owner and original Data args before body execution. Capture state survives body failure; failed row outputs do not.

type Removal source · line 47 · raw

@World:Type -> @Owned:Type -> @L:Type -> Type

Removed returns World and detached affine capture after deregistration. RemovalRejected returns World and original owner. No finalizer is invoked here: caller decides how to reuse or dispose the returned capture.

Templates

template plan source · line 15 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0x7e321819d0ff210531780719c7674cef/ordinary_query_declaration.Declaration<S, 0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>, Ops(0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0x7e321819d0ff210531780719c7674cef/transaction.Outcome<U>, Out)))) -> 0x7e321819d0ff210531780719c7674cef/compose.Plan<S, C, R, E, Ops>

Capture lifecycle reuses Local; each completed run consumes its captured tick. Advanced lowering of the closed query declaration into its typed grant and membership predicate; it performs no traversal or capture mutation.

template finished source · line 17 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-U:Data -> @-Out:Data -> @result:0x7e321819d0ff210531780719c7674cef/capture_query.Executed<0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E>, L, 0x7e321819d0ff210531780719c7674cef/compose.Error<U>, Out> -> 0x7e321819d0ff210531780719c7674cef/local.Outcome<0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E>, L, 0x7e321819d0ff210531780719c7674cef/compose.Error<U>, List<&2, Out>>

template runner source · line 25 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0x7e321819d0ff210531780719c7674cef/ordinary_query_declaration.Declaration<S, 0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>, Ops(0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0x7e321819d0ff210531780719c7674cef/transaction.Outcome<U>, Out)))) -> @world:0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E> -> @capture:L -> @args:Pair(A, Maybe<&2, 0x7e321819d0ff210531780719c7674cef/change_tick.Tick>) -> 0x7e321819d0ff210531780719c7674cef/local.Outcome<0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E>, L, 0x7e321819d0ff210531780719c7674cef/compose.Error<U>, List<&2, Out>>

Advanced captured-query runner with explicit (args,cursor). Threads L through selected rows while retaining performed World changes. Failure retains returned capture but discards row outputs. Bypasses runtime registration checks; ordinary callers use define/run or App capture add.

template registered source · line 50 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0x7e321819d0ff210531780719c7674cef/ordinary_query_declaration.Declaration<S, 0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>, Ops(0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0x7e321819d0ff210531780719c7674cef/transaction.Outcome<U>, Out)))) -> @result:0x7e321819d0ff210531780719c7674cef/local.Registered<S, C, R, E, L, Pair(A, Maybe<&2, 0x7e321819d0ff210531780719c7674cef/change_tick.Tick>), 0x7e321819d0ff210531780719c7674cef/compose.Error<U>, List<&2, Out>, runner(S, C, R, E, L, Ops, A, U, Out, query, body)> -> Registration<0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E>, Owner<S, C, R, E, L, Ops, A, U, Out, query, body>, L>

template define source · line 58 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0x7e321819d0ff210531780719c7674cef/ordinary_query_declaration.Declaration<S, 0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>, Ops(0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0x7e321819d0ff210531780719c7674cef/transaction.Outcome<U>, Out)))) -> @world:0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E> -> @name:String -> @capture:L -> Registration<0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E>, Owner<S, C, R, E, L, Ops, A, U, Out, query, body>, L>

Register a captured query with access derived from the same declaration. Consumes capture; refusal returns it with World. Success owns a real Local registration and initializes an absent query cursor. No body runs at setup. Example: examples/captured-query/app.bend.

template returned source · line 60 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0x7e321819d0ff210531780719c7674cef/ordinary_query_declaration.Declaration<S, 0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>, Ops(0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0x7e321819d0ff210531780719c7674cef/transaction.Outcome<U>, Out)))) -> @cursor:Maybe<&2, 0x7e321819d0ff210531780719c7674cef/change_tick.Tick> -> @result:0x7e321819d0ff210531780719c7674cef/local.Run<S, C, R, E, L, Pair(A, Maybe<&2, 0x7e321819d0ff210531780719c7674cef/change_tick.Tick>), 0x7e321819d0ff210531780719c7674cef/compose.Error<U>, List<&2, Out>, runner(S, C, R, E, L, Ops, A, U, Out, query, body)> -> Run<0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E>, Owner<S, C, R, E, L, Ops, A, U, Out, query, body>, A, 0x7e321819d0ff210531780719c7674cef/compose.Error<U>, Out>

template run source · line 70 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0x7e321819d0ff210531780719c7674cef/ordinary_query_declaration.Declaration<S, 0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>, Ops(0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0x7e321819d0ff210531780719c7674cef/transaction.Outcome<U>, Out)))) -> @owner:Owner<S, C, R, E, L, Ops, A, U, Out, query, body> -> @world:0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E> -> @args:A -> Run<0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E>, Owner<S, C, R, E, L, Ops, A, U, Out, query, body>, A, 0x7e321819d0ff210531780719c7674cef/compose.Error<U>, Out>

Execute the checked captured-query registration at its retained cursor. Completed success/error consume the captured execution tick; refusal preserves it. Query failure retains performed World changes and returned capture changes; registration refusal returns original args without running body. Deferred commands remain invisible until explicit barriers.

template skip source · line 76 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0x7e321819d0ff210531780719c7674cef/ordinary_query_declaration.Declaration<S, 0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>, Ops(0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0x7e321819d0ff210531780719c7674cef/transaction.Outcome<U>, Out)))) -> @owner:Owner<S, C, R, E, L, Ops, A, U, Out, query, body> -> @world:0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E> -> Pair(Owner<S, C, R, E, L, Ops, A, U, Out, query, body>, 0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E>)

No callback entry: preserve capture and the existing query reader cursor. Return the same captured owner and World without invoking the body. Both capture state and query cursor remain unchanged.

template removed source · line 78 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0x7e321819d0ff210531780719c7674cef/ordinary_query_declaration.Declaration<S, 0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>, Ops(0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0x7e321819d0ff210531780719c7674cef/transaction.Outcome<U>, Out)))) -> @cursor:Maybe<&2, 0x7e321819d0ff210531780719c7674cef/change_tick.Tick> -> @result:0x7e321819d0ff210531780719c7674cef/local.Disposal<S, C, R, E, L, Pair(A, Maybe<&2, 0x7e321819d0ff210531780719c7674cef/change_tick.Tick>), 0x7e321819d0ff210531780719c7674cef/compose.Error<U>, List<&2, Out>, runner(S, C, R, E, L, Ops, A, U, Out, query, body), L> -> Removal<0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E>, Owner<S, C, R, E, L, Ops, A, U, Out, query, body>, L>

template unregister source · line 85 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0x7e321819d0ff210531780719c7674cef/ordinary_query_declaration.Declaration<S, 0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>, Ops(0x7e321819d0ff210531780719c7674cef/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0x7e321819d0ff210531780719c7674cef/transaction.Outcome<U>, Out)))) -> @owner:Owner<S, C, R, E, L, Ops, A, U, Out, query, body> -> @world:0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E> -> Removal<0x7e321819d0ff210531780719c7674cef/world.World<S, C, R, E>, Owner<S, C, R, E, L, Ops, A, U, Out, query, body>, L>

Remove the matching registration and return its actual affine capture. Refusal returns the original owner for retry; success returns Removed with World/capture. Does not invoke a user finalizer or reset unrelated systems.