Ergonomics of `effing_mad::run` and composition of effect handlers
teohhanhui opened this issue · comments
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?
Uhh, I guess it's just rust-lang/rfcs#2656
Which I was already following anyway...