[Haskell-cafe] HPC question

Andres Löh andres at well-typed.com
Wed May 23 12:22:39 CEST 2012


Hi David.

> Now, if I fiddle in the .tix file by hand to fake a usage of (/=) by
> changing the 52nd entry from 0 to 1, the Eq instance isn't highlighted any
> more in the HTML output. More strangely, if I then remove the usage of (==)
> by changing the 51st entry from 1 to 0, the Eq instance still isn't
> highlighted. A similar effect happens with the Show instance. It seems to be
> highlighting based only on the last entry in the .tix file, where there are
> two or more identically-placed boxes. Is this right? I'd have expected that
> if I use (==) then the deriving (Eq) clause should be considered 'used'.

I've not looked at the .tix file, but a few tests seem to confirm what
I'd suspect. For derived instances, you have to cover *all* methods,
otherwise the type class will be shown as not covered. Now, in the
case of Eq that's both (==) and (/=), where the derived implementation
of (/=) happens to use the derived implementation of (==). So using
(==) alone is not sufficient, but using (/=) is. Similarly for Show,
where the class defines "showList" that you don't test.

> Secondly, I can't work out what the four boxes in position 15:6-15:9 are
> supposed to be. If I use -ddump-simpl I can see many calls to 'tick' but
> there's no mention of numbers 47, 49 or 50. Perhaps they've been simplified
> away? I'm afraid I don't know what else to try dumping to get at the
> instrumented code before the simplifier's had a go at it.

For the datatype, your use of field labels causes GHC to generate
accessor functions. These aren't covered by your tests. Therefore the
datatype shows as not completely covered.

HTH,
  Andres

-- 
Andres Löh, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com



More information about the Haskell-Cafe mailing list