[GHC] #14831: QuantifiedConstraints: Odd superclass constraint
GHC
ghc-devs at haskell.org
Fri Mar 2 13:45:06 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):
Update: With [https://ghc.haskell.org/trac/ghc/ticket/2893#comment:34
latest changes] the original code compiles AND we can build this hierarchy
for our own `Semigroup`-`Monoid`-`Group` hierarchy
{{{#!hs
instance semi ~=> Semigroup => Semigroup (Free semi a) where
(<>) = liftFree2 (<>)
sconcat = undefined
stimes = undefined
instance mon ~=> Monoid => Monoid (Free mon a) where
mempty = liftFree0 mempty
mappend = liftFree2 (<>)
mconcat = undefined
instance grp ~=> Group => Group (Free grp a) where
inv = liftFree1 inv
}}}
but leaving out or inlining default methods `mconcat = foldr mappend
mempty` fails.
----
{{{#!hs
class Monoid a => Group a where
inv :: a -> a
type cls ~=> cls' = (forall xx. cls xx => cls' xx :: Constraint)
liftFree0 :: (forall xx. cls xx => xx) -> Free cls a
liftFree0 a = Free (pure a)
liftFree1 :: (forall xx. cls xx => xx -> xx) -> (Free cls a -> Free cls a)
liftFree1 f (Free xs) = Free (fmap f xs)
liftFree2 :: (forall xx. cls xx => xx -> xx -> xx) -> (Free cls a -> Free
cls a -> Free cls a)
liftFree2 f (Free xs) (Free ys) = Free (liftA2 f xs ys)
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14831#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list