Music Theory - Implementation 2018-09-02

By Max Woerner Chase

In this post:

I spent Saturday reading about crate organization, partly for this, mostly for gdp, and then just started implementing types and functions from the last post. It's not all implemented yet, and I keep changing the interfaces, but it shouldn't take long for me to get things the rest of the way ported, and start adding functionality.

The biggest obstacle I've hit so far is not having a good sense of when code with weird ergonomics is Just How Rust Is Right Now, and when it's "Oh, yeah, that was a compelling use case, so we stabilized a feature that helps with that literally a year ago." So, with generally not knowing how best to express things, I feel like I haven't really hit my stride, but all the same I'm translating code into a nice, mostly-concise form. A bunch of my re-expressions were around converting from tuple returns to mutable arguments.

For ease of "just throwing code in there and making sure it typechecks" I've been just writing absolutely everything into a single file. To move forward, I think I ought to start separating things into modules. Maybe first do it within the file, then pull out modules into their own files as possible. Once that's done, I can look over the various types, and, without the noise of the entire rest of the file, figure out what derives and such to stick on them.

One thing I should figure out before I do too much more is, what exactly is this library supposed to expose? I guess, probably, all of the types I noted up, but I'm not really sure. Also, I probably want to bite the bullet and make Duration a newtype, because I do want it to be distinct from "a fraction that is the same shape".

Next time, I look over this last week.