It's usually difficult to focus on the tiny passions, but it seems that I have prematurely achieved a life of contentedness and abundant leisure and that I'll be able to hold onto it for some time. I have always been a computer enthusiast and probably should have succumbed to that current earlier in life, but, well, you know, causality and serendipity and all of that other bad spec fic shit; now I have my girls and a happiness that I wasn't even seeking. I also have this job where I sit in front of a pair of computer screens for hours on end and write in a language that I learned last summer (recently, more in a language that I learned last month) and I fucking love it. I get paid to play Lego for a few hours every day, it's just that the blocks are significantly more complex and completely intangible. It provides such an intense level of focus that it is almost meditative at times. I have immersed myself in it so much that it is actually somewhat difficult to type in this text area; I continually find myself wanting to go kk up a couple lines or hhhh back to the previous word to fix something or jj escape to command mode. Above all, however, the most useful tool in my budding career is the environment that I work in. I went a bit hardcore and chose to learn how to use an industrial strength window manager called XMonad, which is configured directly in Haskell source and recompiled (this, in itself is a challenge as Haskell is a somewhat obscure functional programming language, and as such is non-linear in nature and difficult to learn - even now, I don't know it very well). It has become my most cherished tiny passion. My xmonad.hs configuration file has become something like a bonzai tree to me over the last few years. Rare is the day that I don't tweak something. Some days, I will take the day off to wade through it while perusing the API docs, trimming here, refactoring there. In it, there are subtleties of code that I genuinely find beautiful even before the consideration of what functionality they provide.
This single line, for example:
doTrans i = ask >>= \w -> liftX (setOpacity w i) >> idHookThe elegant solution to a long-standing niggling problem that this line of code represents is powerful enough to actually carry emotional weight for me. This one line allows the window manager to set the opacity of a window based on whatever window property flag that I want. It makes windows transparent. Not the most powerful example from a pragmatic standpoint, but to automatically set the opacity of windows as they are created without the need of an external utility is unheard of (XMonad is a tiling window manager, so without transparency, there is no concept of 'wallpaper' because you would never be able to see it and even programmers need pleasing aesthetics). There are many other solutions and I toiled away trying to get them all to work with moderate success, but the issue remained effectively unresolved for quite some time before I worked out this solution.
Another common task in the configuration file of every single XMonad user is window attribute matching. The built-in boolean comparison operators are, logically, equal to (=?) and not equal to (=!). Exact match is inflexible, so I wrote these:
q ~? x = fmap (x `isInfixOf`) q -- includes? q !? x = fmap (not . isInfixOf x) q -- excludes? q ^? x = fmap (x `isPrefixOf`) q -- has head? q ?$ x = fmap (x `isSuffixOf`) q -- has tail?Native partial matching! It was a small revolution, but a powerful one. There are so many simple little efficiencies that I've worked in over time, and I am quietly proud of every single one of them. The file as a whole is something of a sacred treasure as it defines an environment that I have nurtured and improved for years. There are dated copies of it strewn throughout my various backup drives and file systems. There are obsolete versions of it that I dig through and pore over periodically to regain a bit functionality that I gave up in some underlying system changeover at some point. I don't get many opportunities to express the level of satisfaction that I get from working with code as I still refuse to have interactions with entities that I don't have a meatspace connection to, but I have the feeling that you guys will get it to some degree simply because you know what I was before I became enthralled with programming. Though, now, having written that out, I'm not sure what insights into my current affairs that would really afford you. Whatever. This is what I'm into now. Taye diggs.
I thought this might be helpful to visualize some of what the code does.

The title is an actual line from my client's code. I can't help but giggle every time I see it, though not because of the joke itself, but because of the image of the other guy on the project sitting at his computer giggling at it enough to have added the comment.
No comments:
Post a Comment