[GHC] #14831: QuantifiedConstraints: Odd superclass constraint

GHC ghc-devs at haskell.org
Wed Feb 21 21:58:08 UTC 2018


#14831: QuantifiedConstraints: Odd superclass constraint
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.5
      Resolution:                    |             Keywords:
                                     |  QuantifiedConstraints wipT2893
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Ah. Maybe not a bug. Consider
 {{{
 instance (forall xx. cls xx => Semigroup xx)
       => Monoid (Free cls a) where
    mempty = undefined
 }}}
 We need the superclass
 {{{
  [W] Semigroup (Free cls a)
 }}}
 What you were hoping was that GHC would use the instance
 {{{
 instance (forall xx. cls xx => Semigroup xx)
       => Semigroup (Free cls a) where
 }}}
 to reduce the wanted superclass to
 {{{
  [W] (forall xx. cls xx => Semigroup xx)
 }}}
 which we can readily solve from the context of the `Monoid` instance.

 But ALASf, the `Monoid` instace claims to have a way to solve `(Semigroup
 xx)` for
 any `xx`.   Currently GHC tries the local, quantified constraints
 ''first'', so
 from
 {{{
  [W] Semigroup (Free cls a)
 }}}
 using the quantified constraint, we get
 {{{
  [W] cls (Free cls a)
 }}}
 which we have no way to solve.

 The quantified constraint does look far too general.  I'll declare this
 not-a-bug for now.

 I have not looked at comment:2 yet; let's sort this part out first.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14831#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list