4 ms·
Is there a solution yet in Rust to this problem of, monadic-ish constructs like Result and Option, but no nice way to chain them together without hideous nestin
by randommodnar 10y ago
Is there a solution yet in Rust to this problem of, monadic-ish constructs like Result and Option, but no nice way to chain them together without hideous nesting, like Haskell's "do" or Scala's "for"?
- steveklabnik 10y agoWe don't have HKT and therefore we can't have real do notation. The mdo crate provides a duck-typed macro. .and_then calls themselves aren't too bad, with the right whitespace.
- comex 10y agoIn the special case of Result, the new ? operator is going to subsume try! and offer more flexibility: https://github.com/rust-lang/rfcs/pull/243 https://github.com/rust-lang/rfcs/pull/243 (note that what was actually accepted differs from the text of the RFC, you need to scroll to the bottom) As steveklabnik says, there's nothing resembling generalized monadic do notation for now.