Opened 11 months ago

Closed 11 months ago

Last modified 11 months ago

#9178 closed task (fixed)

improve orphan instance warning

Reported by: fphh Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

The current warning

Warning: orphan instance: instance ClassName TypeName

could be improved by suggesting three solutions:

(i) Move the instance declaration to the file, where the class has been declared
(ii) Move the instance declaration to the file, where the Type has been declared
(iii) Wrap the type with a newtype and declare the instance on the new type.

Attachments (1)

0001-Finished-ticket-9178-and-added-a-test.patch (3.9 KB) - added by fphh 11 months ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 11 months ago by fphh

  • Status changed from new to patch

Finished, ready for review.

comment:2 Changed 11 months ago by fphh

This is how it looks like. What do you think?

T9178.hs:8:10: Warning:
    Orphan instance: instance Show T9178_Type
    To avoid this
        move the instance declaration to the module of the class or of the type, or
        wrap the type with a newtype and declare the instance on the new type.

comment:3 Changed 11 months ago by simonpj

OK with me. Do others like the new error message? It's a user matter not an implementation matter.

Simon

comment:4 Changed 11 months ago by Joachim Breitner <mail@…>

In 877a9577280f4b6aa6ef47f7a27d9b741b8234cf/ghc:

Better warning message for orphan instances (Ticket #9178)

Including a test case.

comment:5 Changed 11 months ago by nomeata

  • Resolution set to fixed
  • Status changed from patch to closed

Also ok with me. That makes two of us, so I pushed it. Nevertheless: If someone wants to improve it, feel free to do so.

Congrats, Heinrich, for your first contribution to GHC, I hope there will be more! :-)

comment:6 Changed 11 months ago by Joachim Breitner <mail@…>

In 707bde533dcb16bf8f5a30179d098b343e54fe7b/ghc:

Update test results with new orphan instance warning

It seems that the patch in #9178 was not fully validated.
Note: See TracTickets for help on using tickets.