Hpc (at least with 6.10.1) is not happy with literate haskell or with cpp. Even if your file contains no cpp, hpc will give spurious results if you use the cpp option on the command line. One way round both of these problems is to pre-process the source by hand with something like

1 What is hpc?

Hpc is a tool-kit to record and display Haskell program coverage. Hpc
includes tools that instrument Haskell programs to record program
coverage, run instrumented programs, and display the coverage
information obtained.

Hpc works by applying a source-to-source transformation; this
transformation also generates as a by-product a program-index file
(.pix) and module-index files (.mix). The transformed program is
compiled with a library; in addition to its usual run-time behaviour
the program generates a coverage record in a program-ticks file
(.tix). If the program is run more than once, coverage data is
accumulated to reflect all runs.

Hpc provides coverage information of two kinds: source coverage and
boolean-control coverage. Source coverage is the extent to which every
part of the program was used, measured at three different levels:
declarations (both top-level and local), alternatives (among several
equations or case branches) and expressions (at every level). Boolean
coverage is the extent to which each of the values True and False is
obtained in every syntactic boolean context (ie. guard, condition,
qualifier).

Hpc displays both kinds of information in two different ways: textual
reports with summary statistics (hpc-report) and sources with colour
mark-up (hpc-source).

2 Downloading

This version of hpc is available under a BSD-style license for free
use by all sectors of the Haskell community. The hpc-trans tool was based
on components from the nhc98 compiler or from the hat tracing system,
and we gladly acknowledge the contribution of the original authors.

5 Hpc quirks

Hpc (at least with 6.10.1) is not happy with literate haskell or with cpp. Even if your file contains no cpp, hpc will give spurious results if you use the cpp option on the command line. One way round both of these problems is to pre-process the source by hand with something like