[Haskell-beginners] data at different stages

Dennis Raddle dennis.raddle at gmail.com
Sat Jan 28 05:59:00 CET 2012

I'm working on an application for reading Music XML and manipulating it,
including translating it into midi events.

Storing music data can take place from different perspectives or

- a literal translation of the MusicXML would store each note and marking
on the page

- another representation might relate to higher concepts: for instance,
instead of storing individual dynamic markings and indications for swelling
and ebbing of dynamics, it might create a single data structure which is a
dynamic profile over time. Instead of storing all the markings over the
notes individually (staccato, accents, slur marks, etc.) it might examine
all the markings at once and compute concrete performance instructions note
by note.

There are about four distinct stages in processing the music, in which
things become either more abstract (grouping together details into higher
concepts) or more concrete (such as more literal performance instructions).

One of the stages, by the way, tries to represent notes in a way such that
they can be moved in time or "sliced out" without disturbing the continuity
of the performance instructions.

At first I created several different data structures, one for each useful
stage. Many of the fields are copied literally. There are similar fields
which need distinct names. This is starting to seem like a confusing mess.

Another approach is to create one data structure which contains some
"Maybe" type fields. When the processing reaches a certain stage, they are
set to "Just <value>" if applicable to that stage. Otherwise they are set
to Nothing.

I didn't want to do this at first because it's too much like a sloppy
script language. The type system of the compiler would no longer assist me
in verifying the validity of the data at each stage.

But it's turning into a mess- and the key reason it's a mess, I think, is
that I DON'T have a clear model of the stages. It keeps changing as I
expand the requirements of my program. What seemed like a useful
representation last month needs to be changed today.

Any ideas welcome.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120127/7e678303/attachment.htm>

More information about the Beginners mailing list