Archive for July, 2007

QOTD XIV

Monday, July 30th, 2007

From the outside, the type systems of languages like Haskell and ML tend to look like a sort of archaic ecstatic religious rite. The bleeding mendicants pause as they shuffle past, sing a verse in praise of the purifying pain of strong typing, then prod themselves with pointy sticks and progress along their lonely road.

Bryan O’Sullivan, commenting on his own quotation of Yaron Minsky. I’ve heard people complain about Haskell’s type system as being too strict, but once you figure out how to get things to type check, you can actually use it like a miniature theorem prover. Which is, essentially, what it is.

Oh yeah, and it’s my birthday today.

More from the list monad

Wednesday, July 18th, 2007
Prelude Control.Monad> let truthPermutations n = replicateM n [False,True]
Prelude Control.Monad> truthPermutations 3
[[False,False,False],[False,False,True],[False,True,False],[False,True,True],
[True,False,False],[True,False,True],[True,True,False],[True,True,True]]
Prelude Control.Monad> let satisfies p [x,y,z] = p x y == z
Prelude Control.Monad> filter (satisfies (==>)) $ truthPermutations 3
[[False,False,True],[False,True,True],[True,False,False],[True,True,True]]

Try expressing truth tables so succinctly and at such a high level in an imperative language. The list monad rocks.

Codata

Monday, July 16th, 2007

On Planet Haskell today, sigfpe posted a fairly readable (i.e., hopefully comprehensible to non-experts) essay about Data and Codata. I intend to do a talk on this topic someday, but in the meantime, you might find this enlightening.

QOTD XIII

Saturday, July 14th, 2007

The problem with defending the purity of the English language is that English is about as pure as a cribhouse whore. We don’t just borrow words; on occasion, English has pursued other languages down alleyways to beat them unconscious and rifle their pockets for new vocabulary.

James D. Nicoll on rec.arts.sf-lovers (from 1990; quoted at Language Log.)

Frustration

Tuesday, July 10th, 2007

My full results have finally turned up on the uni intranet. Highlights: 6 modules (70 credits) from level 3 and 4 modules (40 credits) from level 2 at >70%, weighted average 67.7%. Soooo close to a first :(

I think bad time management cost me the grade. I should have done some work towards the project and/or the report for a School of European Languages module over Easter, but was lazy and didn’t. Then a couple of weeks later I had deadlines for both on the same day; I chose to work on the dissertation (which was obviously more important as it’s worth 20 credits vs. half the mark for a 10 credit module), but if I’d picked the report, the mark wouldn’t have been capped at 40% and the weighted average would have been over 68%. Then a couple more percentage points on another module (most likely TPL, Software Lab, or German General Language III) would have got another 10 credits at >70%, which would have got me a first on the preponderance principle (within 2% of a classification boundary, if you have at least 120 credits above the boundary you get the higher classification).

STACK OVERFLOW!

Saturday, July 7th, 2007

You might have heard of the Garfield Randomizer. Turns out a similar thing exists for Dinosaur Comics.

I actually came across Dadasaurus Rex a couple of weeks ago. It lends itself very well to the treatment since not only is the panel layout the same in each strip, the art is the same as well. Here’s a rather excellent one I got:

Dadasaurus Rex suffers from sleep madness.

A fairly accurate depiction of what happens when you don’t get enough sleep, I think. :)

One-line definition of the power set function

Monday, July 2nd, 2007

If you thought the one-line definition of the Fibonacci sequence in Haskell was beautiful, try this:


import Control.Monad
powerset :: [a] -> [[a]]
powerset = filterM (const [True, False])

A black box for sure, unless you have “internalized the list monad“. But it does show how stonkingly powerful monads are.