Hobby-hacking Eric


In preparation for my FOSDEM learn-about-conflictors mission, I am trying to catch up on patch theory stuff by reading this paper:

darcs get http://darcs.net/darcs-patch-theory
cd theory
make paper.ps

Now this is a fine example of literate haskell, where the literacy actually helps you understand what's going on, much more than it gets in the way of the code. Maybe it's also because some things are more suited to the literate way of programming than others, and this is one of them.

Oh yeah, dabbled with the ssh stuff. Think I had made more progress than I orginally thought; just hadn't noticed because I had not written the code to actually use the control master instead of just launching it, so of course, I was typing my password a gazillion times and not understanding why I couldn't connect. Silly me. Not done yet, but I'm a bit more optimistic now.


arrows as conveyor belts

I think I've finally found the visual key to understanding arrows. Where regular functions are boxes that accept input and produce output, arrows are the same thing with conveyor belts. I think this helps to visualise what the various operators are for. See this diagram, for example.

I've got diagrams for arr, first, second and ***. Still don't know really what I'm talking about though, so I'm a bit hestitant to put all this on wikibooks just yet.

Omnigraffle is a great tool. I'd love to see the free and open source software community do as well as Omnigroup.

Oh and darcs news: arjanb has charged me with a mission for FOSDEM: go to talk to the conflictors people until I understand it somewhat, and then write it down somewhere so that other people can understand it. I hope I'm up to this one! I think I'd like to make this part of a general project: writing a friendly Understanding Darcs booklet - combination of latex and hevea. I've already dreaming up diagrams to show the lifecycle of potential patches (changes) -> named patches -> exported patches, as well as the difference between the working directory and the pristine tree. What I figure is that patch theory and conflictors could be the "advanced" section of this booklet.

Argh. Too many hobbies. Saturation. What a great thing to be complaining about, though... I guess I should be thankful.


no darcs lately

Haven't had much of a chance to work on darcs lately. Some bits and pieces of work on the ssh control master stuff. I think I'm stuck somewhere on the code which launches the control master in the background and asks it every 3 seconds if it's ready yet. Or not, maybe that's fixed already. Geez, I can never remember what I'm doing anymore. Senility strikes in my mid 20s.

Been interested lately in learning what the heck arrows are, and working on the Haskell wikibook, so put the darcs down for a bit.

Flakey like that.



Ok, finally fixed the dateparser stuff and understood why it doesn't like those long years. It's nothing to do with haskell, just that System.Time calls some a function from time.h (mktime) to convert dates to number of seconds. Naturally, if the date is something like 105 years ago, then that translates to some really big negative number which is bigger than what you can represent in sizeof(time_h), depending of course on what time_h is defined as on your system. This should be blindingly obvious, of course, but i'm more a high level kind of guy. I hardly even know what a computer is. MaxInt? What the heck is that?

The annoying was trying to figure out how to catch the error gracefully. At first my catches weren't working, and I spent some time puzzling over that, trying to figure out what not. Then I realised that it wasn't the date matcher code itself that was throwing the exception, but the actual attempts to test the date ranges, long after the date has been parsed. So what ended up doing was testing the date range on the current date, just to see if throws an exception or not.
I had to do it in a slighly hacky way, though:

matcher `liftM` now >>=
\x -> if x then return matcher else return matcher
\e -> if e == "Time.toClockTime: invalid input"
then error "Can't handle dates that far back!"
else error e

One of the places where haskell laziness is annoying. Normally, i'd just say

matcher `liftM` now
return matcher
-- the rest of the code...

and be done with it, but since Haskell is lazy, it never bothers evaluating that, so I had to trick it by using this completely meaningless if.

In other news, on Thu night, I had written a pretty embarassing mail to the Unison list chiming in on Andres Loeh's idea for atomic directories. I basically tried to shed more light on why suc a feature would be useful and point out that it's more important for us darcs users that it be implemented quickly than with a "correct" user interface. Could have said it very simply, but I started going off in random sleep-deprivation-based directions, like saying that maybe if the unison people started to use darcs, they might like it so much that they would feel enough of a sympathy for us that we'd see an implementation the next morning. Ugh. 3-in-the-morning humour. It did elicit a response, however, pointing out places we in the Unison code we should look to in order to implement this. So I think maybe I'll try to get it done. I dunno. Might turn out to be the hard. Too bad unison doesn't have a nice regression testing system like darcs does (does it?). Anyway, so my first step here has been tailorise the unison subversion repo. This will make it easier for me to manage the patches I send in, and it might also be a useful way to show darcs off to the unison crowd. Shrug. Who knows?


unexpected burst of darcs hacking

Worked on two things tonight:

Tommy doesn't mind the silly code in the date parser, finds it rather cute and thinks we should really just be trapping the error and printing out an amusing error message. I'll go with it, but before doing that, I wanted to look deeper into what was making this break. Roughly, it's some kind of MAXINT overflow, but the question I had for myself was why it was overflowing in two different places on his machine vs. mine. Turns out that the library System.Time is buggy! Try this at home, normalizeTimeDiff $ noTimeDiff { tdYear = 1 } and you'll get some weird stuff. Igloo will submit a bug report and a patch to the Haskell folks. Yay!

Riadstradh asked me if I had gotten around to making a dmg for Tiger (like i said i would). Tickled to see either (a) people being nice and testing things out or (b) showing an interest in wxDarcs. The first binary I made didn't work. Turns out you also have to make sure to idtool change the libs required by the libs that you copy. So now my script for copying frameworks around loops around and tries to get all bases covered. Hope it works this time.


multiplexing over a single ssh connection

One of my friends at work today was complaining about darcs and the gazillion ssh connections it sometimes has to make, so I decided to take on zooko's feature request that we multiplex over a single ssh connection. It's not turning out to be very easy. One problem is that I need to work out how the business with launching the ssh control master is going to work. The thing has to be running in the background while darcs goes about it business. What I would like to be able to do is launch the thing, but wait until the connection has actually been established before returning. This way, the next time darcs wants to call ssh, it doesn't have to worry about the control master. Will have to think about this some more. In the worst case, we could just give friendly instructions on how to do this: I've already updated the FAQ on the wiki, suggesting that the user set DARCS_SSH='ssh -S the_control_file'.


no darcs lately

Have been taking a break from darcs hacking for a while.

Lately working on the Haskell wikibook, mostly importing my monads and space suits tutorial into the monads chapter as well as learning and writing about monad transformers. You'll note that the monad transforms text is a remix of Jeff Newburn's All about Monads tutorial with even more spoon feeding, because slow people like me need that kind of thing. Kudos to Jeff for granting us wikibookians permission to remix his text and to Paul J. for thinking to ask him about it.

This is greatly blurring the line between work and leisure. I'm learning about monad transformers because I need to use them for something at work, but I'm using a leisure-activity (building a wikibook) as a tool to help me learn.