Skip to main content

Module dispatch

Module dispatch 

Source
Expand description

Choosing which proof answers a call.

A proposition may have several proofs. Which one runs is decided here, at the moment of the call, from a policy the caller supplies — ask for speed and you get the fast one, ask for a small footprint and you get the frugal one, and the answer is the same either way. That is the arrangement this whole system exists to make possible, and it is a policy decision rather than an architectural one precisely because nothing above this layer had to know which proof it was getting.

§Checking both sides

Arguments are checked against the signature before an implementation sees them, and the result is checked before the caller does. The second check is the one that earns its keep: an implementation that returns the wrong shape has failed to prove what it claimed, and that has to be loud. It is the only failure that never falls back to another proof, because trying someone else would be papering over a broken proof rather than working around a broken machine.

Asking for sort also considers proofs of anything that refines sort, since a proof of a stronger claim proves the weaker one too. A caller gets the benefit of a specialised implementation without having to know it exists.

§Equivalence reorders the call

An equivalence link says two signatures are one proposition with the parameters renamed and reordered — request(url, cb) and request(callback, getUrl). Asking for either considers the proofs of both, and a proof of the other one is handed the arguments in the order it takes them. Nothing is converted: an equivalence only pairs parameters that hold the same data, so putting them in another order is the whole of it.

Structs§

Considered
One candidate and what became of it.
Dispatcher
Decides which proof answers a call, and runs it.
Invocation
What happened when a proposition was called.
Options
What the dispatcher checks and how forgiving it is.

Enums§

Outcome
Why a candidate was passed over, or what happened to it.
Policy
How to choose among the proofs of a proposition.