Skuld.Comp.ForeignSuspend (skuld v0.31.1)

View Source

Suspension for external/foreign resources (e.g., JavaScript Promises).

Like InternalSuspend, the resume function receives the env at resume time — (val, env) -> {result, env}. This allows the scheduler to inject updated shared state into the env before the continuation runs.

The :payload field is an opaque handle for the foreign platform to resolve the suspension. Skuld treats it as a black box — it never inspects or uses it directly. The Hologram JS runtime stores a Promise ref here; other platforms would store whatever their event loop needs.

Fields

  • id — unique identifier (from FreshInt.fresh_integer()), used by the foreign platform to correlate a resolved resource back to this suspension
  • resume — continuation, receives (val, env) -> {result, env}
  • payload — opaque handle for the foreign platform

Summary

Types

t()

@type t() :: %Skuld.Comp.ForeignSuspend{
  id: term(),
  payload: term(),
  resume: (term(), Skuld.Comp.Env.t() -> {term(), Skuld.Comp.Env.t()})
}