Skip to main content

ShallowHandler

Struct ShallowHandler 

Source
pub struct ShallowHandler<A, B> {
    pub effect_name: String,
    pub val_clause: Box<dyn Fn(A) -> B>,
    pub op_clause: Box<dyn Fn(String, String, Box<dyn FnOnce(String) -> Free<A>>) -> B>,
}
Expand description

A shallow handler: handles only the first operation encountered.

Fields§

§effect_name: String

The effect this handler covers.

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

Return clause.

§op_clause: Box<dyn Fn(String, String, Box<dyn FnOnce(String) -> Free<A>>) -> B>

Operation clause: (op, arg, raw_continuation) → B.

Implementations§

Source§

impl<A, B> ShallowHandler<A, B>

Source

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

Create a new shallow handler.

Source

pub fn handle(self, comp: Free<A>) -> B

Apply the shallow handler to a computation.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<A, B> !UnwindSafe for ShallowHandler<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.