pub struct EffectRuntime { /* private fields */ }Expand description
The Algebraic Effects runtime.
Construct with EffectRuntime::new(), register effect declarations
via register_effect, then execute a block of instructions via
run.
Implementations§
Source§impl EffectRuntime
impl EffectRuntime
pub fn new() -> Self
Sourcepub fn register_effect(&mut self, eff: IREffectDeclaration)
pub fn register_effect(&mut self, eff: IREffectDeclaration)
Register an effect declaration so perform sites can validate operation arity + parameter shapes at dispatch.
Sourcepub fn bind_global(&mut self, name: impl Into<String>, value: Value)
pub fn bind_global(&mut self, name: impl Into<String>, value: Value)
Bind a named value into the global environment (used to resolve symbolic arguments at perform sites).
Sourcepub fn enable_tracing(&mut self)
pub fn enable_tracing(&mut self)
Enable trace event recording. Off by default.
Sourcepub fn take_trace(&mut self) -> Vec<TraceEvent>
pub fn take_trace(&mut self) -> Vec<TraceEvent>
Drain the recorded trace, leaving the runtime tracing in a fresh state.
Sourcepub fn run(
&mut self,
block: &[Instruction],
) -> Result<ExecutionResult, EffectRuntimeError>
pub fn run( &mut self, block: &[Instruction], ) -> Result<ExecutionResult, EffectRuntimeError>
Run a block of instructions and produce a terminal
ExecutionResult.
Sourcepub fn lookup_operation(
&self,
effect: &str,
operation: &str,
) -> Option<&IREffectOperation>
pub fn lookup_operation( &self, effect: &str, operation: &str, ) -> Option<&IREffectOperation>
Look up an effect operation by name. Returns None if the
effect is not registered or the operation is not declared.
Sourcepub fn effects(&self) -> &HashMap<String, IREffectDeclaration>
pub fn effects(&self) -> &HashMap<String, IREffectDeclaration>
Read-only access to registered effects (test introspection).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EffectRuntime
impl RefUnwindSafe for EffectRuntime
impl Send for EffectRuntime
impl Sync for EffectRuntime
impl Unpin for EffectRuntime
impl UnsafeUnpin for EffectRuntime
impl UnwindSafe for EffectRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.