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

Pages: 1-

Haskell Monads

Name: Anonymous 2007-07-25 17:27 ID:DtTg9xo2

Hi, I'm learning Haskell, and I'm currently stuck on monads and monad (categorical) theory. Can someone write a paragraph of what exactly is a monad is haskell, in simple english? Or at least link to a good monad tutorial. Thank you.

Name: Anonymous 2007-07-25 17:43 ID:Heaven

(lisp ((((lambda y x lambda )))))))))))))))))))))))))()))))))))))))))))))))))))))))

Name: Anonymous 2007-07-25 18:10 ID:a//SyiSw

This is the article that finally caused monads to 'click' for me: http://sigfpe.blogspot.com/2006/08/you-could-have-invented-monads-and.html

I still couldn't write a paragraph in plain english on what they are, but I think I have a feel for them now.

Name: Anonymous 2007-07-25 19:04 ID:/kGBSc3M

Basically, it's some kind of type that somehow encapsulates another type (like the list or the maybe monads). It can contain "additional" data (i.e. state, like the IO monad, that contains the state of the world).

Using a special syntax (do) or operator (>>=), one can then apply functions on the contained value(s), such that the result is still encapsulated, and any state (possibly) preserved.

(>>=) :: (Monad m) => m a -> (a -> m b) -> m b

The type of (>>=) shows that, given a function (a -> M b), such as return, it can transform an M-monad value from type a to type b.

The do-syntax just makes it more pretty and less transparent.

Name: Anonymous 2007-07-25 19:16 ID:yMekHun8

Haskell is insane. All that fappery. When you need side effects, you have them. Shoving FP up your anus and making things complicated because of it is about as stupid as shoving OOP up your anus (as in Java). Right tool for the right job motherfuckers.

Name: Anonymous 2007-07-25 19:31 ID:I7LL+wCk

Monads = typed pipes. Think of doStuff >>= doMoreStuff as being basically the same sort of operation as cat foo | bar and you'll be happy.

Name: Anonymous 2007-07-25 21:11 ID:IcgSlIff

>>5
monads aren't only for side effects.

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