Skuld.Comp.ISentinel protocol (skuld v0.1.13)
View SourceProtocol for handling sentinel values in run/run! and generic sentinel inspection.
Sentinels are control flow values (Suspend, Throw, etc.) that bypass normal computation flow. This protocol allows generic handling without coupling to specific sentinel types.
Summary
Functions
Get the resume function if this sentinel is resumable, nil otherwise.
Complete a computation result - invoke leave_scope or bypass for sentinels
Extract value or raise for sentinel types
Is this a sentinel value? Returns false for plain values.
Get the serializable payload (struct fields minus :resume). Used for logging/serialization.
Return a new sentinel with the resume function replaced. Returns unchanged if not resumable.
Types
@type t() :: term()
All the types that implement this protocol.
Functions
@spec get_resume(t()) :: (term() -> {term(), Skuld.Comp.Types.env()}) | nil
Get the resume function if this sentinel is resumable, nil otherwise.
@spec run(t(), Skuld.Comp.Types.env()) :: {Skuld.Comp.Types.result(), Skuld.Comp.Types.env()}
Complete a computation result - invoke leave_scope or bypass for sentinels
Extract value or raise for sentinel types
Is this a sentinel value? Returns false for plain values.
Get the serializable payload (struct fields minus :resume). Used for logging/serialization.
@spec with_resume(t(), (term() -> {term(), Skuld.Comp.Types.env()})) :: t()
Return a new sentinel with the resume function replaced. Returns unchanged if not resumable.