[GHC] #14061: `instance Eq Dyn`
GHC
ghc-devs at haskell.org
Sun Jul 30 06:32:12 UTC 2017
#14061: `instance Eq Dyn`
-------------------------------------+-------------------------------------
Reporter: zaoqi | Owner: (none)
Type: feature | Status: new
request |
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.2
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
{{{#!hs
{-# LANGUAGE KindSignatures, GADTs #-}
data Dyn :: * where
Dyn :: a -> Dyn
}}}
How to write the correct `instance Eq Dyn`, do not change `data Dyn`?
{{{#!hs
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
class GEq a b where
geq :: a -> b -> Bool
instance {-# OVERLAPPABLE #-} (Eq a) => GEq a a where
geq = (==)
instance {-# OVERLAPPING #-} GEq a b where
geq _ _ = False
}}}
{{{#!hs
instance Eq Dyn where
Dyn a == Dyn b = geq a b
}}}
{{{
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Prelude> :load Dyn.hs
[1 of 1] Compiling Main ( Dyn.hs, interpreted )
Ok, modules loaded: Main.
*Main> Dyn () == Dyn ()
False
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14061>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list