~/bend-docscommunity

PROPOSED.bend open laws/TODOs

raw source on the hub · import 0x23d6c01e38291fa6120695d15d993373/PROPOSED.bend as PROPOSED

Route's laws, proposed (for the human to move into a LAWS.bend, reword or drop): PROOF.bend proves them. An API means what serving it does; these say that the ways of putting APIs together mean what they should, on every request and every server.

3 imports
import Base
import hhefesto-wire@1.0.0.0/Wire.bend as W
import ./Route.bend as R

Laws

law alt_id_left provedin PROOF.bendsource · line 12 · raw

@+a:0x23d6c01e38291fa6120695d15d993373/Route.rt.Api -> @s:0x23d6c01e38291fa6120695d15d993373/Route.rt.Server(a) -> @+req:0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Req -> {0x23d6c01e38291fa6120695d15d993373/Route.rt.serve(0x23d6c01e38291fa6120695d15d993373/Route.rt.Alt{0x23d6c01e38291fa6120695d15d993373/Route.rt.Nothing{}, a}, (Unit{}, s), req) == 0x23d6c01e38291fa6120695d15d993373/Route.rt.serve(a, s, req) : IO(0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Resp)}

Nothing is choice's identity, on the left and on the right: an API offered beside the one that answers nothing serves as the API alone.

law alt_id_right provedin PROOF.bendsource · line 18 · raw

@+a:0x23d6c01e38291fa6120695d15d993373/Route.rt.Api -> @s:0x23d6c01e38291fa6120695d15d993373/Route.rt.Server(a) -> @+req:0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Req -> {0x23d6c01e38291fa6120695d15d993373/Route.rt.serve(0x23d6c01e38291fa6120695d15d993373/Route.rt.Alt{a, 0x23d6c01e38291fa6120695d15d993373/Route.rt.Nothing{}}, (s, Unit{}), req) == 0x23d6c01e38291fa6120695d15d993373/Route.rt.serve(a, s, req) : IO(0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Resp)}

law alt_assoc provedin PROOF.bendsource · line 27 · raw

@+a:0x23d6c01e38291fa6120695d15d993373/Route.rt.Api -> @+b:0x23d6c01e38291fa6120695d15d993373/Route.rt.Api -> @+c:0x23d6c01e38291fa6120695d15d993373/Route.rt.Api -> @sa:0x23d6c01e38291fa6120695d15d993373/Route.rt.Server(a) -> @sb:0x23d6c01e38291fa6120695d15d993373/Route.rt.Server(b) -> @sc:0x23d6c01e38291fa6120695d15d993373/Route.rt.Server(c) -> @+req:0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Req -> {0x23d6c01e38291fa6120695d15d993373/Route.rt.serve(0x23d6c01e38291fa6120695d15d993373/Route.rt.Alt{0x23d6c01e38291fa6120695d15d993373/Route.rt.Alt{a, b}, c}, ((sa, sb), sc), req) == 0x23d6c01e38291fa6120695d15d993373/Route.rt.serve(0x23d6c01e38291fa6120695d15d993373/Route.rt.Alt{a, 0x23d6c01e38291fa6120695d15d993373/Route.rt.Alt{b, c}}, (sa, sb, sc), req) : IO(0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Resp)}

Choice is associative: how alternatives are grouped does not change what a request gets (the first to answer, or the first final error, or the most telling miss), the servers grouped the same way.

law seg_dist provedin PROOF.bendsource · line 39 · raw

@+p:String -> @+a:0x23d6c01e38291fa6120695d15d993373/Route.rt.Api -> @+b:0x23d6c01e38291fa6120695d15d993373/Route.rt.Api -> @sa:0x23d6c01e38291fa6120695d15d993373/Route.rt.Server(a) -> @sb:0x23d6c01e38291fa6120695d15d993373/Route.rt.Server(b) -> @+req:0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Req -> {0x23d6c01e38291fa6120695d15d993373/Route.rt.serve(0x23d6c01e38291fa6120695d15d993373/Route.rt.Seg{p, 0x23d6c01e38291fa6120695d15d993373/Route.rt.Alt{a, b}}, (sa, sb), req) == 0x23d6c01e38291fa6120695d15d993373/Route.rt.serve(0x23d6c01e38291fa6120695d15d993373/Route.rt.Alt{0x23d6c01e38291fa6120695d15d993373/Route.rt.Seg{p, a}, 0x23d6c01e38291fa6120695d15d993373/Route.rt.Seg{p, b}}, (sa, sb), req) : IO(0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Resp)}

A literal segment distributes over a choice: "/p" in front of a choice is the choice of the two with "/p" in front.

law text_round provedin PROOF.bendsource · line 49 · raw

@v:String -> {0x23d6c01e38291fa6120695d15d993373/Route.rt.parse(0x23d6c01e38291fa6120695d15d993373/Route.rt.TText{}, 0x23d6c01e38291fa6120695d15d993373/Route.rt.print(0x23d6c01e38291fa6120695d15d993373/Route.rt.TText{}, v)) == Done{v} : Result<&2, &2, String, String>}

A text capture reads back what is printed for it.