Advice from papa Harold

Posted by harold at December 19th, 2007

Since I’m on vacation (and I hope you are, too! Happy Holidays!), I decided to write a “normal” blog post. Here goes:

Cocaine flavored doughnuts seem to be quite popular in Palo Alto these days. Why? I don’t know. It might just be because we’ve unwittingly become the favorite retirement location of ’80s traders, who, after years of heart attacks, now want to slow down a bit and serve as venture capitalists. And by serve, I mean continue to ravage the markets for personal gain, all the while screwing up most of the time anyway. For those of you out in the real world, this should explain a lot. Alan Greenspan’s quite famous irrational exuberance wasn’t due to any sort of failure of the market after all. It’s actually about crackheads controlling the purse strings in this county.

And when crackheads prevail, sexist walnuts can’t be far behind. That, also, should make perfect sense, considering that silicon valley has an approximate 7:1 male to female ratio (not including stray canines, who seem to have no problem whatsoever replicating furiously). When you combine the California sun and surf with computer nerds and throngs of wannabes, the unfortunate consequences are far worse than those of liposuction. Put simply, the creative tech culture is imploding in on itself in a fury of 170-hour work weeks, only to be replaced by a bunch of sterile websites. Like that one social networking site for lobsters. Killer idea, guys!

Woe is the engineer who just wants to live the simple life today. What with traffic, rent and food prices through the roof, an overabundance of crackheads, and a distinct lack of culture, all that’s left to do is work. And that’s very sad because hacking around in one’s freetime is really where all the innovation starts. Maybe a little LSD if you’re from the east bay, but just as likely it’s about getting electrocuted one too many times and suddenly coming up with an idea for genetically engineered peanut butter. Or something. You probably didn’t notice, but I’m a little off my rocker today. Those recalcitrant hedgehogs are really gnawing at me.

But the point is, money does not compensate for living like a robot in a trash can. Take that advice wisely, youngfolk, as you go to work for the latest dot-bomb startup (version 2.0). You’re only young once, so you might as well take a shower now and then and maybe plant some geraniums in your yard before you get arthritis. That is, if you even have a yard. Trust me, gardening is far better than cocaine. If you’re really clever, you can even combine the two. But having friends helps. Walnuts, not so much. It’s all a matter of perspective. I prefer pine nuts, myself. They’re far more progressive.

So maybe California isn’t the best place in the universe. Me, I’ve found my own little home away from home volunteering in Sudan. But South Carolina is just as good—be careful not to exploit any migrant workers. They’re people too, you know. And unlike the ones in northern California, they don’t even get stock options. Just slow down and stomp on the daises. Fucking daises, I hate ‘em. Maybe something will happen. Maybe you’ll get a life. It’s important to do whatever, you know. Crawl around, find the life that suits you, and hope to hell that it doesn’t all go down the toilet one fine morning in February. Certainly beats getting fat on doughnuts, I guess.

Posted in Web 2.0| 6 Comments | 

Monads and Schroedinger’s cat

Posted by harold at December 2nd, 2007

It seems like everybody and his brother (unless his brother makes web 2.0 sites with rounded corners) is clamoring to use Haskell these days. Mostly because they think it’s 31337, but have no idea how it actually works. This eventually devolves into a discussion of trying to figure out what the heck monads are. Well, I have another explanation, folks. And it involves an analogy.

Think about Schroedinger’s cat in the box. You can’t directly interact with the cat, but if you wanted to feed it, you could put a mouse in the box. And if you wanted to pet it, you couldn’t stick your hand in (’cause you’d be getting information out), but you could make a petting device and stick that in the box.

Well, folks, a monad M is basically a box. Something of type M a is a box with something of type a inside. For example, you could have an M cat where the type cat can have values LiveCat or DeadCat—but from outside the box, you don’t know which it is.

If you want to transform the a to a b, you have to make sure that all the information about the original a thing remain in the box. The only way to do this is to put a function of type a -> b into the box, with the instructions to apply it to the thing inside the box. For example, you might have an M cat and want to apply a function adorn that puts a little hat on the cat, which would have type cat -> (hat, cat). But hold on there! Now you need some help to put that function into the box.

The monad operations, explained elsewhere, are simply syntax for this intuition. The “return” function puts something into a box. The “bind” operation (>>= in Haskell) takes something in a box, and a function, and puts the function into the box and applies it to the thing inside. In Haskell, the function is actually expected to return something already in a box, so we’d have to compose return with our cat-hatting function (return . adorn), making something of type cat -> M (hat, cat). The rest is details.

Posted in Programming| 6 Comments |