News for hackers. Stuff that matters.
Re:Go vs. Swift [pdf] by comex on Wednesday January 18, 2017 @09:05PM (#13432351)
Rust copied 'if let' from Swift (~2 years ago) despite having decent pattern matching; community consensus today is that it's highly worthwhile as a feature. There have also been proposals to add 'guard let'. So, while I don't have enough Swift experience to judge its ADT support overall, I wouldn't cite those features as evidence that it's wanting. They might not be as natural in traditional FP languages like Haskell, but they seem to fit pretty well in the stylistic niche Rust and Swift (among other languages) have carved out.

edit: FWIW, there's some overlap between '?' and 'guard let', but not that much. Using hypothetical Rust syntax, they'd overlap in this case:

    guard let Some(x) = foo else {
        return Err(GettingFoo);
    }
better expressed as

    let x = foo.ok_or(GettingFoo)?;
…but if you want to return something other than a Result, or the ADT being matched on is something custom rather than Option/Result, there's no good way to make '?' do the job.
Re:Go vs. Swift [pdf] by tomjakubowski on Thursday January 19, 2017 @01:47AM (#13433667)
> Rust copied 'if let' from Swift (~2 years ago) despite having decent pattern matching; community consensus today is that it's highly worthwhile as a feature.

Rust copied 'if let' and made it far nicer and more capable by allowing arbitrary fallible pattern matches to be the condition. Then Swift 2 copied that improvement back with 'if case'.

Re:Go vs. Swift [pdf] by Ericson2314 on Wednesday January 18, 2017 @09:31PM (#13432471)
? is bind for Either monad if you squint.

`context(e?)` becomes `e >>= \x -> context(x)`

Re:Go vs. Swift [pdf] by majewsky on Thursday January 19, 2017 @09:50AM (#13436182)
You mean `e >>= context` ? ;)
Re:Go vs. Swift [pdf] by Ericson2314 on Thursday January 19, 2017 @06:16PM (#13440361)
Hah!

I should have been clear about CPSing things first so I didn't need to eta-expand :)