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.
-
Prikaži ovu nit
-
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.
4 proslijeđena tweeta 16 korisnika označava da im se sviđaPrikaži ovu nit -
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!
1 reply 6 proslijeđenih tweetova 18 korisnika označava da im se sviđaPrikaži ovu nit -
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`
3 proslijeđena tweeta 24 korisnika označavaju da im se sviđaPrikaži ovu nit -
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>"
3 proslijeđena tweeta 16 korisnika označava da im se sviđaPrikaži ovu nit -
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).
3 proslijeđena tweeta 23 korisnika označavaju da im se sviđaPrikaži ovu nit -
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.
1 reply 3 proslijeđena tweeta 20 korisnika označava da im se sviđaPrikaži ovu nit -
The problem is that without currying at the type level, higher kinded polymorphism makes type inference trivially undecidable. We have no currying.
4 proslijeđena tweeta 21 korisnik označava da mu se sviđaPrikaži ovu nit -
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.
1 reply 3 proslijeđena tweeta 15 korisnika označava da im se sviđaPrikaži ovu nit -
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)
1 reply 4 proslijeđena tweeta 24 korisnika označavaju da im se sviđaPrikaži ovu nit
(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).
-
-
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.
5 replies 19 proslijeđenih tweetova 111 korisnika označava da im se sviđaPrikaži ovu nit -
This comes up a lot, please link this thread liberally.
5 proslijeđenih tweetova 62 korisnika označavaju da im se sviđaPrikaži ovu nit
Kraj razgovora
Novi razgovor -
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.