News for hackers. Stuff that matters.
Re:Things about programming I learned with Go by leshow on Tuesday August 22, 2017 @12:23PM (#15073931)
You'd need generics and algebraic types to implement Result/Option
Re:Things about programming I learned with Go by curun1r on Tuesday August 22, 2017 @01:24PM (#15074516)
False. That feature allows a more efficient implementation, but (T, error) (or an equivalent struct) can be reasoned about in much the same way as Result<T>. You don't need a tagged union when you can use the nil-ness of one of the two values in the tuple as the tag. Similarly, Option<T> is just a wrapper around a nullable T.
Re:Things about programming I learned with Go by KirinDave on Tuesday August 22, 2017 @09:25PM (#15077798)
That would let people do this, and I hear people ask for it a lot. I dunno if it'd actually be better without the possiblity of not-wow-slow combinators.

Golang has all these weird performance pitfalls that you only hit if you contort the language too hard. Naming combinatior functions sometimes trips those conditions.

I'm of the opinion that even just pattern matching and the kind of nil type propagation checking that TypeScript does could help enourmously.

Generics won't fix error handling without compiler help, and the best way to get that help is to introduce pattern matching as a forcing function.

Re:Things about programming I learned with Go by leshow on Wednesday August 23, 2017 @08:16PM (#15086494)
The type you propose can inhabit both different variants at once, the entire point of Option is that it is either something or not.