docs.rs failed to build monadify-macros-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Procedural macro backing monadify's do-notation.
This crate exports a single procedural macro, [mdo], which is re-exported
by monadify under the non-default do-notation feature as monadify::mdo.
What it does
mdo! desugars an imperative monadic block — a sequence of let,
pat <- expr;, guard(expr);, and bare expr; statements followed by a
trailing final expression — into nested Marker::bind(..) calls over
monadify's Bind /
Applicative trait hierarchy.
The block names its Kind marker explicitly (marker inference is impossible
because the GAT Of<Arg> is not injective):
use monadify::{mdo, OptionKind, Applicative};
let r: Option<i32> = mdo! { OptionKind;
x <- Some(2);
y <- Some(3);
guard(x + y > 0);
OptionKind::pure(x + y) // raw monadic value, == Some(5)
};
A runnable version of this example lives on monadify::mdo (the gated
re-export), where it can depend on monadify without a build cycle.