logoalt Hacker News

joaohaaslast Tuesday at 10:50 PM2 repliesview on HN

It was not forgotten. Maybe/Either and 'do-notation' are literally what Rust does with Option/Result and '?', and that is mentioned a lot.

That said as mentioned in a lot of places, changing errors to be sum types is not the approach they're looking for, since it would create a split between APIs across the ecosystem.


Replies

dcowlast Tuesday at 11:39 PM

Where there’s a will there’s a way. Swift is almost universally compatible with objective-c and they are two entirely different languages no less. If an objective-c function has a trailing *error parameter, you can, in swift, call that function using try notation and catch and handle errors idiomatically. All it takes is for one pattern to be consistently expressible by another. Why can’t Result/Either types be api-compatible with functions that return tuples?

show 1 reply
Yoriclast Tuesday at 11:32 PM

Indeed, I can testify that `?` was very much designed with the do-notation in mind.