I was playing with musical note names having the goal to not confuse enharmonic equals, i.e. I wanted to get the accidentals (sharps and flats) right. The note a perfect fifth above the note B
needs to be Fs
and not Gb
, even though Fs
and Gb
are the same key on a piano keyboard.
Also I wanted the convenience of writing e.e. Fs
in a haskell program, without spaces, quotes or an extra function.
I ended up defining 35 constructors, ranging from Cbb
to Bss
. While this worked and did get the accidentals right, I was unhappy about the limitation to at most two accidentals. Internally, the accidentals we represented asInt
s anyways.
- Is there a way to define an infinite number of constructors as indicated in the title, so notes with any number of accidentals (like
Cbbbb
) could be used? Template haskell maybe? - Or alternatively, can I get the convenience of writing
Cbbbb
in a haskell program (without quotes, spaces or an extra function) without makingCbbbb
a constructor?