News for hackers. Stuff that matters.
Re:Rust and the Blub Paradox by eximius on Saturday January 23, 2016 @11:32AM (#10958853)
"No, you don't have to learn monads."

Ha! This is ironic because a present discussion over some syntactic sugar (maybe more) to make Rust error handling feel more part of the language and more ergonamic may be ad-hoc monads. Not that the programmer needs to know that - it's just something that should happen to play nice in the rest of the Rust type ecosystem

Re:Rust and the Blub Paradox by M2Ys4U on Saturday January 23, 2016 @11:57AM (#10958957)
I was under the impression that `Option<T>` and `Result<T, E>` were monads.
Re:Rust and the Blub Paradox by saurik on Saturday January 23, 2016 @01:00PM (#10959227)
What makes monads in Haskell interesting is that someone identified them as a pattern, generalized their usage, and then syntax was added to the language that lets you compose them in a natural manner. Sequential execution itself "is a monad", but in most languages we express that using something as simple as ";" or "\n": Haskell effectively generalized the idea of statements to support anything that is monadic, which is why identifying something as a monad ends up becoming so interesting in Haskell as opposed to many other languages.
Re:Rust and the Blub Paradox by pcwalton on Saturday January 23, 2016 @01:46PM (#10959431)
And Haskell gave up rich control flow (break, continue, early return) by doing so. If you trace through what having those statements means for monads as a first-class concept, you find that the situation becomes very much not that simple.
Re:Rust and the Blub Paradox by ngrilly on Saturday January 23, 2016 @04:09PM (#10960100)
I've never heard this argument before. Very interesting.
Re:Rust and the Blub Paradox by mafribe on Saturday January 23, 2016 @12:04PM (#10958985)
MONSIEUR JOURDAIN: Oh, really? So when I say: "x := x+1" and "throw new Exception” is that monadic?

PHILOSOPHY MASTER: Most clearly.

MONSIEUR JOURDAIN: Well, what do you know about that! These forty years now I’ve been using monads in programming without knowing it!

    -------------------------------
With many apologies to Molière, many things are monadic including state and exceptions. Most programming languages introduce them as first-class core concepts rather than as monad instances. Hence you can use them innocently, without realising that they are monadic.
Re:Rust and the Blub Paradox by u320 on Saturday January 23, 2016 @12:38PM (#10959116)
Yes but the Rust type system cannot express monads, so they aren't monads in the type sense (they don't implement a specific Monad trait).
Re:Rust and the Blub Paradox by steveklabnik on Saturday January 23, 2016 @12:47PM (#10959153)
Fun Trivia Fact: Rust's type system was[1] Turing complete. So you could actually have monads. You just wouldn't want to.

1: The program that proved this no longer compiles, so we're not sure if the type system is or is not at the moment.

Re:Rust and the Blub Paradox by eximius on Saturday January 23, 2016 @10:02PM (#10961272)
I would love to see this program. Maybe even spend some time trying to get it to compile.
Re:Rust and the Blub Paradox by steveklabnik on Friday January 29, 2016 @06:16PM (#10999310)
Re:Rust and the Blub Paradox by Manishearth on Sunday January 24, 2016 @03:53AM (#10961978)
I think this is still possible with associated types. You can imitate higher kinded types with associated types, just that you wouldn't want to.

I recall someone posting a Monad or Collection HKT example when associated types were proposed.