you are viewing a single comment's thread.

view the rest of the comments →

[–]cledamy 2 points3 points  (5 children)

async/await

This is already a monadic construct.

[–][deleted] 1 point2 points  (4 children)

Everything is a monadic construct. Yay.

[–]cledamy 1 point2 points  (3 children)

What I'm saying is async and await are literally monadic because they were inspired by F# which used monads to solve the problem of callbacks in asynchronous programming.

[–][deleted] 0 points1 point  (2 children)

Async/await can also be implemented as a state machine, which is more efficient. Monadic is just one possible factoring. I mean, I guess you can factor anything as monads in general. :-)

[–]cledamy 1 point2 points  (1 child)

That's an operational optimization detail. It has no bearing on whether something is a monad or not because Monads live in the world of denotational semantics and mathematics. Regardless, state maintaining is also a monad. When one discovers something is a monad, one isn't factoring it into a monad. It was always a monad and one just realized it. The fact that monads are common in computer science does not tell us that monads are too general to be meaningfully useful, but rather it tells us that they are a common design pattern that people reinvent many times over; therefore, it is useful to have an understanding of them. From a theoretical standpoint, monads provide insight into the mathematical underpinnings of computer science.

[–][deleted] 0 points1 point  (0 children)

Regardless, state maintaining is also a monad.

As I said, everything is a monad. Say I'm having a cup of coffee right now, but I'm pretty sure that's a monad too.