restore_raw_owner.bend
bendvy-ecs-core@0.1.0.4 · 22 lines · 3 definitions
1import Base
2import bendvy-ecs-core@0.1.0.4/decode_data.bend as D
3import bendvy-ecs-core@0.1.0.4/snapshot_data.bend as Snapshot
4import bendvy-ecs-core@0.1.0.4/restore_raw.bend as Raw
5
6
7
8
9type Returned<Owner:Type,Runtime:Type,Output:Type> is Type:
10 ParseRejected{owner:Owner,runtime:Runtime,original:D.Raw,error:Raw.Error}
11 Delivered{original:D.Raw,output:Output}
12def parsed(~Owner:Type,~Runtime:Type,~Output:Type,~run:Owner -> Runtime -> Snapshot.Snapshot -> Output,+original:D.Raw,owner:Owner,runtime:Runtime,result:Raw.Parsed) -> Returned<Owner,Runtime,Output>:
13 match result:
14 case Raw.Rejected{input,error}:ParseRejected{owner,runtime,input,error}
15 case Raw.Accepted{snapshot}:Delivered{original,run(owner,runtime,snapshot)}
16
17
18
19
20
21def run(~Owner:Type,~Runtime:Type,~Output:Type,~restore:Owner -> Runtime -> Snapshot.Snapshot -> Output,owner:Owner,runtime:Runtime,+input:D.Raw) -> Returned<Owner,Runtime,Output>:
22 parsed(~Owner,~Runtime,~Output,~restore,input,owner,runtime,Raw.parse(input))