Skuld.Comp.Env (skuld v0.1.26)
View SourceEnvironment construction and manipulation.
The Env struct carries evidence (handlers), state, and the leave-scope chain.
It supports extension fields - arbitrary atom keys can be added via Map.put/3.
Summary
Types
The environment struct. Supports extension fields beyond the core struct keys
(structs are maps, so Map.put(env, :custom_key, value) works).
Functions
Remove a handler for an effect signature
Get handler for an effect signature (returns nil if missing)
Get handler for an effect signature (raises if missing)
Get the current leave-scope handler (returns identity if nil)
Get state for an effect
Get the current transform-suspend handler (returns identity if nil)
Create a fresh environment with identity leave-scope and transform-suspend
Update state for an effect
Install a handler for an effect signature
Install a new leave-scope handler
Install a new transform-suspend handler
Types
@type t() :: %Skuld.Comp.Env{ evidence: %{required(Skuld.Comp.Types.sig()) => Skuld.Comp.Types.handler()}, leave_scope: Skuld.Comp.Types.leave_scope() | nil, state: %{required(term()) => term()}, transform_suspend: Skuld.Comp.Types.transform_suspend() | nil }
The environment struct. Supports extension fields beyond the core struct keys
(structs are maps, so Map.put(env, :custom_key, value) works).
Functions
@spec delete_handler(Skuld.Comp.Types.env(), Skuld.Comp.Types.sig()) :: Skuld.Comp.Types.env()
Remove a handler for an effect signature
@spec get_handler(Skuld.Comp.Types.env(), Skuld.Comp.Types.sig()) :: Skuld.Comp.Types.handler() | nil
Get handler for an effect signature (returns nil if missing)
@spec get_handler!(Skuld.Comp.Types.env(), Skuld.Comp.Types.sig()) :: Skuld.Comp.Types.handler()
Get handler for an effect signature (raises if missing)
@spec get_leave_scope(Skuld.Comp.Types.env()) :: Skuld.Comp.Types.leave_scope()
Get the current leave-scope handler (returns identity if nil)
@spec get_state(Skuld.Comp.Types.env(), term(), term()) :: term()
Get state for an effect
@spec get_transform_suspend(t()) :: Skuld.Comp.Types.transform_suspend()
Get the current transform-suspend handler (returns identity if nil)
@spec new() :: Skuld.Comp.Types.env()
Create a fresh environment with identity leave-scope and transform-suspend
@spec put_state(Skuld.Comp.Types.env(), term(), term()) :: Skuld.Comp.Types.env()
Update state for an effect
@spec with_handler( Skuld.Comp.Types.env(), Skuld.Comp.Types.sig(), Skuld.Comp.Types.handler() ) :: Skuld.Comp.Types.env()
Install a handler for an effect signature
@spec with_leave_scope(Skuld.Comp.Types.env(), Skuld.Comp.Types.leave_scope()) :: Skuld.Comp.Types.env()
Install a new leave-scope handler
@spec with_transform_suspend(t(), Skuld.Comp.Types.transform_suspend()) :: t()
Install a new transform-suspend handler