Archive for the ‘Uncategorized’ Category

Do-notation can be misleading

Wednesday, August 13th, 2014

Consider the following function:

oddness :: Maybe Int
oddness = do
  let a = Just 1 :: Maybe Int
  b <- a
  return b

Perfectly fine, albeit contrived, redundant, etc. Bear with me. Now consider what happens if we change the value of a:

oddness :: Maybe Int
oddness = do
  let a = Nothing :: Maybe Int
  b <- a
  return b

This looks odd, because it looks like we’re extracting the value from a into b, and then passing it to return – it looks like there’s some Int we extract from Nothing, and calling return converts it back to Nothing.

But of course, we know that this do-notation desugars to something like:

oddness :: Maybe Int
oddness =
  let a = Nothing :: Maybe Int
  in a >>= \b -> return b

And recall the definition of (>>=) for Maybe:

instance  Monad Maybe  where
    (Just x) >>= k      = k x
    Nothing  >>= _      = Nothing

So what’s happening here is that what’s on the right of (>>=) remains unevaluated, and Nothing is the result. Mystery solved.

How 6-year-olds think about evolution…

Saturday, December 8th, 2012

Had an interesting conversation with Henry tonight. Can’t quite remember how we started – he was asking something to do with the Ice Age, or the Stone Age. Then he asked, “How did the first person get here?” Now, he’s seen plenty of nature shows; he’s heard of evolution; so I decided to ask him some questions to make him think, viz:

“How did the first cat/dog/cow/etc get here?” (Hmmm… not sure.)
“Is a zebra a horse?” (Yes. A white horse with black stripes.)
“Is a donkey a horse?” (No.)
“But donkeys are quite like horses, aren’t they? Slightly different.” (Hmmm… maybe they are related. Like cousins?)
“Do you still think a zebra is a horse?” (Hmmm… maybe they are cousins too.)
“What’s an example of a small dog?” (A chihuahua.)
“What’s an example of a large dog?” (A golden retriever.)
“How do you know they are both dogs? They are very different.” (They just are dogs.)
“But they look really different, don’t they? More different than a zebra and a horse.” (Hmmm.)
“Is a lion related to a horse?” (No. Hmmm… well, they both run fast. And they both have fur. Maybe they are distant cousins.) [Interesting that he chose “running fast” to be a familial trait.]
“Is a person related to a horse?” (No. Yes? Yes. Oh! People evolved from apes, I saw it in a nature show.)
“Do you know what extinct means?” (Yes. It means something that isn’t alive any more. There aren’t any left.)
“What is an example of an extinct animal?” (A dinosaur. But dinosaurs aren’t really extinct because they evolved into birds!)

At this point the conversation degenerated into a game of dinosaurs evolving into birds and flying around the couch with a blanket streaming behind…

The 4th Amendment and Email

Tuesday, November 20th, 2012

Tonight there was an interesting broadcast of To The Point examining email privacy rights and the 4th amendment, with reference to the recent warrantless FBI investigation resulting in the resignation of David Petraeus as the director of the CIA. The program also featured Declan McCullagh, author of this piece on c|net.

The judicial system has long held that the government requires a warrant to open your mail. And in the 60s, it caught up to telephone technology when it ruled that wiretap warrants actually require a higher burden of proof than a regular “physical search” warrant, because they constitute an ongoing, secret eavesdropping. But the law has not yet caught up with email technology – the government can still peruse emails without a warrant.

This is obviously detrimental to privacy, and something all liberty-minded folks are against. And, it was claimed in the show, large technology companies (Google, Facebook et al) are in the camp that the government shouldn’t be allowed to mine email accounts without due process. But ISTM that it’s not that simple for the 3rd party companies. Because the very same legal interpretation that means that the government doesn’t require a warrant, protects them.

If emails are public records (as they are currently, so the argument for defence of warrantless email access goes), then 3rd parties have no particular responsibility to keep them private. (According to the discussion on To The Point, emails are protected at the instant they are travelling across the wire, but when stored they count as public.)

On the other hand, if emails are private, then the government can’t access them willy-nilly, but presumably that imposes extra responsibilities on the 3rd parties. Which may not be something that Google, Facebook et al want. Can they in good conscience make the argument that the government shouldn’t be allowed access, but they should be able to mine data for advertising or selling on? I think not.

Late night stealth

Thursday, July 26th, 2012

I would like to share with you some things I’ve learned about creeping around stealthily late at night, after the family have gone to bed, in case you find yourself in a similar situation. I’m pretty good at it now. So, obviously to avoid waking anyone up, you want to avoid making any noise, and also avoid any lights. Here’s my list of things to be aware of:

  • Night vision is given by a biochemical change inside the eye: in 5-10 minutes you’ll get pretty good night vision, and in half an hour more or less the maximum. But any exposure to light will very quickly reverse the change. So, if you need to turn on a light (eg the bathroom), just keep one eye tight shut to preserve its night vision.
  • Your peripheral vision is more light-sensitive than your central vision. This is because humans are optimised for daylight: the fovea has a high concentration of cones (sensitive in good lighting conditions) and a lower concentration of rods (sensitive to low light levels). You can see this in a dark room with a very dim light source – if you look directly at the light, it will disappear because the cones around your fovea can’t detect it. But you will see it clearly if you don’t look directly at it.
  • If you’re anything like me, your joints, especially knees and ankles, may crack when walking up and down stairs (and maybe at other times). I’ve found the best defence against this is to give my feet a quick roll around before embarking upon the stairs.
  • Know your house. This takes time to master, but if you are a habitual late-nighter, you’ll learn all the things that make noise. It is very important not to walk into anything, before you have your proper night vision! Kids’ rooms are among the most dangerous places in the dark. Even if you don’t step on a lego brick, you may still knock something that plays a tune or makes a loud noise.
  • Practically all staircases have creaky areas. To minimize creak, walk on the edge of the riser or towards the wall. The middle of the step is likely to creak the most.
  • Doors are most likely to creak at the ajar position, even if they are moved slowly. If you have a somewhat creaky door, moving it quickly is sometimes a good option to avoid the creak.
  • Soft noises of the white noise type are unlikely to wake people. Don’t be obsessed with being absolutely silent. The soft brushing of socks on carpet, or the quiet swish of a curtain closing are noises that shouldn’t wake anyone.
  • If you have to get into bed with a sleeping person, do your best to spread your weight and not to press the mattress down unevenly.
  • If you have to get undressed, do so in another room. Clothes can make quite a bit of noise, jeans and belts especially. Flannel pyjamas are almost silent.
  • Socks are better than bare feet. Bare feet are OK on carpet, but less so on hard floors.
  • Know a bit about phases of sleep. This will enable you to judge whether the sleepers are more or less likely to awaken. Note: phases of sleep progress differently in very young children.

The Second Amendment

Tuesday, July 24th, 2012

Why do people support the second amendment?

I’m going to try to avoid straw man arguments here. And the first straw man argument to avoid, I think, is: “because it protects us from tyranny: if the government becomes corrupt, we can rise up and overthrow it.” Perhaps I’m being naive, but do people really believe they could overthrow the US government through violent means? Perhaps they do; belief without evidence (or belief in the face of evidence to the contrary) is far from rare and even perceived as a virtue and called “faith”. The defence against tyranny argument is also appealing; it’s a fantasy people would like to believe, fuelled by the movie industry and no doubt the NRA. But can people really be fooled by it? I move on.

A second, slightly more nuanced argument which I’ve heard from some, hinges (I think) on the purpose of the Bill of Rights: to frame the (moral) context for the law, viz. “it’s important to preserve the right to rebel against a corrupt government.” This is a logical absurdity. If one is rising up against a corrupt government, one is undoubtedly breaking many laws. Overthrowing a corrupt government is (almost by definition) a choice of the moral over the legal. It doesn’t matter whether your right to overthrow a corrupt government is recognized by that government!

A third reason to support the second amendment, which I’m not going to bother arguing against, but I can’t help thinking is real for some (unfortunately) is the argument from authority. These amendments were written by the founders of the US. And the fact that it’s amendment #2 and not #22 lends it extra gravitas, I’m sure. But again, I’ll move on.

A fourth argument (and I’m afraid another straw man) is the old chestnut “if guns are outlawed, only outlaws will have guns.” This argument has always mystified me because, well, so what? This is already the case in many countries, all of which have substantially lower gun death rates than the US.

In the end, I think the only really understandable position to take is simply that of a gut feeling that this is enshrining an ancient, basic individual right, that extends from the right to life and protection of one’s person. According to Wikipedia, this is the position taken by the SCOTUS. and it is consistent with the purpose of the Bill of Rights, being not to define or grant rights, but to recognize and protect those rights which are accepted as being ancient, “natural” and fundamental to the human condition. This is why the language of the amendments is not, “people may do X” but rather, “the right of the people to do X shall not be infringed/violated.”

I don’t agree that people have a right to arms: one might as well say that people have a right to drive. To me, this would be at least as defensible here in LA: nevertheless we recognize that driving is a privilege and not a right. But even though I don’t agree with this last argument, it is at least understandable that people feel this way. I just hope that people are able to critically examine their beliefs about the second amendment and be honest about why they support it.

A musical interlude

Sunday, February 5th, 2012

I had piano lessons at around age 5, and again around age 10. I never practised enough or liked my teacher much. As a teenager at university, I went back to the piano to play tunes that I wanted to, and taught myself enough to get by on those. After university, nothing for a long time. But I wanted for a while to go back to piano, and so I’ve been studying since summer at the Redondo/Hermosa/Manhattan School of Dance and Music. I still don’t get enough time to practise, but I am learning a lot more music theory and really enjoying composing.

So here is the latest piece I composed: a minuet for violin and cello.

Merry Xmas

Sunday, December 25th, 2011

This year it was a fairly quiet affair, seeing as we’d already visited family in late summer and at Thanksgiving.

The kids did well as usual. Mini-Elbeno got a Kindle Fire from the grandparents (and has been bound not to buy anything on it without the express permission and help of Mrs Elbeno or myself). Micro-Elbeno is apparently going to grow up to be a typographer because he loves letters so much. He got various alphabetic gifts.

I got Mrs Elbeno a wooden watch made from maple and sandalwood. As for me, I got a few items from my always well-stocked Amazon wishlist:

It’s October

Wednesday, October 5th, 2011

And that means the 17th Annual Interactive Fiction Competition is underway. This year there are many entries playable on the web! What will they think of next, eh?

Also, Blizzcon approaches (a little more than 2 weeks away), another Humble Bundle is out (and as good as usual), and today it rained quite a lot here. Hope everyone’s enjoying the Diablo III beta; we’re still working hard.

More exciting news: a new bookshop opened nearby: Mysterious Galaxy. They specialize in SF, Horror, Fantasy and Mystery. I popped in there with mini-Elbeno on Saturday and picked up a copy of The Invention of Hugo Cabret for him to enjoy.

Diablo III Beta goes public

Tuesday, September 20th, 2011

After a few weeks of being friends and family only (and sorry to my games industry friends, but you weren’t allowed in either) it’s now open season for the Diablo III Beta test.

Birthday

Friday, June 3rd, 2011

Thanks everyone for the birthday wishes.

I got a few cool gifts: