Skip to content

Learning Haskell

Classes have finished for the year, and I finally have some time to get real work done! One of the whole host of things I got involved with this semester was working on designing a new programming language with my friend Alex Marquez.

One of the major hurdles for me is that a new type system is core to the language, and that type system uses all sorts of techniques that I’m unfamiliar with. Type inference, pure functional style, reification, currying, kinds (type of types) and many other things I now vaguely understand with from talking about the language with Alex, but there’s certainly a long way to go.

So I decided to rectify that by giving a shot at Haskell, that crazy, purely functional language with monads and all sorts of interesting things. I’m working through a collection of resources now, and thought I’d collect them here for others to start from.

  • The first is Real World Haskell (RWH), the O’Reilly book by Bryan O’Sullivan, John Goerzen, and Don Stewart.
  • Next is Learn You A Haskell (LYAH), the quirky tutorial by Slovenian Miran Lipovača.
  • I also found the Gentle Introduction to Haskell (GIH), by Paul Hudak, John Peterson, and Joseph Fasel to be useful as well.
  • And for a great search engine of Haskell types and documentation, check out Hoogle.

Of the three tutorials, RWH is the most gentle. It also features a wonderfully innovative comment system, where user comments can be made on a paragraph by paragraph basis. Several times I found that a comment had a particularly useful addition or alternate explanation, which greatly added to the straight text. Reading RWH+Comments feels akin to being at a conference while following the backroom chatter on Twitter during a presentation. You’re given both the presentation and the critique, interwoven in time.

But at times, RWH felt a bit too slow at getting to the interesting stuff. I wandered around a bit and found myself at LYAH, which is the site I started learning Haskell from several months ago. With quirky drawings and a good pace, I switched over to using LYAH as my primary Haskell tutorial.

And by browsing around online (imagine…) I came across GIH, the most academic of the three. GIH does an excellent job of formally defining functions and concepts as you move forward, but it’s quite heavy. I found myself glancing at other resources to actually understand what was going on, and in several cases I only understood a piece of code because I’d learned something from another tutorial. I’d say that GIH is better for a later tutorial once you get the big picture of Haskell and are looking for more details. GIH goes into more depth on language constructs and has extensive links to the official Haskell definition and the code implementing the Prelude (standard library).

And a great resource shared with me by friend David Hollis is the search engine Hoogle. I’ve ended up using Hoogle mostly as a reminder of what functions do, not just what their type signature is. And searching by a type signature is something I’ve never seen before. Very cool!

Best of luck in learning Haskell!

UROP Newsletter Posted

So of course the day after I write a post saying the profile I wrote will be ready within a week, it’s posted! I’m featured in the UROP Newsletter on page 8.

Undergraduate Researcher Profile

News on the research front! Besides pursuing an Amazon AWS research grant, I was selected to be featured in the GT UROP newsletter for my work on the Music Technology research as an undergraduate. The newsletter will be ready to go within a week or so, and I’ll be sure to look out for copies around campus and online.

In the meantime, I have typeset the profile in LaTeX (a favorite to work with, though quite the pain sometimes). Here is the Undergraduate Researcher Profile.

Amarok development on ArchLinux

I switched my play laptop over to Arch sometime last semester, and had a great time getting everything set up. It’s much more of a hands-on experience, and like everyone who writes up an account of an Ubuntu -> Arch transition, I feel like I have a much better idea how the boot process and wireless configuration work. Of course, nowhere near as much as setting up an LFS installation, but still…

After two years with Mac OS X on my primary laptop, I’m getting that itching again for going back to an open source community OS. Sure, suspend/hibernate is flawless on Macs, and Firefox is formidably fast, but iTunes is a poor replacement for my Amarok installation. There was an Amarok2 build for the Mac a while back that I beta tested, but it’s just not ready for primetime yet, and I haven’t heard much of any development work done for the Mac platform in months.

So with a weekend where I’m already busy (finals week — papers, projects, exams anyone?), I sat down and figured out ABS, found an amarok2-svn PKGSOURCE, and have started hacking away. A great first place for KDE projects to look for trivial things to fix is Krazy (down now for some reason). I looked at comparison to and concatenation with single-quoted characters instead of double-quoted ones (QString works faster on characters than other QStrings), and sent off a patch to the Amarok mailing list.

Hopefully with a few weeks at the beginning of this summer between school and my internship, I’ll be able to finally hack around on Amarok a bit. It’s about time, since I’ve been following development for at least two and a half years now!

Back from India!

I actually returned from India a bit over two weeks ago, but the standard school fair has been keeping me quite busy. Apart from the research symposium mentioned below (slides coming soon?), I also had to: grade HW, do CS2200 HW, Databases project, 8-10pg PUBP paper, open the TA application, 2200 Project, Research demonstration, Research presentation, Prob/Stat HW, and a 2200 Test. And I was supposed to be playing piano for church and competing in a debate tournament over that weekend, but those just weren’t able to happen…

The India trip was a one-week Friday evening to Sunday morning father-son trip. My dad and I left Atlanta for our 8,500 mile, 17 hour direct flight Atlanta-Mumbai. After sleeping nicely, we arrived at Mumbai’s international airport, met our local contact Pradeep, and made it to the hotel via taxi. Since it was only midnight local time (9:30 in the morning on our bodies!) we went out for some “breakfast”. We spent the next couple days wandering around the back roads of Mumbai, hitting up the highlights of Haji Ali, Sassoon Docks, Gateway to India Arch, Elephanta Island, Mani Bhavan (Gandhi’s house), Cafe Leopold, the Taj Mahal Hotel, and all sorts of intriguing back roads. We have this tendency of tryin to avoid doing just the “tourist thing” when visiting other countries, being ferried around by vehicle from site to site without getting a true experience for the flavor of a country’s local culture.

After Mumbai we took a domestic flight down to Coimbature and taxi’d up to Ooty, where we were able to meet with a couple from our church working on Freedom Firm, an organization working for “rescue, restoration, and justice for victims of sex trafficking”. Really powerful work there. Also while in Ooty we woke up early to track elephants and tigers in a nature preserve, hiked the 3hr Cooley trail (and ran away from a lone male elephant), and visited the tea museum and a local tea factory. This is also where Dad got sick and we lost a morning due to illness. Though it slowed us down, it was a nice break from just experiencing and offered the chance for reflection. How much does experience matter if you can’t take those experiences and forge them into coherency for actually impacting your life?

Leaving Ooty via taxi, we made our way to Mysore to see the palace there, but had to miss it because we’d lost so much time that morning. We ended up barely making it to Bangalore in time to make the overnight train up to Hyderabad. What a fantastic experience! In Hyderabad we stayed at Pradeep’s parents’ house, which had a welcome sense of familiarity even though we’d never been to the place. Although much of our siteseeing in Bangalore didn’t work out, we were able to meet up with some great guys at India Missions Association, where Pradeep’s parents work.

There’s certainly way too much for me to able to fit all of my experiences in today, so maybe I’ll have more posts in the future on this wonderful opportunity to visit India I had.

Applying for UROP Research Symposium

Coming on April 1, there will be an undergraduate research symposium at Georgia Tech, with opportunities for both presenting at poster sessions and a 20 minute oral presentation. Part of the application for the presentation is a 250-word abstract of the research thus far, so this was the first time that I’ve had the chance (or had a good reason to) write more about the project. We have recommendations working great now, and are now getting to increasing the size of our music database from 500 tracks to roughly 1700. Soon we’ll also have tempo incorporated into the recommendations, which we think will be a good discriminating feature for tracks. It’s still in the early stages of customizing the CBR algorithm to our specific body of music (Indian music) so there are a lot more improvements to make.

What’s been holding me up recently is unicode text in Python 2.4.4. There are all sorts of funky characters in some of the tracks we’re using, both for filenames and id3 tags. For getting tracks into the databse, we try to have artist, album, year, and filepath. Since filepath is often a function of artist, album, and track number, it is filled with funky characters too. I’m in the process of debugging to figure out what’s going on, and am experimenting with the unicode method, bash language settings, python language settings, and vim language settings in ways I never have before. Hopefully I’ll be able to post my fix soon!

Buying Sheet Music Online

You would think that in the world we live today, getting ahold of sheet music for some of your favorite songs online wouldn’t be that big of a deal. I mean, just poke your nose into enough dark corners of the internet and eventually what you’re looking for reveal itself. Right? There seem to be plenty of people getting along just fine using that approach for music, movies, TV shows, software, and even e-books now. But you would be surprised how difficult it is to find freely available sheet music, let alone the legal kind.

So what’s a music aficionado supposed to do? Well, I happened to stumble upon a site today that does sheet music right, worshipmusic.com. Sure, it’s a highly specialized target audience, but read this: I was able to buy a digital lead sheet for a song I’ll be playing in a few days for just $2.50. Yeah, two dollars and fifty cents. A nice and simple process too. The standard shopping cart, checkout fare, but then I instantly received a download link via email for the pdf. Not any of those crazy proprietary plugins that tend to cause Firefox crashes, but nice simple pdfs. Exactly what everybody wants. I had a great experience and worshipmusic.com, and would have bought several more songs if they would have had them available for digital download.

Maybe I want everything my way, but it still wasn’t good enough. If I can get a song for $0.99 on iTunes, why should it cost $2.50 for the sheet music? And especially since I’m just downloading a file. You can’t even plead printing, shipping, and distribution costs on that one, buddy. The two and a half bucks was a low enough price point for me on this one-time purchase, but it’d probably need to be closer to the buck-a-pop range that iTunes has gotten. The selection is also extremely limited. Out of six songs I was looking for, they only had one. Browsing was a bit difficult as well. With long lists of items and not much effort put into usability, particularly categorizing the catalog, it took a while to figure out that they even had that song.

So what would the perfect sheet music store look like for me? Probably a lot like Amazon.com‘s mp3 downloads, but with pdf files instead of mp3. It’s a clean store, easy to find things. The download process is simple, and gives you exactly what you wanted: that file quickly, easily, and legally. If old media is to not get run over by turning public opinion regarding file sharing, they’ve got to fight with products, not lawsuits. And this sort of product is exactly what I’m looking for.

First Post!

So in the tradition of every website, I’m going to be starting a blog to share some personal views with all of you, whoever you are. I’d imagine this will act in a combination of a research journal for my CBR research and some interesting papers on information security, machine learning, and music technology that I run into. When cool things come up in my classes as well (most likely Infosec or Databases), I’ll make sure to make a mention of that too. Just in general, I’ll try to keep things non-stagnant and moving in some sort of cohesive direction. We’ll see how that goes…

CBR website functioning

First up is some work on the CBR Research. We’ve gotten the first few similarity matrices done on a subset of our music library, just 500 songs for now. The similarity matrix is the actual product of the entire CBR algorithm: a complete graph with weighted edges and n vertices, where n is the number of songs. Each edge weight is the distance one song is from another. So theoretically, the vertex which is closest to another should be the song that is most similar to the first. Theoretically.

Part of what I’ve done over the past few weeks is to convert the matrix into a more usable form (row-column-distance 3-tuples) and import those into the MySQL database. Now we’re able to make queries that return the closest few tracks to any given seed song and actually listen to the music, always a good thing. Because without listening to it, you can’t tell if the algorithm is producing any sort of meaningful results!

Turns out the results are pretty good, especially for a very first run-through. Loud and fast songs are followed by other loud and fast songs, and slow, airy songs are followed by slow, airy songs. Excellent. Next up, we think that adding a tempo component to the algorithm will greatly improve results, and are looking at throwing bpm into the whole mix. Since it’s working solely on frequency distributions now (MFCCs, to be precise), adding tempo should be a good discriminatory attribute. Makes sense to me, so we’ll look towards putting that in soon too.

BPM submission interface

The problem is, though, that we need a way of calculating bpm algorithmically, which should be a relatively solved problem as far as Music Technology goes. Unfortunately, the first run-through of the default bpm detection function in the MIR Toolbox only got three of five bpm values correct, compared to our manual annotation. So to scale up to our 500 song subset, and later to the entire library? Three of five sure won’t do, so we’ve got some tweaking to do with the algorithm there, and the only way we can know if it’s working correctly or not is to have correctly-annotated songs… enter human intelligence!

I’ve added new tables to the db structure for users and bpm ratings, created the ability to login as a particular user, and label a particular song with a particular bpm. All with a relatively decent, but perfectly functional, interface. So the group of us in CBR Research will be annotating these few songs and working from there. That’s right, crowd-sourcing with a crowd of … 6. Fun stuff.

Ajax-y prettiness

I’m looking into a real-slick ajax interface for the submissions with jQuery and other fanciness, but it looks like just too much work for someone with much less javascript/jQuery experience than in PHP and MySQL. It’s working now, so if it ain’t broken don’t fix it! In the future, once this whole thing is opened up to the public, slickness will be a factor that we’ll need to consider, and the ajax experience certainly promotes that. I’ll have to work on it sometime, so might as well start immersing myself in the technology before there’s a deadline and it’s still early in the semester.

Expect to hear more about the work in future! I’ll be sincerely trying to keep this blog from falling into disrepair like so many seem to do. Things should be interesting, that’s for sure.