2 ms·
Is Maybe/Option an effectful computation? Is List? I don't think it's really accurate to say this is what monads are "for". It's one use for monads but monads a
by mattnewport 4y ago
Is Maybe/Option an effectful computation? Is List? I don't think it's really accurate to say this is what monads are "for". It's one use for monads but monads aren't "for" anything and there are monads that are not about effects.
- chombier 4y ago> Is Maybe/Option an effectful computation Yes, Maybe/Options are a way of encoding partial functions/exceptions. List is a way of encoding non-determinism.
- codebje 4y 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.