Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Monads

Name: Anonymous 2009-03-16 7:10

How are monads different than side effects?

Name: Anonymous 2009-03-17 21:28

>>50
What the fuck?  Monads specifically DON'T have return values representing the changed state; they keep any "state" inside their own guts.

That explanation has nothing to do with how monads are implemented, and only gives one limited example of a use of them, and does it incorrectly.  Either you are >>12, or you have no fucking clue what monads are intended to do (and the former implies the latter).

- Functional programming would generally take encapsulated state as a parameter and return new state data.
- Instead of passing State1 vs State2 around as you call these functions, monads invisibly remember the most recently modified state.
- This last used state is stored behind the monad's name... just like a mutable variable's name.
- You only have to worry about the other parameters & normal return values in your functions, and the syntactic sugar of monads handles the state passing for you.

If you understand pure functional programming, that's all there is.  If you don't, and wonder why the fuck people are passing "state" around, monads won't do you any good anyway.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List