Record and replay
An effect goes to the host, and the answer of the host can be different at each run. A clock, a random number and a request are examples. A failed run is then hard to find again.
The function recorder wraps the function perform of a host. Its log has each effect with its address, its kind, its payload and its answer. The function replayer makes a new perform from that log. A replay gives each answer of the log, and the host gets no call. Thus the replay gives the result of the recording.
A replay examines each effect
Section titled “A replay examines each effect”The replayer finds each effect by its address. It compares the kind and the payload of the effect with the log. A different effect at an address gives #REPLAY!, and the run stops there. Thus a replay of a changed document does not give an old answer to a new question.
The address comes from the place of the effect in the document. A new step before an effect takes the address of that effect, thus the log refuses it.
Select Record a run to get a new log. Then select a document under Replay against, and select Next effect to step through the log.
seq(a = log("the time"), b = log(a + 1), write("total", b))
#REPLAY!. In a recording the arrow goes to the host. In a replay it stops at the log.A log is data
Section titled “A log is data”The function encodeLog writes a log as JSON, and decodeLog reads it again. Thus a host can store a log and replay it on another computer. An error of a recording comes again with its code, its reason and its place.