I have been working on a music theory framework for quite a long time now. Years, even. What began as an amused 'I wonder what that would look like' has become my quest to outline the wind. While I certainly have not been working on the library full time, I have thrown many hours into it.
For some reason, I decided that I needed to parse chord symbols. To be clear, I did not need it for a particular app. I needed to figure it out. Why? I realized that it is a complex challenge without any clear solutions and solving it could open new possibilities which I want opened.
Roughly two years ago, I wrote a 'parser' which was really a gussied up scanner (I built its API in the likeness of NSScanner). This, coupled with my zeal and naïveté, led a large amount what the I will describe as ‘poorly planned code that worked'. I decided that I could do better.
Roughly one year ago, I wrote a 'parser' which is a poor man's (me) combinator (I think. Maybe). I tried not to rush into this attempt as brashly as the previous. I read up on parsing, learned that what I wanted was a variation on a GLR parser, and I figured out how to write the behavior that I was after. This led to what I will call 'only slightly less poorly planned code'. I will take this moment to say that the tests pass and I cover the lion's share of my cases. It is alright code. The problem, as it turns out, is that I made a mistake in design which greatly overcomplicates parsing slash chords.
Disheartened by my realization, I simply put the project down for a little while. I thought about a paper that I found in the lead up to the rewrite. It seemed like a silver bullet–it explained how to write a GLR parser–except it explained everything in Haskell. Not only did I not know Haskell, Haskell did not seem interested in letting me get to know Haskell.
Then Apple announced Swift and I recognized some Haskell-like leanings. For some reason, this has inspired me to learn Haskell. I seem to think that if I do, I will be able to write the parser in Swift.
This is all to say, I am heading back into the mines. I hope that writing about it might somehow lead to me unleashing my 'now much less terrible' code upon the world when I surface.