What would be the benefit of a `Monad` type?

To offer my $0.02: in Rust, not much.

In pure functional languages, monads are pretty much needed for a handful of use cases for solving very concrete and practical problems. Like, performing I/O, getting through chained fields of types, having syntactic sugar for error handling, etc.

In Rust, which is not constrained by the "thou shalt never mutate anything" rule, these problems have more natural and convenient solutions. And while some of the types and APIs do benefit from a monad-like design and usage pattern, it's a lot less useful to abstract over general monads, because there's not much to generalize (or rather, it doesn't solve more problems than the other features of the language).

Some have facetiously argued in the past that "monads are a solution to a problem you shouldn't have". While I don't agree with such a strong statement, I can see where it's coming from.

6 Likes