So can anybody tell me in a way one can understand it what a fucking monad does?
Name:
Anonymous2008-09-23 13:52
It's hides state because Haskellers are too afraid of side effects. It allows them to be hypocrites while they look the other way at what the language is really doing.
Name:
Anonymous2008-09-23 14:36
A nomad is like a package that hides something. You can stuff variables into it (HASKELL's way of assignment), you can open them, you can do something to the contents and repack.
I know my descriptions are (probably) non-enlightening but I intend to keep everything short; Google will help you find out more.
The only reason why monads have the appearance of complex wizardry is because it is a highly abstract concept and many descriptions use references to the math behind monads. If you're an experienced hacker that uses Haskell, you may have invented monads yourself. http://sigfpe.blogspot.com/2006/08/you-could-have-invented-monads-and.html
A monad is a kind of abstract data type (like a queue or a finite map) with two operations, bind and return, that are supposed to fulfill three mathematical properties. You will go a long way if you keep this in mind when thinking about monads.
Programmers often write code that can be described as "general computation blocks"; some data that has been processed is passed onto some more instructions that perform exactly the same process. Please don't confuse this (admittedly vague and useless) description with recursion or calling a function.
Monads allow programmers to describe "computational strategies" that will input data into the monad, perform the calculation which returns another monad. Writing code in this way allows the programmer to easily combine general computations in a purely functional manner. Another affect is that it allows programmers to "hide" a computation.
An example is a state monad which allows programmers to simulate 'imperative style variables' within a purely functional language.
Name:
Anonymous2008-09-23 20:16
Let's see if I got it right: monads are an ugly hack that's necessary mainly due to the stupid static type system, and also as a way to write (f (g (h (i x)))) as something like x → f → g → h → i?
No, it's because Haskell is a pure language without side-effects. There are non-pure languages with proper type systems.
Name:
Anonymous2008-09-23 20:27
Proper type system to me:
x.fuck()
Hello object referenced by x; lol, would you happen to have the word "fuck" in your dictionary by any chance? Cool, grab its reference. Hello object referenced by x.fuck; would you happen to be applicable? Awesome, now do it. (If any of this fails, raise DoNotWantException.)
Name:
Anonymous2008-09-23 20:30
without side-effects.
It's true…Haskell's stupid static type system prevents it from having any effect on the world whatsoever.
And you don't have to worry about fuck not being applicable or whatever because such a thing would raise an error at compile-time, you could even do the same for the fuck function by removing the third line.
Name:
Anonymous2008-09-23 20:40
>>16
Yes, but what if some other guy comes with a new class, Vagina, for which there's no implementation of x, yet the Penis one would work because Vagina objects can behave like Penises (yet they don't inherit from any common class or anything like that; maybe Vagina doesn't even know about Penis)? In a dictionary-based type system, the system couldn't give a fuck (no pun intended) about what you pass as long as it happens to have the dictionary keys you ask for.
>>18
No matter what, you'd still have to instruct the Vagina class to use Penis' implementation. A dictionary-based language is probably pretty dynamic and stuff, so you'd do it at object initialization time instead of compile-time as with Haskell.
Name:
Anonymous2008-09-23 21:02
>>20 No matter what, you'd still have to instruct the Vagina class to use Penis' implementation
Why? Penis could implement how to Move and Cum, so could Vagina, while being completely unrelated and inaccessible from each other. See example in FIOC:
class Penis (object):
def Fuck(self): #lol
return 'Oh'
class Vagina (object):
def Fuck(self):
return 'Ah'
Penis and Vagina could be defined in two completely unrelated files from two completely unrelated projects who happen to share a library that implements Stuff.
Name:
Anonymous2008-09-23 21:12
>>21 No matter what, you'd still have to instruct the Vagina class to use Penis' implementation Why?
If that's what you wanted to do, that is.
Penis and Vagina could be defined in two completely unrelated files from two completely unrelated projects who happen to share a library that implements Stuff.
Okay? Haskell could do that as well with typeclasses (oh man, I haven't used Haskell in months, excuse the made-up syntax):
[code]class Stuff x where
fuck x = raise NotImplementedException
data Penis deriving (Stuff)
instance Stuff Penis where
fuck x = "Oh"
data Vagina deriving (Stuff)
instance Stuff Penis where
fuck x = "Ah"
You never really went steady, but you'd run into her from time to
time while knocking around in disreputable joints, usually late at
night, every several months or so. She looked so hot, so sleek, so
sexy, so expressive, so exotic. You'd end up back at her place and
the night would just... take off. A complete blur of hot, sweaty,
feverish, delirious, fumbling passion. You'd do things to each
other... you'd do things to her, she'd do things to you... things
that you're not even sure have names, that you're pretty sure are
illegal almost anywhere. Even her kinks have kinks --- and after one
of these nights, you'd realize that you yourself had a lot more kinks
than you. And it wasn't just physical, it was --- cerebral.
Ethereal. Transcendent. But it would all whiz by in a blur, and by
morning you'd find yourself lightheaded, a bit confused, and
stumbling homeward to your regular gal.
Over the next few days and weeks you'd find yourself occasionally
drifting away, thinking about her. Haskell. You'd be there, banging
away at your regular girl, and find yourself thinking "you know, if I
was with Haskell, I'd be doing this completely differently." You'd
think "I could be doing so much bigger and better stuff with
Haskell." Now, your regular girl, she's not as exotic as Haskell.
Pretty, maybe, if you're lucky. (Perhaps your regular girlfriend's
name is Python. ;-) But not nearly as --- weird. Wild. Cool.
Exciting. Don't get me wrong --- your girl, she's wonderful. You've
got a wonderful relationship. She's --- comfortable. You can bang
away at her all day and night. She's accommodating. Easy going.
You work well together. But --- confidentially --- she's, well,
maybe just a little bit boring. You'd catch yourself thinking these
things, and the guilty pangs would get to you... You'd quash the
thoughts, buckle down, and get back to banging away. Comfortable...
there's a lot to be said for that, ya know? Comfortable... just
keep telling yourself that.
Months would go by. Late some night you'd find yourself out,
disreputable places again. Maybe that hacker bar, LtU. Somebody'd
slip you an URL for some renegade paper, you know, one of *those*
papers. You'd run into Haskell again. And the whole thing starts over.
Eventually, you're going to get the ultimatum. Haskell's ultimately
just like any other girl on some level; she needs commitment.
Eventually, after one night of wild, feverish, kinky, abstract
passion, she's going to say to you: "All these times, and you don't
understand me at all! You know, you're going to have to get serious,
mister! I've got needs, too. You're going to have to get serious
about my monads, or that's the last time you're going to play with
them! Got it?"
...and then, you've got to make The Choice.
Chances are, you're going to go back to your regular gal. Haskell's
just too much for any one man, probably. She leaves a trail of
broken, brainy, embittered PhDs and former programmers behind her.
She ruins you for the RealWorld. You can ride a while, but you
probably can't go the distance with her. Go back to your regular gal
and try not to think too much about what you've seen. Done. Felt.
Thought.
Maybe you can salvage a little happiness; but it'll be hard. After
all... you've tasted Haskell.
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
oh my god you are all idiots
Name:
Anonymous2008-09-24 9:44
>>26
whoever wrote that is a tragic shell of a man...
Name:
Anonymous2008-09-24 14:21
>>31
heh yeah, horrible how fucked up geeks can get
Name:
Anonymous2008-09-24 14:51
I came....
Name:
Anonymous2008-09-24 18:37
>>22
So can Java. But this means you have to define a class or interface with placeholder methods and properties beforehand, and that this class must be known to all three parts - the Penis, the Vagina, and the guy calling fuck. Python doesn't require this; the guy who writes Penis and the guy who calls fuck may not know each other besides the fact they can fuck, and may not know Vagina at all, because Vagina could be developed somewhere else, some other time, and it could just happen to be useful to replace a Penis in a future version of the fucker guy's program. Interfaces, called protocols in Python jargon, are just documentation of guidelines in order to make objects that feel alike.
All the manuals on haskell monads suck - including yaht. Some tell shit, some claim stuff which has nothing to do with monads and most of them are written with so much complex shittalk or can't get it to the point that they are completely unusable.
As long as they can't write a single proper tutorial about monads, im just gonna stay far away from haskell. Better: they should just scrape monads and replace it with something which doesn't sound like ancient voodoo magic.