haskell and xmonad

I came back from Thanksgiving in California to find my copy of Real World Haskell had arrived. I've spent the last several days making my way through it up through chapter 10.

I'd read a few of the first chapters last year when I was struggling to learn Haskell, and posted enough comments that I'm amoung the (many many) people credited in the Preface. Amusing, since I still don't consider myself proficient in the language.

Reading back through those and on through Chapter Nine has swapped back in the basics I learned last year, and built on them. I was able to get all the way to Chapter Ten before hitting real brain-melting stumbling blocks. That's progess!

I can't help but feel that Chapter Ten should come later, perhaps after monads are covered. Only other quibbles so far are some typographical problems introduced in typesetting the book, and a few bugs and problems that were pointed out in comments on the web site, but not fixed in time for the first edition.


Anyway, I know more than enough Haskell now to configure xmonad. While I'm still perfectly happy with awesome, xmonad has some cool things going for it. Playing with it this evening, I especially like:

  • Being able to compile my xmonad.hs and rely on Haskell's type checking to make sure I wrote it correctly and it will work.
  • Xmonad's integration with gnome. This was a nice suprise, and being able to just use the gnome panel in xmonad, rather than building my own panel, has made it a lot easier to get started with.
    gnome panel showing xmonad workspaces
  • The power and beauty of xmonad's layouts. Start with the usual simple sorts of layouts like tiled, full screen and floating. These can be transformed in a myrid of ways (ie, rotated, decorations added), and can even be combined together to create more complex layouts. So I was quite easily able to configure it to alternate between a tabbed desktop layout that plays nicely with panels, and absolute unadorned full-screen mode:
    myLayout = desktop ||| noBorders Full
      where
        desktop = tabbed $ ewmhDesktopsLayout $ avoidStruts $ twoPane
        tabbed = addTabsAlways shrinkText myTheme
        twoPane = Tall 1 2/3 3/100
    
    (And it wasn't too hard to enhance this with a special-purpose grid layout for the workspace I run pidgin on.)
  • That my xmonad.hs is small, easy to understand, and doesn't contain any boilerplate beyond main = xmonad $ gnomeConfig.
  • It lets me muck about with doing something real with Haskell without having to commit to using it in some project of my own.
  • It supports cycling all windows on screen so that each in turn moves into the main viewport, via XMonad.Actions.RotSlaves.rotAllUp. An action that has been on my window manager wish-list for ages. Implemented in an easy 3 lines of code.

My current set of gripes with xmonad is small:

  • mod-shift-space is documented somewhere, but not where you need it.
  • I applied addTabsAlways to a Tall layout, and got title-bar like "tabs". But how do I add multiple windows as tabs to a given frame, like in ion? Can't figure out how, or even if it's possible.
  • Moving the mouse cursor over one of the above title-bar-like things doesn't focus its window. Very annoying!
  • Mouse support is very lacking. I'd like to be able to drag tabs around the screen, and maybe drag a border between frames to resize, couldn't find modules implementing any of that.
  • Theme configuration is only partly factored out, some of it is scattered in several different places.
  • Reloading the config file takes ages. 1.9 mb executable has to be built and run.
  • The lack of a dynamic language shows; there's no way to open a prompt and type Haskell into the window manager. I rarely speak lua to awesome or ion3, but it's nice to have the ability there. I think it should be possible to do this with Haskell (see ghci).
Posted
mpd proxy

An idea I've had for a while is to write a proxy for MPD. I have mpd servers scattered around, and lots of clients I use on my laptop, and it was getting annoying to manually point each client at whatever server I was listening to at the time. The proxy would get in between the client and servers, and redirect all the clients to whatever server I told it to use.

One interesting question is whether the MPD protocol can deal with a client suddenly speaking to a different server with a different state. The protocol is mostly stateless, but the proxy would need to send the password each time it changed to a different server. There could also be trouble if clients cached info about the database, etc, as they wouldn't see the new info from the new server.

I bailed and took a quick and dirty workaround to that problem. My mpd proxy disconnect all clients when changing to a new host. Clients then reconnect, re-sending passwords, and clearing any caches.

So the implementation is not all it could be (and is not ready to be added to mpdtoys yet), but here it is: mpdproxy

Needs simpleproxy installed to work, set MPD_PORT=6601 to make clients use it, and to change the server it connects to, just echo foo >~/.mpdhost.

I'm pretty happy with the result -- now I can use mpc and mpdtoys like mpstore without worrying about specifying a host, and sonata lets me know what's playing everywhere.


On to pondering better things, like discovering nearby mpd servers automatically with mdns..

Posted
wherein I read too much
  1. Dishwasher, by Pete Jordan
  2. Windfalls, by Jean Hegland
  3. River of Gods, by Ian McDonald
  4. Powers, by Le Guin
  5. Real World Haskell, by O'Sullivan, Goerzen, Stewart
  6. Matter, by Iain M. Banks
  7. Ars Magica, by Tweet & Rein Hagen

Nice set of books. Pity I'm in the middle of all of them.

Lately I have a hard time finishing many novels, I think because waiting for the plot to play out gets boring. Although River of Gods has mostly just confused me with too many viewpoint characters. And by this, where each box is a chapter, and that big box I'm just at the start of scares me:

Dishwasher is fun light reading. If I'd thought to bring it to its owner, Jay, who misplaced it, I could have picked it up from where I left off months ago and read it on the plane. Double oops. Oh well, there's always my next doctor or dentist appointment.

Powers is a probably great book by Le Guin. I hope there are many more to come, but the tendancy is to savor what's available. Also, I have it in dead tree edition, which I tend to save up for when I need them.

Windfalls is such a dead tree book, hibernating in the yurt for me to get back to them some day. I may have to start it over, since it's pretty involved, and rather out of my usual comfort zone.

Real World Haskell is coming along well, I hope.

Matter hasn't pulled me in yet, oddly.

Ars Magica I've been flipping through the PDF of idly.


Anyway, after all that, turning up a random story generator in 1 kilobyte of code couldn't help but feel like a relief.

discussion

Posted
road trip
Blessing, VA
Rt 666 Hogback Rd

I'm in Charlottesville for a few days. Got to visit the always atmospheric Crozet Pizza, and am enjoying a cabin at Misty Mtn.

Had a good long think on the drive up, but it doesn't want to come out as a blog right now.

Posted
Dell Mini 9

Well, I got the Dell Mini 9. Tiny little toy-looking laptop. It's too soon to tell if I'll like it. Or if my goal of using this as my only laptop, and primary work machine will succeed. But what a lot of firsts and changes!

My first laptop with no moving parts. Yay!

My first completely silent laptop. Double yay!

First laptop I've bought with linux preloaded. The default Ubuntu load was ok. It also contains my name 886 times. :-) Scarily, it also runs bits of code I wrote for base-config.

Installing Debian went ok, mostly, though wireless is a bit of a pain, and I have a strange problem with something fiddling with LCD brightness periodically. Oh, and SHDC cards make it crash on boot and resume. I've set up a page with the details, including how to fix the missing punctuation keys.

I've switched to using white on black for my terminals, and run them full screen rather than tiled. Cause the screen is small, and doesn't handle large black expanses as well as I've been spoiled to expect by machines that cost three times as much.

I like that netbooks encourage minimalism.

Posted
trim

Dell chose to ship Linux on the Mini 9, and so they were not required to plaster Windows stickers all over the case.

They made up for this sticker deficit with a useless sticker that reads just "Inspiron M series" (or something approximating that). My mind boggles at the decision process behind that.

Removing this sticker, I scratched the case of my new laptop. I also spent about 20 minutes scrubbing off the evil glue they used, which spread everywhere.


I had hoped the white power LED on this laptop would be less eye-searingly painful than the blue leds that were trendy before.

It is, but it's also right on the front of the laptop, which is often in a direct line of site to the screen. In any dim enviroment, the LED is still brighter than the screen.

I fixed this by applying some electrician's sticky tape to the case. Obviously, I can't win.

Posted
two parties and a story

Happy solstice! High point of the season for me, and today was a two party day. My sister has reached the point where a good b-day present for her is merging the blog style comments branch into ikiwiki and installing linux on yet another laptop. So we had a little installation party with cake and Carcassonne. Except for wireless it was a success. Since I outsourced the other present to the UK, perhaps someone can sort out Christmas by telling me how to get Intel 5100 wireless working in Debian? ;-)

At the solstice party tonight, all three of the recent inhabitants of the bottom of Wortroot washed up on the porch, each of us looking a bit scraggly (especially the current resident). Jeremy told this story:

His friend decided to drive his SUV down the driveway to the farm, without consulting with him first. (This driveway was blasted out of the hillside by amateurs, using dynamite, in an earlier era of life at the farm. It has been basically unmaintained since, progressively more eroded and rutted, and over the last 20 years only the Yellow Truck (with no brakes) has had free reign over it.)

He got down the hill ok, and he passed the small field, and then he got to the narrow place. (Where the creek is eroding the driveway away faster than we can cut into the hill to widen it.) And Jeremey told him to stop, but he kept on going.. sliding right off the driveway, and rolling the SUV into the creek.

(The creek here is, now that I think of it, exactly as wide as your average SUV is tall, and in a gully exactly as deep as your average SUV is wide. It must have fit perfectly.)

They tried winching it out. That didn't work. They didn't even think to ask neighbor Jimmie to once again haul a vehicle up the driveway. His tractor couldn't have gotten this one out. They had to rent a "small backhoe on treads, like a tank" to do the job.

Ok, maybe you have to have lived there to appreciate this. :-)

Posted
personal wishlists 40319, 32

40319

An e-book reader where I can click on any word and enter a definition for it. The definition will then appear as a tooltip when I hover over the word.

Take that, Iain Banks, and Neal Stephenson!

32

I want Deskview X's terminal program. The one that resizes the font when the window is resized. Except free and modern.

With modern (ie, auto-layout tiling) window managers, this is less of a wishlist and more of a missing necessity. Ideally, it would always keep the window 80 columns (or some other user-defined value) wide.

I've poked around in gnome-terminal's source, and this looks fairly doable, but I have not found the time to get down and do it.

Posted
Southern borscht

I was asked for my borscht recipe. This is loosely derived from a recipe that is really weird -- it says to throw away the beets! Both that recipe and mine are probably very unauthentic. But good.

6 cups water
3 medium size beets
2 medium size potatoes, quartered
1/2 cup chopped carrots
1 stalk celery, chopped -- optional
1/2 a bell pepper, chopped (red or green) -- optional
1/3 cup butter
1/2 to 1 cup chopped onion
1/2 cup tomatoes (fresh are best, canned or tomato paste + water is ok)
1/4 cup milk
2 cups finely chopped cabbage
1 tablespoon vinegar
1 teaspoon dried dill weed
sour cream

Put water in a large pot on high heat. Add beets, potatoes, carrots, celery, and bell pepper. Cover and boil until potatoes are tender.

Meanwhile, melt butter in a skillet. Saute onion in butter until tender, about 5 minutes. Stir in tomatoes, reduce heat to medium low, cover, and simmer for 15 minutes.

Remove half of sauce from skillet into a medium size bowl. Add cabbage to remainder of sauce in skillet and cook covered on medium low heat, stirring occasionally for ten minutes, or until tender.

Reduce heat on pot to a simmer. Remove beets from pot and set aside to cool.

Remove quartered potatoes and add to bowl with tomato sauce. Mash potatoes, adding milk, until creamy. Stir mashed potato mixture into soup in pot.

Grate beets, removing skin if desired, or grating it in. Combine grated beets and cabbage into pot. Add vinegar to taste (optional but recommended with sweet beets). Add salt and pepper to taste. Stir in a teaspoon of dill.

Cover and cook for at least another 5 minutes on low heat, then let it cook in its residual heat for as long as desired.

Serve hot, garnished with sour cream and dill.

Posted
the OpenID logo and free software

Suppose you have a free software package that includes an OpenID login form. Such forms are supposed to include a little OpenID logo . But as hard as you look, you can't find a license for the OpenID logo. Though there seem to be indications that it might get one in 2009, it seems like it will not be free enough to be included in a free software package.

Due to this problem, all the ikiwiki sites out there have not used the OpenID logo, or indeed any logo, in their login form for the 2+ years that ikiwiki has proudly supported OpenID. That was so suboptimal that I spent some donations to commision an unofficial OpenID logo openidlogin-bg.gif. It's freely licensed for use in whatever.

Putting the little OpenID logo in the login form is a nice touch, it helps spread awareness about OpenID and users learn to look for it. The fact that free software packages can't include it weakens that. Having an alternative logo that evokes the "real" logo and the concept of a login is better than no logo at all. But it is also needlessly confusing.

I encourage the new OpenID board to reconsider plans for logo licensing, and bear in mind that many free software packages can have native OpenID support, and should be able to include a copy of the logo, without worrying about it conflicting with their license, or not being free enough to be included in a free software distribution.

Posted