4 ms·
It is not. do notation is just syntactic sugar. The feature that enables re-use are the type-classes and the structure of the standard library. Interestingly, y
by choeger 6y ago
It is not. do notation is just syntactic sugar. The feature that enables re-use are the type-classes and the structure of the standard library. Interestingly, you do have traits in rust, but I think there is no monad trait yet in the std lib.
- steveklabnik 6y agoThere is not a monad trait because we do not have higher kinded types, which is a requirement. Beyond that, it's not clear that a monad trait would work, even if we did. It may, but it also may not. We'll see (or not) I guess.
- bad_user 6y agoWhy wouldn't a Monad trait work? You mean you couldn't express it in Rust, even with HKTs? Or you mean that it wouldn't be useful?
- steveklabnik 6y agoBoth. See here for more https://twitter.com/withoutboats/status/1027702538563477505 https://twitter.com/withoutboats/status/1027702538563477505 There have been some people working on these problems, take https://varkor.github.io/blog/2018/11/10/monadic-do-notation-in-rust-part-i.html https://varkor.github.io/blog/2018/11/10/monadic-do-notation... for example. This is why I say "not clear" and not "impossible" or something. We just don't know.
- deleted 6y ago[deleted]
- Quekid5 6y agoIt's basically a research-level problem given the other constraints of Rust. (Which is fine. Trade-offs and all that.)