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

> The transform is "transform the wrapped properties into some IO call", and all transforms are explicitly sequential.

Not every monad has to do with IO. The oddity of Haskell is that Haskell has this IO type and every real world action has to produce an IO value, but the defining characteristic of IO isn't that it's a monad.

Now, in the IO type, we use monads to sequence I/O operations, indeed (like "read something to the keyboard, then write this same something you read).

But there are other monads that do other things! Monads always enable you to write sequential-looking code (through do notation), sure, but they don't need to execute sequentially - and most of them has nothing to do with IO!

For example, the Cont monad enables writing code in continuation-passing style [0], and it's famously difficult to grok [1]. Suffice to say that it enables using the "call with current continuation" operator from Scheme (which doesn't work on IO, but works on Cont) [2]

[0] https://www.haskellforall.com/2012/12/the-continuation-monad...

[1] https://stackoverflow.com/questions/3322540/how-and-why-does...

[2] https://stackoverflow.com/questions/20451022/how-to-interpre...




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: