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-16 9:07

Guys, shut up. Just, shut up.

Monads are not particular to modeling side effects. They're basically for any situation where you need to shuffle data in and out of containers while not having to be explicit about how the wrapping and unwrapping is actually done.

This is a "stupid" explanation, but it's still better than talking about triples and categories.

Anyway, the only reason monads are used for side effects in Haskell is that you have a data type that represents "the part of the world that allows side effects." This is, of course, everything outside your program. Other data types usable as monads include lists, Maybe, and yes, State.

As for side effects only being allowed in IO functions: Haskell is not the first to do this. For example, Ada (it was popular with the military for years... you might have heard of it) has always separated "functions" from "procedures" and prohibited the former from having any side effects outside of the local variables of the function. This is basically mandatory in any safety-conscious language, apart from the ones that do shit like prohibiting dynamic allocation.

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