[Haskell-cafe] I miss OO
Michael Mossey
mpm at alumni.caltech.edu
Thu Nov 26 02:27:25 EST 2009
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?
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.
>
More information about the Haskell-Cafe
mailing list