Skuld.Comp.ScopeEnv (skuld v0.27.2)
View SourceScope machinery carried through a computation.
Groups the three elements that define what scope a computation is running in:
evidence— installed effect handlersleave_scope— cleanup chain for scoped effectstransform_suspend— suspend decoration chain, also scoped
These three are installed together via scoped/2, inherited together at fiber
spawn, and survive suspend/resume cycles together. They are the computation's
"scope structure" — the runtime context that determines how effects are handled.
Relationship with Env
ScopeEnv is embedded in Env.scope. The Env module provides accessor
functions that delegate into scope so callers don't need to reach through
the nesting to read or mutate scope fields directly.
Summary
Functions
Remove a handler for an effect signature
Get the handler for an effect signature, or nil
Get the current leave-scope handler (returns identity if nil)
Get the current transform-suspend handler (returns identity if nil)
Get all installed handler signatures
Create a fresh scope env with identity leave_scope and transform_suspend
Install a handler for an effect signature
Install a new leave-scope handler
Install a new transform-suspend handler
Types
@type t() :: %Skuld.Comp.ScopeEnv{ evidence: %{required(Skuld.Comp.Types.sig()) => Skuld.Comp.Types.handler()}, leave_scope: Skuld.Comp.Types.leave_scope() | nil, transform_suspend: Skuld.Comp.Types.transform_suspend() | nil }
Functions
@spec delete_handler(t(), Skuld.Comp.Types.sig()) :: t()
Remove a handler for an effect signature
@spec get_handler(t(), Skuld.Comp.Types.sig()) :: Skuld.Comp.Types.handler() | nil
Get the handler for an effect signature, or nil
@spec get_leave_scope(t()) :: Skuld.Comp.Types.leave_scope()
Get the current leave-scope handler (returns identity if nil)
@spec get_transform_suspend(t()) :: Skuld.Comp.Types.transform_suspend()
Get the current transform-suspend handler (returns identity if nil)
@spec handler_sigs(t()) :: [Skuld.Comp.Types.sig()]
Get all installed handler signatures
@spec new() :: t()
Create a fresh scope env with identity leave_scope and transform_suspend
@spec put_handler(t(), Skuld.Comp.Types.sig(), Skuld.Comp.Types.handler()) :: t()
Install a handler for an effect signature
@spec with_leave_scope(t(), Skuld.Comp.Types.leave_scope()) :: t()
Install a new leave-scope handler
@spec with_transform_suspend(t(), Skuld.Comp.Types.transform_suspend()) :: t()
Install a new transform-suspend handler