Hacker News new | past | comments | ask | show | jobs | submit login

What's do notation?

I've used optionals in many languages, and this is the first I've heard of it. What else do you really need except map and... flatMap (aka `then` aka `and_then` aka `>>=` aka `bind`).




https://en.m.wikibooks.org/wiki/Haskell/do_notation

rough analogy: `await` replaces `.then()`, do-notation replaces `.flatMap()`


C# has had Nullable<T> for many years before it got stuff like ?. and ?? that mostly covers this, and it was, well, tolerable.


Ergonomics sucked and a lot of people didn't use them (or even know they existed!) because ergonomics sucked


From my work experience at the time, it was used pretty heavily in new codebases.


I mean the fact that they've been around since 2.0 but you saw it used heavily in new codebases says a lot doesn't it?


You misunderstood - I saw them in codebases that were new back when .NET 2.0 was new.

To be more precise, it was when .NET 3.5 was new (2008). That brought a lot of visibility to Nullable<T> because it was featured prominently in LINQ. But ?. didn't come until C# 6 (2014). I was wrong about ??, though - that one was added along with Nullable itself.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: