QuantifiedConstraints: Odd superclass constraint
This code works
{-# 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?
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.5 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |