Ticket #3888 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

Suggest -XGeneralizedNewtypeDeriving for newtypes

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.12.1
Keywords: Cc: vogt.adam@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: typecheck/should_fail/tcfail117 Blocked By:
Blocking: Related Tickets:

Description

newtype A = A Int deriving Enum

t.hs:1:27:

Can't make a derived instance of `Enum A'

(`A' has non-nullary constructors)

In the newtype declaration for `A'

But perhaps -XGeneralizedNewtypeDeriving should be suggested (ideally only if the wrapped type actually had such an instance)?

Change History

Changed 3 years ago by simonpj

  • status changed from new to closed
  • testcase set to typecheck/should_fail/tcfail117
  • resolution set to fixed

Good idea. Fixed by

Mon Mar  1 11:15:55 GMT 2010  simonpj@microsoft.com
  * Suggest -XGeneralizedNewtypeDeriving (fix Trac #3888)
  
  If we can't derive a type, but it's a reasonable possibility that
  newtype deriving would do the job, suggest it. 
  
  A little refactoring too, moving non_iso_class to top level,
  and putting it with std_class_via_iso.

    M ./compiler/typecheck/TcDeriv.lhs -12 +23

Simon

Note: See TracTickets for help on using tickets.