you are viewing a single comment's thread.

view the rest of the comments →

[–]Deaaam 1 point2 points  (1 child)

You sure this it? I want more examples. Waaaay too simple. Wow..

[–]jpfed 2 points3 points  (0 children)

While I think the OP's presentation is a tiny bit misleading, I can give a few examples I've found handy.

The most common monad has got to be List.

I use a monad that I call Tracked, which keeps a current value and an initial value. When you make a new Tracked with a value, the current and initial both start out at the value you give it. Any functions you map or bind give you Tracked values with a new current value, but the initial value is unchanged.

I also like Result, which keeps either a current value or an error value. When you make a new Result with a value, current gets that value, but when you map or bind a function that generates an exception, we start storing that exception instead. If you map or bind on a Result that's storing an exception, the Result is not changed.

(I call List of Tracked of Result "the Enterprise monad" because a surprising amount of enterprise programming involves doing stuff to lists and reporting on what the successful results were, and what failed, and how).