Following on from my question here : How do I attach optional attributes to values?
I'm trying to define a Haskell representation of music.
I'd like to do something this :
data Chord = Chord Int Modality [Annotate] deriving (Eq, Show, Read) which, as I understand defines a new type which is a Chord.
And then I want to be able to add Chords amongst other events to a Score such that
data Event = Note Int | Chord Int Modality [Annotate] | Rest However, the compiler says I'm trying to define Chord twice.
So, is there a way to use an earlier defined data type inside a new data type definition? What I'm doing looks, to me, more or less like the classic Tree definition :
data Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving (Show, Read, Eq) which works OK. So why is it ok to use "Tree" in this example, but not "Chord" in mine?