[Haskell-beginners] Question about functors (or maybe not...)

Patrick LeBoutillier patrick.leboutillier at gmail.com
Sat Mar 19 03:00:33 CET 2011


Hi,

I'm writing a music library and have the following types and functions:

data Note = C | D | E | F | G | A | B | Sharp Note | Flat Note
raise C = Sharp C

data Quality = Major | Minor

data Chord = Chord Quality Note  -- Note is the root
data Scale = Scale Quality Note  -- Note is the tonic

What I would like to do is to be able to lift the raise function and
apply it to
Chords and Scales. Something like this:

fmap raise (Chord Major C) = Chord Major (Sharp C)

But these are not functors as it doesn't seem to make sense for them to
be polymorphic. A chord can't really made of anything except Notes.


Does anybody have any ideas?

Patrick

-- 
=====================
Patrick LeBoutillier
Rosemère, Québec, Canada



More information about the Beginners mailing list