Opened 3 years ago

Last modified 3 years ago

#13347 patch bug

Abstract classes in hs-boot should not be treated as injective

Reported by: ezyang Owned by:
Priority: low Milestone:
Component: Compiler (Type checker) Version: 8.1
Keywords: hs-boot Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D3236
Wiki Page:


They could be implemented by a newtype (see mkClass), making them non-injective.

Fortunately, this doesn't seem to cause any unsoundness, because the *constructor* for the newtype corresponding to a class is never in scope, so we are never allowed to unwrap "class newtypes". Phew!

Change History (3)

comment:1 Changed 3 years ago by ezyang

Differential Rev(s): Phab:D3236

comment:2 Changed 3 years ago by ezyang

Status: newpatch

comment:3 Changed 3 years ago by Edward Z. Yang <ezyang@…>

In fb5cd9d/ghc:

Properly represent abstract classes in Class and IfaceDecl

Previously, abstract classes looked very much like normal
classes, except that they happened to have no methods,
superclasses or ATs, and they came from boot files.  This
patch gives abstract classes a proper representation in
Class and IfaceDecl, by moving the things which are never
defined for abstract classes into ClassBody/IfaceClassBody.

Because Class is abstract, this change had ~no disruption
to any of the code in GHC; if you ask about the methods of
an abstract class, we'll just give you an empty list.

This also fixes a bug where abstract type classes were incorrectly
treated as representationally injective (they're not!)

Fixes #13347, and a TODO in the code.

Signed-off-by: Edward Z. Yang <>

Test Plan: validate

Reviewers: simonpj, bgamari, austin

Subscribers: goldfire, thomie

Differential Revision:
Note: See TracTickets for help on using tickets.