[GHC] #14831: QuantifiedConstraints: Odd superclass constraint

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


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

 {{{#!hs
 {-# Language QuantifiedConstraints, RankNTypes, PolyKinds,
 ConstraintKinds, UndecidableInstances #-}

 import Data.Semigroup

 newtype Free cls a = Free ()

 instance (forall xx. cls xx => Semigroup xx) => Semigroup (Free cls a)
 where
   (<>)    = undefined
   stimes  = undefined
   sconcat = undefined

 -- instance (forall xx. cls xx => Semigroup xx) => Monoid (Free cls a)
 where
 --   mempty = undefined
 }}}

 but uncomment the `Monoid` instance and we get

 {{{
 $ ghci -ignore-dot-ghci /tmp/I.hs
 GHCi, version 8.5.20180128: http://www.haskell.org/ghc/  :? for help
 [1 of 1] Compiling Main             ( /tmp/I.hs, interpreted )

 /tmp/I.hs:12:10: error:
     • Could not deduce: cls (Free cls a)
         arising from the superclasses of an instance declaration
       from the context: forall xx. cls xx => Semigroup xx
         bound by the instance declaration at /tmp/I.hs:12:10-67
     • In the instance declaration for ‘Monoid (Free cls a)’
    |
 12 | instance (forall xx. cls xx => Semigroup xx) => Monoid (Free cls a)
 where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 Failed, no modules loaded.
 Prelude>
 }}}

 Is this correct behavior?

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


More information about the ghc-tickets mailing list