Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#10252 closed feature request (worksforme)

Abstract newtype in hs-boot

Reported by: ezyang Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.11
Keywords: backpack Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Currently, the following syntax is not supported in an hs-boot file:

module A where
newtype F

This functionality would be pretty useful, since often the RHS of a newtype is intended to be abstract, and would be a pain to place in the boot file. This is also useful for Backpack.

It's a bit hard for me to tell what this should do under the hood: we would have newtypes without the coercions.

Change History (4)

comment:1 Changed 4 years ago by ezyang

Resolution: worksforme
Status: newclosed

Actually, the data keyword seems to work fine here.

comment:2 Changed 4 years ago by goldfire

This scares me. data and newtype are different! After a quick ponder, I don't see damage that can be caused by abusing this.

But, if we ever had representational type families (where type instance RepF Int = Bool would be used to reduce RepF Age to Bool), this would be a disaster. I can't seem to find a ticket requesting representational matching for type families (or classes, or data families), but the idea has come up. (See some wonderings in this direction in #9112, for example.)

comment:3 Changed 4 years ago by rwbarton

You already can define instances of a data family that are newtypes, isn't this sort of like a special case of that?

comment:4 Changed 4 years ago by goldfire

Hmmm... I guess so. It means that we can't tell whether something is a data or a newtype right away. This throws out the idea of representational matching, for better or worse.

Good point.

Note: See TracTickets for help on using tickets.