Sampling rate is the number of numeric audio samples captured or generated each second. A sampled signal approximates a continuous analog signal, so its rate limits how accurately it can reproduce changes over time. For a signal with a known highest frequency, the rate must be at least twice that frequency; 44.1 kHz is a common choice because frequencies above 22 kHz are not relevant to human hearing. section 10.1
In a mono synthesizer, a sample can be a Double and a signal a list of samples. Set a single sampleRate value, then derive integer counts from it: samples per period are sampleRate / frequency, and samples for a duration are duration * sampleRate. Round these results because a signal cannot contain a fractional sample. section 10.1.1
Listing 10.1 Types and helper functions for dealing with signals
type Sample = Double #1 type Signal = [Sample] #1 type Hz = Double #1 type Seconds = Double #1 sampleRate :: Double #2 sampleRate = 44100 samplesPerPeriod :: Hz -> Int samplesPerPeriod hz = round $ sampleRate / hz #3 samplesPerSecond :: Seconds -> Int samplesPerSecond duration = round $ duration * sampleRate #4
This helper module fixes the rate at 44,100 samples per second and turns frequencies and durations into the integer sample counts needed to generate a signal. section 10.1.1
Exporting generated audio
A tone generator uses samplesPerPeriod and samplesPerSecond to create waveform values. When writing a WAV file, place the same rate in the Audio record, alongside one channel and converted sample data. Keeping generation and file metadata aligned lets the exported data be interpreted at the intended speed. section 10.1.2 section 10.1.2

