Chris Martin

Maybe death

Imagine we are programs running in a computer. Computerland operates under a strict rule; if you so much as utter a single sentence that is nonsensical or ambiguous, you will be killed.

For example, these expressions will result in your prompt termination:

  • "colorless green ideas"
  • "the fifth letter in the word 'soup'"

If we come across a friend holding a box, we might ask:

  • "What color is the object in the box?"

If the box contains one object, our friend may tell us its color. If the box is empty, however, or if it contains more than one object, then it's all over. We should therefore be sure to ask a preliminary question first to ascertain whether the second question is permitted:

  • "How many objects are in the box?"

If the answer is "one," then we know that "the object in the box" is well-defined, and we may ask our friend about its color.

This still seems risky. With my life at stake, I would prefer to not to be in the habit of using the expression "the object in the box" under any circumstance; it would be too easy to be careless and slip up if I didn't correctly keep track of what questions I had already asked. I'd rather combine the two questions into one:

  • "Does the box contain exactly one object x, and if so then what is the color of x?"

To which we may receive a reply such as:

  • "No"
  • "Yes, blue"

I write and make videos for Type Classes about Haskell and related topics. I am also working on a book, The Joy of Haskell.