[GHC] #14831: QuantifiedConstraints: Odd superclass constraint

GHC ghc-devs at haskell.org
Wed Feb 21 10:46:48 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 Iceland_jack):

 Similarly

 {{{#!hs
 newtype Free :: (Type -> Constraint) -> (Type -> Type) where
   Free :: () -> Free cls a

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

 fails because of the default methods `sconcat` and `stimes`

 {{{#!hs
 class Semigroup a where
   (<>)    :: a -> a -> a
   sconcat :: NonEmpty a -> a
   stimes  :: Integral b => b -> a -> a
 }}}

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

 I.hs:10:10: error:
     • Could not deduce: cls (Free cls a)
         arising from a use of ‘GHC.Base.$dmsconcat’
       from the context: forall xx. cls xx => Semigroup xx
         bound by the instance declaration at I.hs:10:10-70
     • In the expression: GHC.Base.$dmsconcat @(Free cls a)
       In an equation for ‘sconcat’:
           sconcat = GHC.Base.$dmsconcat @(Free cls a)
       In the instance declaration for ‘Semigroup (Free cls a)’
     • Relevant bindings include
         sconcat :: GHC.Base.NonEmpty (Free cls a) -> Free cls a
           (bound at I.hs:10:10)
    |
 10 | instance (forall xx. cls xx => Semigroup xx) => Semigroup (Free cls
 a) where
    |
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 I.hs:10:10: error:
     • Could not deduce: cls (Free cls a)
         arising from a use of ‘GHC.Base.$dmstimes’
       from the context: forall xx. cls xx => Semigroup xx
         bound by the instance declaration at I.hs:10:10-70
       or from: Integral b
         bound by the type signature for:
                    stimes :: forall b. Integral b => b -> Free cls a ->
 Free cls a
         at I.hs:10:10-70
     • In the expression: GHC.Base.$dmstimes @(Free cls a)
       In an equation for ‘stimes’:
           stimes = GHC.Base.$dmstimes @(Free cls a)
       In the instance declaration for ‘Semigroup (Free cls a)’
     • Relevant bindings include
         stimes :: b -> Free cls a -> Free cls a (bound at I.hs:10:10)
    |
 10 | instance (forall xx. cls xx => Semigroup xx) => Semigroup (Free cls
 a) where
    |
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 Failed, no modules loaded.
 Prelude>
 }}}

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


More information about the ghc-tickets mailing list