News for hackers. Stuff that matters.
Re:Haskell's Children by fnord123 on Wednesday September 23, 2020 @09:23AM (#24566730)
>Rust forces you to write stuff like Result::and_then and Result::map over and over again.

The feature of Haskell that lets you avoid writing 'and_then" over and over is do-notation.

Re:Haskell's Children by 59nadir on Wednesday September 23, 2020 @09:31AM (#24566830)
What everyone is talking about isn't "not having to write `and_then` over and over" but rather that there is a common interface to "things that are monads", i.e. `>>=`, `map` and `apply`. `do`-notation is nice syntactic sugar on top of that common interface, but it's not the actual thing itself.
Re:Haskell's Children by creata on Wednesday September 23, 2020 @09:58AM (#24567111)
I think you misunderstand. I mean that merely by implementing the Monad typeclass, you get a ton of methods (mapM_, join, etc.) for free. You can't do that in Rust right now.
Re:Haskell's Children by fnord123 on Thursday September 24, 2020 @06:59AM (#24577337)
I wonder if these could be written against the Carrier trait.
Re:Haskell's Children by choeger on Wednesday September 23, 2020 @09:33AM (#24566842)
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.
Re:Haskell's Children by steveklabnik on Wednesday September 23, 2020 @10:22AM (#24567393)
There 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.

Re:Haskell's Children by bad_user on Wednesday September 23, 2020 @01:01PM (#24569220)
Why 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?

Re:Haskell's Children by steveklabnik on Wednesday September 23, 2020 @01:09PM (#24569331)
Both. See here for more 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... for example. This is why I say "not clear" and not "impossible" or something. We just don't know.

Re:Haskell's Children by Quekid5 on Wednesday September 23, 2020 @07:07PM (#24573308)
It's basically a research-level problem given the other constraints of Rust. (Which is fine. Trade-offs and all that.)