Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ergonomics of effing_mad::run and composition of effect handlers #14

Open
teohhanhui opened this issue Mar 30, 2024 · 1 comment
Open

Comments

@teohhanhui
Copy link
Contributor

Currently:

fn main() {
    let console_handler = handler!(Console {
        print(s, _) => println!("{s}"),
    });
    let with_console = handle_group(do_command(), console_handler);
    let cli_options_handler = handler!(CliOptions {
        read() => options().run(),
    });
    let with_cli_options = handle_group(with_console, cli_options_handler);

    effing_mad::run(with_cli_options);
}

What if:

fn main() {
    let console_handler = handler!(Console {
        print(s, _) => println!("{s}"),
    });
    let cli_options_handler = handler!(CliOptions {
        read() => options().run(),
    });

    effing_mad::run!(
        do_command()
        |> handle_group(console_handler)
        |> handle_group(cli_options_handler)
    );
}

And mainly because naming is hard... There is nothing special about with_cli_options in the previous code other than it just happens to be the last in the chain?

@teohhanhui
Copy link
Contributor Author

Uhh, I guess it's just rust-lang/rfcs#2656

Which I was already following anyway...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant