bend-kit-resources Releases (1): 0.1.0.0 0x8ef64648a1ae4481382be5e5ce2a9fc8 indexed https://jend.leeeet.dev/files.txt?path=bend-kit-resources@0.1.0.0 Definitions (18): Resources.Pool (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=Pool) # A pool of `capacity` units, `held` of them reserved. `owner` names the pool, # so a reservation cannot return to a different pool. type Pool is Data: Pool{owner: Nat, capacity: Nat, held: Nat} Resources.Grant (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=Grant) # A reservation of `amount` units from the pool named `owner`. It is affine: # it cannot be copied, so it is released at most once. type Grant is Type: Grant{owner: Nat, amount: Nat} Resources.Reserve (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=Reserve) type Reserve is Type: Took{pool: Pool, grant: Grant} Refused{pool: Pool} Resources.Release (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=Release) type Release is Type: Released{pool: Pool} Kept{pool: Pool, grant: Grant} Resources.Split (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=Split) type Split is Type: Parts{taken: Grant, rest: Grant} Whole{grant: Grant} Resources.Combine (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=Combine) type Combine is Type: Joined{grant: Grant} Apart{first: Grant, second: Grant} Resources.new (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=new) # An empty pool of `capacity` units. def new(owner: Nat, capacity: Nat) -> Pool: Resources.capacity (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=capacity) def capacity(p: Pool) -> Nat: Resources.reserved (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=reserved) def reserved(p: Pool) -> Nat: Resources.available (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=available) # The units that a reserve can still take. def available(p: Pool) -> Nat: Resources.reserve.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=reserve.go) def reserve.go(fits: Bool, +o: Nat, c: Nat, h: Nat, +n: Nat) -> Reserve: Resources.reserve (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=reserve) # Takes n units when they fit. Refused hands back the pool unchanged. def reserve(p: Pool, +n: Nat) -> Reserve: Resources.release.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=release.go) def release.go(ok: Bool, o: Nat, c: Nat, h: Nat, q: Nat, +n: Nat) -> Release: Resources.release (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=release) # Returns g's units to p. Kept hands back both unchanged when g names another # pool or holds more than p has reserved. def release(p: Pool, g: Grant) -> Release: Resources.split.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=split.go) def split.go(fits: Bool, +o: Nat, +a: Nat, +n: Nat) -> Split: Resources.split (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=split) # Splits n units off g. Whole hands back g when it holds fewer than n. def split(g: Grant, +n: Nat) -> Split: Resources.combine.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=combine.go) def combine.go(same: Bool, o: Nat, a: Nat, q: Nat, b: Nat) -> Combine: Resources.combine (https://jend.leeeet.dev/definition.txt?path=bend-kit-resources@0.1.0.0/resources.bend&name=combine) # Joins two grants of one pool. Apart hands back both when their pools differ. def combine(x: Grant, y: Grant) -> Combine: