Yes, my thoughts exactly.
This problem is not solved by monads, but by higher kinded types in general in languages like Haskell. They give you a uniform way to be generic over effects like async (Async<A>
) vs sync (Identity<A>
). Both of these can be treated as (F<A>
) for all A
. So a generic Into
would look like the following, and no special syntax or semantics would be needed. The type system (if sound) would prevent you from misusing a trait like this.
trait Into<F,T> {
def into(self): F<T>;
}
Others have listed a bunch of good resources. If you are more of a visual learner, I have heard good things about the Easy Rust videos - https://www.youtube.com/watch?v=-lYeJeQ11OI&list=PLfllocyHVgsRwLkTAhG0E-2QxCf-ozBkk