Archive for May 2011

Twitter Weekly Updates for 2011-05-29

  • Experiment still ongoing, 5 days. #mylitteexperiment #
  • Excellent workshop with Vanessa Menendez-Covelo this Saturday. She got me into positions I thought were beyond me. #ashtanga #yoga #
  • http://www.bbc.co.uk/programmes/b011lvb9 : All Watched Over by Machines of Loving Grace #
  • Building more stuff for [h4a], updating and adding cblrepo itself, as well as criterion. #h4a #haskell #archlinux #
  • Oh how I wish authors of #haskell libs would put examples in their Haddock docs. Right now it's criterion that's confusing me. :-( #
  • Seeing some strange stuff when using criterion. #haskell #performance #
  • Experiment over! It took my former employer a week to turn off my access to the SSH gateway into the internal network. #mylittleexperiment #
  • This is only the beginning of being a responsible parent who only has FLOSS systems in the house. #floss #parenting #
  • Sent a letter to the manager of the nursery urging them to use an open format for their weekly newsletter. :-) #openformat #

Twitter Weekly Updates for 2011-05-23

  • 2 days to go :-) #
  • I just got a lesson in nice Text.JSON usage. I guess I should stop looking to @donsbot for idiomatic #haskell ;-) #
  • Good morning! #
  • Cleaning out desk and computer at work. The scrubbing of one of the systems will run over night. #movetosweden #leavingjob #
  • One more day in this job :-) #movetosweden #leavingjob #
  • Off to my last day at work in the UK. First some #yoga though. #leavingjob #movingtosweden #
  • I'm just about to leave the office for the last time :-) #
  • I am now officially in between jobs. For about 2 months :-) #movingtosweden #
  • First day as funemployed (thanks @mcclurmc for the word) & I've accomplished all I wanted & a little bit more. Great start. #movingtosweden #
  • I'm running an experiment: 2 days. #
  • Lots of un/re-learning to do here: http://www.fieggen.com/shoelace/index.htm :-) #shoes #
  • Done for the day :) #movingtosweden #

Twitter Weekly Updates for 2011-05-15

Twitter Weekly Updates for 2011-05-09

Xmonad and Gnome 3

The upgrade to Gnome3 in ArchLinux a few days ago broke my previous setup that combined xmonad with Gnome. Gnome 3 has a fallback mode, but I found that the instructions for replacing metacity under Gnome 2 no longer worked. With some help from the xmonad mailing list (in particular Jens Petersen and his efforts of providing a working setup on Fedora) I now finally have a working setup again. Here’s how I did it.

Add a session file for use by Gnome Session (/usr/share/gnome-session/sessions/xmonad.session):

[GNOME Session]
Name=Xmonad session
RequiredComponents=gnome-panel;gnome-settings-daemon;
RequiredProviders=windowmanager;notifications;
DefaultProvider-windowmanager=xmonad
DefaultProvider-notifications=notification-daemon

And a desktop file for GDM (/usr/share/xsessions/xmonad-gnome-session.desktop):

[Desktop Entry]
Name=Xmonad GNOME
Comment=Tiling window manager
TryExec=/usr/bin/gnome-session
Exec=gnome-session --session=xmonad
Type=XSession

That’s all it takes. Of course I’ve raised a ticket against the Arch package.

Per-user Gnome 3 configuration

Gnome 3 just hit the official ArchLinux repos a few days ago. It’s new, it’s slick, it’s shiny… but I don’t think it’s ready for general use just yet. It seems stable enough, but there’s just a few too many things missing to make it feel like it’s complete. Anyway, running Arch means that at times one has to live with not-quite-release-ready software anyway :-)

The biggest issue I’ve come across with Gnome 3, and especially Gnome Shell and the window manager, is configuring the themes. I was pointed to a fairly good article on customising the Gnome Shell, but it suggests modifying system files which is a bad thing to do even on single-user systems. So this post should be read as an addendum to that one.

First of all install the User Theme Gnome Shell Extension. The AUR packages available pull the source from its git repo because there doesn’t seem to be any releases of the extensions just yet. When using the bleeding edge source I ran into problems with Gnome Shell crashing so I advise against using it. I’ve had success with the source tagged at 3.0.1, you can find an Arch source package for Gnome Shell User Theme that I put together based on one of the AUR packages. Build and install that, then restart Gnome Shell (Alt-F2, r, return). Then verify that the extension has been loaded by using Looking Glass.

Then create copies of the default themes using rsync:

% rsync -a /usr/share/themes/Adwaita ~/.themes
% mv ~/.themes/Adwaita ~/.themes/Adwaita2
% mkdir -p ~/.themes/Default/gnome-shell
% rsync -a /usr/share/gnome-shell/theme ~/.themes/Default/gnome-shell

Then modify the file ~/.themes/Adwaita2/index.theme so that each mention of Adwaita says Adwaita2 instead, except for the cursor theme.

Make sure gnome-tweak-tool is installed (it’s in a package with the same name). Run it and change the shell theme to Default,the windows theme to Adwaita2, and the interface gtk+ theme to Adwaita2 as well.

Now you return to the article on configuring Gnome Shell, but instead of modifying the system files modify the ones in your ~/.themes.

ArchHaskell HABS with cblrepo

As a follow-up to my earlier post on cblrepo I thought I’d convert a snapshot of ArchHaskell HABS to cblrepo. It’s mostly done as an exercise and to serve as an example. You can find it at http://www.kiwilight.com/~magnus/habs/.

Of course I have used it to build all the packages, and I still have the result of that around, so if anyone asks I just might upload that as well.

Twitter Weekly Updates for 2011-05-01

  • My Cabal-2-Arch conversion tool is just about ready to be unveiled. #haskell #archlinux #
  • Gnome3 is here.. it's new… it's shiny… it's cool… just to bad mutter isn't a good window manager :( #

Revisiting JSON in Haskell

I just received an email with some praise for my earlier post on JSON in Haskell–it’s always nice to receive some praise ;-) However, the sender also mentioned that the mLookup function as coded there would blow up on incomplete JSON objects. That was by design, as a simplification, but the sender needed to deal with just that and asked if I had some more elegant solution than making every field in the data type a Maybe.

As I said, it’s always nice to receive praise, so here’s one solution that came to mind as I was reading the email.

I should mention that it relies on there being a reasonable default value for each type of the fields, and that the default is the same for all fields sharing a type.

First off, define a type class for types with default values:

class Defaultable d where
    def :: d

Then modify mLookup so that it uses Defaultable. I renamed it to mLookupAndReadJSON:

mLookupAndReadJSON a as = maybe def readJSON (lookup a as)

Now we need to provide some instances of Defaultable too. I limit this example to cover only GlossDef, so only the following instances are required:

instance Defaultable [a] where
    def = []
 
instance Defaultable a => Defaultable (Result a) where
    def = Ok def

Now it’s possible to decode incomplete JSON objects:

ghci> decode "{ \"GlossSeeAlso\": [\"GML\", \"XML\"] }" :: Result GlossDef
Ok (GlossDef {glossDefPara = "", glossDefSeeAlso = ["GML","XML"]})

I’m sure there are other ways of achieving what the author of the email asked for. Please let me know of them in comments.