Module host

Module host 

Source
Expand description

What a host answers, as one description rather than one per backend.

§Why this is here and not in a backend

Four of Beck’s primitives cannot be computed. uuid() and now() are nondet, secret_env is env, and http_fetch is net.out(host) — each of them is a question whose answer is outside the program, which is exactly what an effect atom is (§3.2). A backend does not know the answers; it knows how to ask.

The tree-walker asked by calling four methods on beck_eval::interp::Host, which is a trait in the evaluator’s crate. A second backend that reached the same four answers a second way would be two descriptions of one thing, and the differential between the backends would be comparing them rather than comparing the program. So the four live here, on Atoms, and the evaluator’s Host extends it.

§The defaults are the seams

Every method has a default, and every default goes through the process seam docs/14-review-findings.md F11 asks for: crate::clock for the wall clock, crate::net for the outbound call, the process environment for a secret. A host that wants to answer differently overrides one method; a host that does not still never names a clock or a network stack.

§A request is a value, and that conversion is here too

http_fetch takes a value the program built and answers with a value the program reads, and the translation between those and crate::net’s Request/Reply is neither the evaluator’s business nor a compiler’s. request_of, reply_value and failure_value are that translation, in one place, so that two backends making the same call cannot send two different requests.

Structs§

ProcessAtoms
The host every default answers for: the process this is running in.

Traits§

Atoms
The impure capabilities a host supplies, one method per effect atom.

Functions§

failure_value
The seam’s Failure as the HttpError the call raises.
reply_value
What came back, as the HttpResponse the program reads.
request_of
An HttpRequest the program built, as the request the seam sends.
uuid_v7
A time-ordered id, without pulling a uuid crate into the tree for one call.