Macro effing_mad::effects

source ·
effects!() { /* proc-macro */ }
Expand description

Define a new group of effects.

Usage

effects! {
    State<T> {
        fn get() -> T;
        fn put(v: T) -> ();
    }
}

Multiple new types are created: one for the group (State in this example) and one for each effect in the group. The group type has associated functions that look like the functions in the invocation.

This allows usage such as let state = yield State::get() and yield State::put(val). The type after -> defines the injection type of that effect, which is the type that such yield expressions will evaluate to.