Let's start with borrowing across yield points. We've solved this problem for real yield points with pin, I have no idea how to solve it using a function interface like >>=
-
-
Show this thread
-
So that means borrows across statements in do notation are just out of the picture. That's extremely limiting.
Show this thread -
Rust's imperative control flow statements like `return` and `break` inside of do notation also doesn't make sense, because we do not have TCP preserving closures.
Show this thread -
So we only know how to have do notation without early return or borrowing. People say this is an open research question, but IMO its just not possible within our runtime constraints.
Show this thread -
Getting beyond that, this is assuming that "future" implements "monad," so if we could just add HKT to have a Monad trait, everything would be hunkydory. That's not true!
Show this thread -
the signature of >>= is `m a -> (a -> m b) -> m b` the signature of Future::and_then is roughly `m a -> (a -> m b) -> AndThen (m a) b`
Show this thread -
That is, in order to reify the state machine of their control flow for optimization, both Future and Iterator return a new type from their >>= op, not "Self<U>"
Show this thread -
Also, our functions are not a `->` type constructor; they come in 3 different flavors, and many of our monads use different ones (FnOnce vs FnMut vs Fn).
Show this thread -
Okay, so Monad can't abstract over Future, but still let's have Monad. Problem: we don't have higher kinded polymorphism, and probably never will.
Show this thread -
The problem is that without currying at the type level, higher kinded polymorphism makes type inference trivially undecidable. We have no currying.
Show this thread -
In order to add higher kinded polymorphism, we'd have to restrict the sorts of types you could use in a way that would feel very arbitrary to users.
Show this thread -
In contrast, generic associated types don't have this problem, and directly solve the expressiveness problems we do have, like Iterable (abstracting over everything with a `.iter(&self)` method)
Show this thread -
(Don't get me wrong, you can write something to abstract over some monads like Option and Result using generic associated types. But its much less ergonomic than Monad in Haskell, even for those).
Show this thread -
IN CONCLUSION: a design that works in a pure FP which lazily evaluates and boxes everything by default doesn't necessarily work in an eager imperative language with no runtime.
Show this thread -
This comes up a lot, please link this thread liberally.
Show this thread
End of conversation
New conversation -
-
-
oh wait, this is programming, not gnosticism, okay, was confused for a little bit
-
i was too but now im stuck send help!
End of conversation
New conversation -
-
-
thank you so much for this

Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
An informative thread. Would be cool to know more about it and I don't think Twitter is OK for such explanations; would be nice if Rust had like official documents explaining such decisions at length that you could point to.
-
For example I might misunderstand the need for type currying. I know that types of multiple type parameters wouldn't work well with Monad, which has a single type parameter, but you can usually work around it (type aliases?) and most types have a single type parameter anyway.
-
Borrowing might be the deal breaker. I only started playing with Rust, so I don't understand how "bind" is incompatible with borrowing. I'm sure you're right, but it would be cool to see it in a longer form of communication.
-
Also, I'm sorry for your trouble, I'm not defending your critics, but programming languages have a history of ignorance, which makes such explanations desirable; see for example JavaScript's Promise:https://github.com/promises-aplus/promises-spec/issues/94 …
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.