DEV Community

Discussion on: What is Async Programming, and Why Should You Care?

 
mileswatson profile image
Miles Watson • Edited

The GetAllPages function returns a task, which can either be awaited (if called by an async function) or synchronously waited using .Result (if called by a synchronous function).

I’m not familiar with the term “monadic”, however I think you are correct that async generates some boilerplate code. You write it as if the code is a single function block, but behind the scenes it automatically generates exit and entry points before and after each await. So yes, I think it is similar to JavaScript’s .then() functionality.

Thread Thread
 
muttsuri profile image
Muttsuri

In a very naive term that will probably get me hunted by the FP Inquisition, I would risk saying that a monad is a "context box".
Examples are things like Thask where you chain tbem with await (or .then()) or sometimes you get to take the thing out of the box.
Another famous example is IO, since those operations can fail the result such a function gets wraped in IO so that it can just be called in the middle of any old function without basically forcing you to wrap the enclosing function in IO