Skip to main content

DeepHandler

Struct DeepHandler 

Source
pub struct DeepHandler<A, B> {
    pub effect_name: String,
    pub val_clause: Box<dyn Fn(A) -> B>,
    pub op_clauses: HashMap<String, Box<dyn Fn(String, Box<dyn Fn(String) -> B>) -> B>>,
}
Expand description

A deep effect handler for a specific effect.

A deep handler handles every operation of the effect recursively, re-interpreting the continuation in the handled context.

Fields§

§effect_name: String

The name of the handled effect.

§val_clause: Box<dyn Fn(A) -> B>

Return clause: val_clause(a) handles the final value.

§op_clauses: HashMap<String, Box<dyn Fn(String, Box<dyn Fn(String) -> B>) -> B>>

Operation clauses: map (op_name, arg, k) to B where k : String → B.

Implementations§

Source§

impl<A, B: 'static> DeepHandler<A, B>

Source

pub fn new( effect_name: impl Into<String>, val_clause: impl Fn(A) -> B + 'static, ) -> Self

Create a new deep handler.

Source

pub fn with_op( self, op_name: impl Into<String>, clause: impl Fn(String, Box<dyn Fn(String) -> B>) -> B + 'static, ) -> Self

Register an operation clause for operation op_name.

Auto Trait Implementations§

§

impl<A, B> Freeze for DeepHandler<A, B>

§

impl<A, B> !RefUnwindSafe for DeepHandler<A, B>

§

impl<A, B> !Send for DeepHandler<A, B>

§

impl<A, B> !Sync for DeepHandler<A, B>

§

impl<A, B> Unpin for DeepHandler<A, B>

§

impl<A, B> UnsafeUnpin for DeepHandler<A, B>

§

impl<A, B> !UnwindSafe for DeepHandler<A, B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.