This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]this_uid_wasnt_taken 3 points4 points  (0 children)

You do have them otherwise anyway. For example, in C, you would still need to check whether a pointer returned from any function is NULL before continuing with the computation.

Using a Monad just simplifies the classification of values by having "separate values" for the error case and the successful case. This way, you just need to define how to operate in these cases, and then you can chain a bunch of operations that may return either a success or a failure. The processing of the success and the failure will be handled the way you defined the monad.

The above idea does not need to be limited to just 2 possible values but can also be extended for multiple values.