LearnEffects and runtimeAsk, answer, handle

Ask, answer, handle

Run an effect and decide how it resumes.

ask requests an effect. answer defines how to respond. handle runs code with that answer.

let clockAnswer := answer Clock {
  tick(k) => resume 1;
};

handle Clock.tick() answer clockAnswer;

Ask

ask Clock.tick();

The ask is the point where pure code reaches an effect boundary.

Answer

let clockAnswer := answer Clock {
  tick(k) => resume 1;
};

An answer receives the continuation and resumes it with a value.

Handle

handle Clock.tick() answer clockAnswer;

A handler keeps policy at the edge. Code inside can ask for the effect without knowing whether the answer is real, fake, cached, or logged.

Continuation

The parameter k is the continuation for the ask. resume 1 sends a value back to the waiting code.

Keep answers short. If answering needs policy, parse config, or logging, move that work into named helpers and keep the handler readable.