Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#11762 closed bug (duplicate)

GHC 8 superclass chain constraint regression

Reported by: _deepfire Owned by:
Priority: highest Milestone: 8.0.1
Component: Compiler (Type checker) Version: 8.0.1-rc2
Keywords: Cc: simonpj
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: #11427 Differential Rev(s):
Wiki Page:


It seems that GHC 8 regresses with regard to GHC 7.10, when it tries to satisfy the constraints, implied by instance context.

The following does not build on GHC 8.0.1 RC2, but does on 7.10.3:

{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
--{-# LANGUAGE UndecidableSuperClasses #-} -- this doesn't matter
{-# LANGUAGE UnicodeSyntax #-}

module Foo where

class Super a
class Super a  Left a
class Super a  Right a
instance (Left a)  Right a

the error being:

  • Could not deduce (Super a)

arising from the superclasses of an instance declaration

from the context: Left a

bound by the instance declaration at repro.hs:9:10-27

Possible fix:

add (Super a) to the context of the instance declaration

  • In the instance declaration for ‘Right a’

It also /roughly/ seems that could possibly be related.

Change History (7)

comment:1 Changed 3 years ago by bgamari

Milestone: 8.0.1
Priority: normalhigh
Type of failure: None/UnknownGHC rejects valid program

comment:2 Changed 3 years ago by bgamari

Cc: simonpj added
Priority: highhighest

Pinging simonpj.

comment:3 Changed 3 years ago by jme

This seems to be the same as #11427--see especially ticket:11427#comment:3.

comment:4 Changed 3 years ago by _deepfire

Oh my god, does it mean we are going to sacrifice the very convenient, simple and obvious (for some value of "simple" and "obvious") implication on the altar of recursive superclasses?

Because #11427 seems to conclude in that way..

comment:5 Changed 3 years ago by simonpj

Yes, it's the same as #11427.

It doesn't bite often, and it's also easy to fix, thus

instance (Super a, Left a) ⇒ Right a

What I most dislike about it is that it's hard to explain and justify. I would like a better way to do this, but I don't know one. Better ideas welcome!


comment:6 Changed 3 years ago by simonpj

Resolution: duplicate
Status: newclosed

OK so currently this is by design, and so I'll mark it as invalid

By all means suggest something better, but we can't do much for 8.0.


comment:7 Changed 3 years ago by Ben Gamari <ben@…>

In 933abfa7/ghc:

rel-notes: Add note about UndecidableSuperClasses and #11762

Test Plan: Read it

Reviewers: austin, kosmikus

Reviewed By: kosmikus

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11318, #11762
Note: See TracTickets for help on using tickets.