
Dear Haskell Cafe, I've been playing around with the -fhpc option to GHC and have come across some things being highlighted yellow in the HTML markup for which I can't work out the right way to 'cover' them. A cut down program that shows what I'm talking about is at http://hpaste.org/68888 Looking at the output of hpc show, I see: 47 0 Main 15:6-15:9 ExpBox False 48 2 Main 15:6-15:9 ExpBox False 49 0 Main 15:6-15:9 ExpBox False 50 0 Main 15:6-15:9 ExpBox False 51 1 Main 22:13-22:14 TopLevelBox ["=="] 52 0 Main 22:13-22:14 TopLevelBox ["/="] 53 1 Main 22:17-22:20 TopLevelBox ["showsPrec"] 54 0 Main 22:17-22:20 TopLevelBox ["showList"] I.e. each of those bits whose highlighting I don't understand is made of some overlapping boxes, one of which is used. 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'. 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. I'm using Haskell Platform 2011.2.0.1 (GHC 7.0.3) on Windows if that's relevant. Thanks in advance, David

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

On 23/05/2012 11:22, Andres Löh wrote:
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.
Ok, I see. It's going to take me a while to cover all instances of this!
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.
Ah, yes, that makes sense. Thanks, David -- David Turner Senior Consultant Tracsis PLC Tracsis PLC is a company registered in England and Wales with number 5019106.

On 23/05/2012 11:33, David Turner wrote:
On 23/05/2012 11:22, Andres Löh wrote:
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.
Ok, I see. It's going to take me a while to cover all instances of this!
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.
Ah, yes, that makes sense.
Further to that, however: http://hpaste.org/68900 The extra test case (line 15) causes HPC not to highlight the Path (line 18) indicating it is now used, even though there are uncovered accessors. I'm confused. Thanks in advance, David
participants (2)
-
Andres Löh
-
David Turner