~/bend-docscommunity

ordinary_capture_query.bend checks

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

10 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

Types

type Owner source · line 30 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0xb2b0f04555daca474f0f77d0966945c9/ordinary_query_declaration.Declaration<S, 0xb2b0f04555daca474f0f77d0966945c9/compose.Frame<S, C, R, E>, Ops(0xb2b0f04555daca474f0f77d0966945c9/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0xb2b0f04555daca474f0f77d0966945c9/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 34 · 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 40 · 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 46 · 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 14 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0xb2b0f04555daca474f0f77d0966945c9/ordinary_query_declaration.Declaration<S, 0xb2b0f04555daca474f0f77d0966945c9/compose.Frame<S, C, R, E>, Ops(0xb2b0f04555daca474f0f77d0966945c9/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0xb2b0f04555daca474f0f77d0966945c9/transaction.Outcome<U>, Out)))) -> 0xb2b0f04555daca474f0f77d0966945c9/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 16 · raw

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

template runner source · line 24 · raw

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

Advanced captured-query runner with explicit (args,cursor). Threads L through selected rows while the ECS transaction journals 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 49 · raw

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

template define source · line 57 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0xb2b0f04555daca474f0f77d0966945c9/ordinary_query_declaration.Declaration<S, 0xb2b0f04555daca474f0f77d0966945c9/compose.Frame<S, C, R, E>, Ops(0xb2b0f04555daca474f0f77d0966945c9/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0xb2b0f04555daca474f0f77d0966945c9/transaction.Outcome<U>, Out)))) -> @world:0xb2b0f04555daca474f0f77d0966945c9/world.World<S, C, R, E> -> @name:String -> @capture:L -> Registration<0xb2b0f04555daca474f0f77d0966945c9/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 59 · raw

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

template run source · line 69 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0xb2b0f04555daca474f0f77d0966945c9/ordinary_query_declaration.Declaration<S, 0xb2b0f04555daca474f0f77d0966945c9/compose.Frame<S, C, R, E>, Ops(0xb2b0f04555daca474f0f77d0966945c9/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0xb2b0f04555daca474f0f77d0966945c9/transaction.Outcome<U>, Out)))) -> @owner:Owner<S, C, R, E, L, Ops, A, U, Out, query, body> -> @world:0xb2b0f04555daca474f0f77d0966945c9/world.World<S, C, R, E> -> @args:A -> Run<0xb2b0f04555daca474f0f77d0966945c9/world.World<S, C, R, E>, Owner<S, C, R, E, L, Ops, A, U, Out, query, body>, A, 0xb2b0f04555daca474f0f77d0966945c9/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 rolls back recorded World changes but retains capture changes; registration refusal returns original args without running body. Deferred commands remain invisible until explicit barriers.

template skip source · line 75 · raw

@-S:Data -> @-C:Type -> @-R:Type -> @-E:Data -> @-L:Type -> @-Ops:(@_:Type -> Type) -> @-A:Data -> @-U:Data -> @-Out:Data -> @-query:0xb2b0f04555daca474f0f77d0966945c9/ordinary_query_declaration.Declaration<S, 0xb2b0f04555daca474f0f77d0966945c9/compose.Frame<S, C, R, E>, Ops(0xb2b0f04555daca474f0f77d0966945c9/compose.Frame<S, C, R, E>)> -> @-body:(@-H:Type -> @-caps:Ops(H) -> @_:L -> @_:A -> @_:H -> Pair(H, Pair(L, Pair(0xb2b0f04555daca474f0f77d0966945c9/transaction.Outcome<U>, Out)))) -> @owner:Owner<S, C, R, E, L, Ops, A, U, Out, query, body> -> @world:0xb2b0f04555daca474f0f77d0966945c9/world.World<S, C, R, E> -> Pair(Owner<S, C, R, E, L, Ops, A, U, Out, query, body>, 0xb2b0f04555daca474f0f77d0966945c9/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 77 · raw

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

template unregister source · line 84 · raw

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