\end{haskelllisting}
A \keyword{trill} is an ornament that alternates rapidly between two (usually
adjacent) pitches. Let's implement a trill as a function that take a note as
an argument and returns a series of notes whose durations add up to the same
duration as as the given note.
A trill alternates between the given note and another note, usually the note
above it in the scale. Therefore, it must know what other note to use. So
that the structure of \function{trill} remains parallel across different keys, we'll
implement the other note in terms of its interval from the given note in half
steps. Usually, the note is either a half-step above (interval = 1) or a
whole-step above (interval = 2). Using negative numbers, a trill that goes to
lower notes can even be implemented.
Also, the trill needs to know how fast to alternate between the two notes.
One way is simply to specify the type of smaller note to use.
(Another implementation will be discussed later.)
So, our \function{trill} has the following type:
\begin{haskelllisting}

\end{haskelllisting}
Since the function uses \function{Music.tranpose}
one can even trill more complex objects like chords.
The next version of \function{trill} starts on the second note,
rather than the given note.
It is simple to define a function that starts on the other note:
\begin{haskelllisting}