[Haskell-cafe] I miss OO

Eugene Kirpichov ekirpichov at gmail.com
Thu Nov 26 02:50:25 EST 2009

2009/11/26 Michael Mossey <mpm at alumni.caltech.edu>:
> First of all, thanks for the ideas, everyone. I think I'm starting to get
> the usefulness of type classes.
> With regard to your question, Eugene, you are probably right. In fact my
> rough draft of this code from four months ago used a Map with time as the
> key (of type Rational). I was trying to come up with a quick example and
> didn't think straight.
> You may observe, however, that the concept "note" has a lot of uses and
> contexts. Sometimes it means simply a pitch, like middle C. Sometimes it
> means a black dot on a piece of staff paper, in which case it has a duration
> (as a number of beats). The context of that black dot gives it a dynamic
> level, an associated instrument (timbre), and of course, a time. In this
> larger context, I'm not sure if there is a deep difference between storing
> time inside the object or outside it, except for the practical matter of
> wanting to index notes by time (in which case it is useful to use time
> outside the object as the key). You tell me: do you think it makes a deep
> difference?

I argue that in the situation you provided, the pitch, duration,
timbre and instrument are "essential" attributes of the dot, whereas
time is the position of the dot on paper and should be separated from
its essence.
I think two concepts should be separated if one makes sense and is
useful without the other. A note out of its time context is certainly
useful, for example, it may probably be converted to a MIDI command or
to a graphical glyph (which is further to be positioned by a layout

> Thanks,
> Mike
> Eugene Kirpichov wrote:
>> Hi,
>> Are you sure you need to store the time *inside* your "objects"
>> instead of using, say, pairs "(Time, YourObject)" (and lists of them
>> instead of lists of your objects)?
>> It would seem strange to me that a note HAS-A time even in an OO
>> design: more likely, a note is associated with a time, and this is
>> modeled by pairing them.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Eugene Kirpichov
Web IR developer, market.yandex.ru

More information about the Haskell-Cafe mailing list