News for hackers. Stuff that matters.
Re:dotNET (OK, C#) gets union types by fwip on Saturday May 23, 2026 @07:15PM (#48252547)
What's wrong with Hindley-Milner?
Re:dotNET (OK, C#) gets union types by skybrian on Saturday May 23, 2026 @07:38PM (#48252710)
Leaving out types in public API's makes type errors hard to understand. Types should be declared in the API and bidirectional type inference used in the implementation.

https://jimmyhmiller.com/easiest-way-to-build-type-checker

Re:dotNET (OK, C#) gets union types by josephg on Saturday May 23, 2026 @08:07PM (#48252914)
Eh. This causes some problems for rust. Right now you can have a function return impl Trait instead of a concrete type. Very handy - and essentially required by async functions.

But the language also requires that types have names in lots of places. For example, you can't store an 'impl Trait' in a struct. You can't make a type alias of an impl Trait. And so on. As a result, async rust can only interact with a butchered subset of the language. (You can work around this with Box<dyn Future<...>> but performance suffers.)

There's a proposal[1] to fix this. But the proposal has been under discussion for (checks watch) 7 years now. Until this lands, async remains a second class citizen in rust.

This entire problem stems from rust's early decision to requiring concrete types at interface boundaries.

https://github.com/rust-lang/rust/issues/63063