Hacker News new | ask | show | jobs
by codebje 1469 days ago
"Effect" is perhaps a broader notion than one might think: it's an effect to write to a file or mutate some variable, sure, but it's also an effect to raise an exception, goto a label, raise an exception, execute asynchronously, be one of a set of possible outcomes, and plenty of other notions.

There's a name for the monad in which there is no effect: the identity monad.

The heart of a monad is the bind/flatMap/and_then interface, in which the value contained in the monad is computed on to produce a new monadic value. This is where the effect occurs: something other than just running the function happens.

If the bind implementation only runs the provided function then there's no effect, and it's the identity monad.