ArchiveOrangemail archive

The Haskell Cafe


haskell-cafe.haskell.org
(List home) (Recent threads) (38 other Haskell lists)

Subscription Options

  • RSS or Atom: Read-only subscription using a browser or aggregator. This is the recommended way if you don't need to send messages to the list. You can learn more about feed syndication and clients here.
  • Conventional: All messages are delivered to your mail address, and you can reply. To subscribe, send an email to the list's subscribe address with "subscribe" in the subject line, or visit the list's homepage here.
  • Moderate traffic list: up to 30 messages per day
  • This list contains about 107,406 messages, beginning Oct 2000
  • 12 messages added yesterday
Report the Spam
This button sends a spam report to the moderator. Please use it sparingly. For other removal requests, read this.
Are you sure? yes no

HPC question

Ad
David Turner 1337766053Wed, 23 May 2012 09:40:53 +0000 (UTC)
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
Andres Löh 1337768593Wed, 23 May 2012 10:23:13 +0000 (UTC)
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
David Turner 1337769265Wed, 23 May 2012 10:34:25 +0000 (UTC)
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 1337778912Wed, 23 May 2012 13:15:12 +0000 (UTC)
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
Home | About | Privacy