[GHC] #14004: G

GHC ghc-devs at haskell.org
Sun Jul 23 05:42:25 UTC 2017


#14004: G
-------------------------------------+-------------------------------------
        Reporter:  zaoqi             |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.3
      Resolution:                    |             Keywords:
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 zaoqi):

 Replying to [comment:9 AntC]:
 > Hi @bgamari, I got this to work just changing the pragmas, per my
 comment:7. (So I editted that comment after posting.) Note there's a `Eq a
 =>` constraint on the `GEq a a` instance; but not on the `GEq a b`.
 >
 > {{{
 >
 > Dyn "hello" == Dyn "bye"    ===> False
 > Dyn "hello" == Dyn "hello"  ===> True
 > Dyn "hello" == Dyn 'b'      ===> False
 >
 > }}}
 >
 > I agree @zaoqi's definition for `Dyn` is 'dodgy'.

 {{{#!hs
 {-# LANGUAGE KindSignatures, GADTs #-}
 {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
 data Dyn :: * where
     Dyn :: a -> Dyn

 instance Eq Dyn where
     Dyn a == Dyn b = geq a b

 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
 }}}
 {{{
 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/14004#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list