ordinary_lifetime_scope_io.bend

bendvy-ecs-core@0.1.0.1 · 23 lines · 0 definitions

1import Base
2import bendvy-ecs-core@0.1.0.1/ordinary_lifetime_scope.bend as Ord
3import bendvy-ecs-core@0.1.0.1/lifetime_scope.bend as Sc
4import bendvy-ecs-core@0.1.0.1/world_io.bend as IOCreate
5import bendvy-ecs-core@0.1.0.1/ordinary_schema_provision.bend as Provision
6import bendvy-ecs-core@0.1.0.1/world.bend as W
7import bendvy-ecs-core@0.1.0.1/relation_commands.bend as A
8
9# Canonical IO creation remains foreign execution, never a mathematical proof.
10def created(~S:Data,~C:Type,~R:Type,~empty:Unit -> C,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~E:Data,value:Provision.Provision<S,A.Store<S,Sc.Store<S,C>>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)>,result:IOCreate.Creation<S,A.Store<S,Sc.Store<S,C>>,R,A.Notice<S,E>>) -> IO(Provision.Provision<S,A.Store<S,Sc.Store<S,C>>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)> & IOCreate.Creation<S,A.Store<S,Sc.Store<S,C>>,R,A.Notice<S,E>>):
11  IO.pure(Provision.Provision<S,A.Store<S,Sc.Store<S,C>>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)> & IOCreate.Creation<S,A.Store<S,Sc.Store<S,C>>,R,A.Notice<S,E>>,(value,result))
12# Create a World with the scope/relation-wrapped provision in host IO.
13# Consumes resource R and returns the provision together with world-io.Creation:
14# Created carries the new World; Refused returns the incoming resource owner.
15# Uses the checked host namespace allocator, not a caller-chosen namespace.
16# No entity is spawned, made live or assigned to a scope by World creation.
17# Use lifetime-scope.scope on the returned World to obtain a same-world token;
18# scoped spawn and cleanup remain deferred until an explicit command barrier.
19# This is an IO setup boundary, not a mathematical proof or an automatic affine
20# finalizer. Example: test-fixtures/public-scopes/feature-timing-v1/fixture.bend:
21# create; main.bend observes linked, persistent, failed and retried scope work.
22def create(~S:Data,~C:Type,~R:Type,~empty:Unit -> C,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~E:Data,value:Provision.Provision<S,A.Store<S,Sc.Store<S,C>>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)>,resource:R) -> IO(Provision.Provision<S,A.Store<S,Sc.Store<S,C>>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)> & IOCreate.Creation<S,A.Store<S,Sc.Store<S,C>>,R,A.Notice<S,E>>):
23  IO.bind(IOCreate.Creation<S,A.Store<S,Sc.Store<S,C>>,R,A.Notice<S,E>>,Provision.Provision<S,A.Store<S,Sc.Store<S,C>>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)> & IOCreate.Creation<S,A.Store<S,Sc.Store<S,C>>,R,A.Notice<S,E>>,IOCreate.create(~S,~A.Store<S,Sc.Store<S,C>>,~R,~A.Notice<S,E>,~Ord.empty_store(~S,~C,~empty),resource),result => created(~S,~C,~R,~empty,~count,~E,value,result))