#7631 closed feature request (fixed)

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 (4)

comment:1 Changed 15 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

comment:2 Changed 15 months ago by dreixel

  • Owner set to dreixel
  • Version changed from 7.6.1 to 7.7

I'm happy to implement this.

comment:3 Changed 14 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(-)

comment:4 Changed 14 months ago by dreixel

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

Done. New test is GenNewtype.

Note: See TracTickets for help on using tickets.