Ticket #7631 (closed feature request: fixed)

Opened 4 months ago

Last modified 3 months ago

Allow to differentiate between newtypes and datatypes when using Generics

Reported by: Feuerbach Owned by: dreixel
Priority: normal Milestone:
Component: libraries (other) Version: 7.7
Keywords: generics Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

When writing a generic instance, I would like to be able to tell whether the type under consideration has been declared using newtype or data.

For example, in SmallCheck? we generate values of certain "depth". It is natural to treat datatype constructors as increasing the depth of the constructed value, and newtype constructors as preserving the depth.

Change History

Changed 4 months ago by Feuerbach

  • summary changed from Allow to differentiate between newtypes and datatypes to Allow to differentiate between newtypes and datatypes when using Generics

Changed 4 months ago by dreixel

  • owner set to dreixel
  • version changed from 7.6.1 to 7.7

I'm happy to implement this.

Changed 3 months ago by jpm@…

commit 6046b25ea35291f9fb0b30633f6f8b8d83a7a00a

Author: Jose Pedro Magalhaes <jpm@cs.ox.ac.uk>
Date:   Wed Feb 13 10:40:16 2013 +0000

    Add isNewtype to GHC.Generics (FIX #7631)

 compiler/prelude/PrelNames.lhs       |    5 +++--
 compiler/typecheck/TcGenGenerics.lhs |    7 +++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

Changed 3 months ago by dreixel

  • status changed from new to closed
  • resolution set to fixed

Done. New test is GenNewtype.

Note: See TracTickets for help on using tickets.