Home
The Broken Hut
Working my way up to a full-size building
October 24th, 2006 

Optimus Prime may have been the greatest Transformer, but that’s not what I’m talking ‘bout here. I mean monadic transformers. And having spent some time reading about them and thinking about my next move in the Haskell programming… this is it.

What are monadic transformers? Well, most (let’s be fair: all) Haskell programs will make use of the IO monad to deal with the outside world. However there’s a number of other instances where monads can be useful — capturing errors, logging progress, maintaining internal state.

There exist separate monads in Standard Library for this stuff: Error and State, for example. But joining them together can be awkward even though many programs will have use for several of them at once.

One technique would be to build your own über-monad with all the bells and whistles you want. This would be both (a) daft, as the work is already done and (b) too error-prone.

The other technique is with monad transformers. They essentially provide an automated way to do monad nesting — such as IO (Either [String] [Bool]) — without all the tedious threading of monads. Kind of like a meta-monad, if you will, since you can sequence monads together in the way that monads allow you to sequence functions.

The other nice thing is that it cuts down on those horrible parentheses. Monad actions from different monads can be called back to back without causing a fuss. Example:

f = do a <- get                          -- from State monad
       liftIO $ print a                  -- from IO monad
       tell $ "found a " ++ show a       -- from Writer monad
       case a `mod` 2 of
           0 -> throwError "even number" -- from Error monad
           1 -> put $ a+2

I didn’t really understand them until I read the recent paper by Martin Grabmüller, Monad Transformers Step by Step. It’s still in draft at the moment but it’s very readable and dead useful.

That trip to Wales my dad was going on… didn’t happen. He left the house at some ridiculous hour in the morning — I’m guessing about four (probably why his tickets were so cheap, eh?) — but clean forgot to actually take the tickets, passport, bus pass, library card or any other form of identification, genuine or fake, which would let him get on the plane.

Remember kids; stupidity isn’t a birth right. You have to really work at getting these kind of things wrong (I sincerely hope).

I had a funny thought on the way home from work. And this is the place to air it, because it’s my blog dammit.

I was thinking about voting and how everyone has very different priorities, excepting some central points such as health or policing. I happen to think science education and free software are important issues (in very different ways) to a country. Other people are as adamant about recycling or fishing or nutrition information on packages of frozen pizza.

I was trying to think of a way where the important stuff would be really obvious, particularly at time of voting. What if you voted for your candidate and gave them a lasting reminder of why you thought they were the person for the job. Imagine using a tagging system to form a folksonomy of political issues. Each candidate’s tags could be published afterwards and mined for all sorts of potentially invaluable information.

  • Did all the people who listed ‘iraq’ (or whatever) as an important political issue for them actually all have the same taste in candidate? Or are there issues which are truly “cross-party”?
  • How do issues vary by geography? Can we correlate interest in, for example, farming or fishing with regions where these activities go on? Or maybe the interest is just as big in large cities where people are beholden to supermarkets for their ‘daily bread’?
  • What was the one thing that nearly everyone went to the polls thinking about? There’s bound to be something; I’m guessing that Iraq or global warming would be near the top at the moment. What will it be come election time?

I think this would be incredibly useful if implemented as simply as possible. There’s no more need to give your identity away than a normal secret ballot, after all. Everything is completely anonymous.

Of course, it really needs a computerised system to make it worthwhile… otherwise you have to deal with scrawled handwriting, the horror of data entry based on millions of (by the time they’ve been hand-counted several times) grubby and tattered slips of paper. And I’m generally against computerised voting at the moment.

But is there anywhere else — for votes on a smaller scale and that matter less — where such a system could be a natural extension of the elections? Something that comes to mind is the students’ associations at universities. I know Edinburgh University’s is done online and I bet others are too.

Am I very wrong, or did Horizon used to be good? Cos that program on artificial intelligence that just finished was really awful. It seems that one of the cameramen spent all his time filming a schoolgirl of far-eastern origin playing in the forest (this seemed to take up a substantial amount of the footage, so I presume it’s important) while the director of photography seemed to have limited the person filming the interviews to only one lens. A fish-eye lens.

This is the face of the modern documentary. In the name of the wee man…

Signing off,

Disgusted of Tunbridge Wells

Cell Phone Use May Be Bad For Your Sperm

Hmm, I don’t think my sperm even known how to use a mobile. Or maybe that’s why it’s called a ‘cell’ phone?

Thank you, I’ll be here all week. Please, tip your waitress.

This page was loaded Dec 19th 2009, 1:49 am GMT.