I know they're a way of wrapping up side effects in a "warm fuzzy thing" but I don't know how or why they work or in fact what they actually do.
I've looked at lots of references but haven't found a single good explanation. There's lots of info about how they apply to Haskell but it's all useless unless you can decode Haskell's esoteric syntax (which I haven't got round to learning yet). Most of the other tutorials are along the lines of "here's how we do it in Haskell, now this is how we implement it in some other language," which, again, is useless unless you know what they do in Haskell.
So can anyone help? This isn't for anything in particular, I'm just curious.
teamonkey wrote:So can anyone help? This isn't for anything in particular, I'm just curious.
I can't quite fathom it myself, but they appear to be some functional language gymnastics so you can change the value of something without mutating it (considered cheating) or passing it around (considered tedious).
i.e. they're fuck all use in the real world, since it's much easier to mutate, or just not use a functional language in the first place
Last edited by lis0r on Tue Oct 09, 2007 3:53 pm 0, edited 1 time in total.
If you really want to know, http://citeseer.ist.psu.edu/62964.html . Category theory is not genuinely difficult but... really warped... you have to look at it from the right angle. Sometimes I have "aha" moments where everything looks very plain and simple. Most of the time it just gives me headaches.
I couldn't visualise monad binding until I learned to crochet, then it was easy That and writing compilers (well, the parser parts, and maybe SSA optimisers which are currently doing my head in).
foxyloxy wrote:I couldn't visualise monad binding until I learned to crochet, then it was easy That and writing compilers (well, the parser parts, and maybe SSA optimisers which are currently doing my head in).
If only I'd read this last night. My wool-obsessed fiancee was trying to teach me to crochet and I was actively dissuading her.
GoatFoam wrote:The ruby one was no good to me as I can't get through that bloody ruby tutorial without wanting to put my fist through the screen. It IS NOT FUNNY.
Yep, I feel much the same; although it showed more or less how to set up a monad in Ruby it completely irritated me.
I can see how they work, but I'm still unsure what monads are actually good for, though. Maybe I'm being dumb, or maybe I should learn to crochet.
Simon
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
GoatFoam wrote:The ruby one was no good to me as I can't get through that bloody ruby tutorial without wanting to put my fist through the screen. It IS NOT FUNNY.
Yep, I feel much the same; although it showed more or less how to set up a monad in Ruby it completely irritated me.
I can see how they work, but I'm still unsure what monads are actually good for, though. Maybe I'm being dumb, or maybe I should learn to crochet.
Simon
I know some knitting, but that only helped me with Metaclasses.
Needlepoint is good for when you are just getting into closures and higher order functions, and quilting is great for continuations, co-routines and their ilk.
tufty wrote:I can see how they work, but I'm still unsure what monads are actually good for, though. Maybe I'm being dumb, or maybe I should learn to crochet.
In a purely functional language, you can't usually guarantee the order of evaluation, hence the order of side effects. If the order matters (e.g. I/O), you're screwed. Monads provide this guarantee.
One thing that I've been wondering about. Doesn't Haskell have closures? How is that compatible with being a pure functional programming language? Or does it only close over functions?