GHC 8 superclass chain constraint regression
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:
```hs
{-# 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 https://phabricator.haskell.org/D1594
could possibly be related.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.1-rc2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GHC 8 superclass chain constraint regression","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1-rc2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"It seems that GHC 8 regresses with regard to GHC 7.10, when it tries to\r\nsatisfy the constraints, implied by instance context.\r\n\r\nThe following does not build on GHC 8.0.1 RC2, but does on 7.10.3:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE FlexibleInstances #-}\r\n{-# LANGUAGE UndecidableInstances #-}\r\n--{-# LANGUAGE UndecidableSuperClasses #-} -- this doesn't matter\r\n{-# LANGUAGE UnicodeSyntax #-}\r\n\r\nmodule Foo where\r\n\r\nclass Super a\r\nclass Super a ⇒ Left a\r\nclass Super a ⇒ Right a\r\ninstance (Left a) ⇒ Right a\r\n}}}\r\n\r\nthe error being:\r\n\r\n> • Could not deduce (Super a)\r\n> arising from the superclasses of an instance declaration\r\n> from the context: Left a\r\n> bound by the instance declaration\r\n> at repro.hs:9:10-27\r\n> Possible fix:\r\n> add (Super a) to the context of the instance declaration\r\n> • In the instance declaration for ‘Right a’\r\n\r\nIt also /roughly/ seems that https://phabricator.haskell.org/D1594\r\ncould possibly be related.","type_of_failure":"OtherFailure","blocking":[]} -->
issue