[GHC] #14004: G

GHC ghc-devs at haskell.org
Sat Jul 22 05:08:21 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:                    |
-------------------------------------+-------------------------------------
Description changed by zaoqi:

Old description:

> {{{#!hs
> {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
>
> class GEq a b where
>     geq :: a -> b -> Bool
>
> instance {-# OVERLAPPING #-} Eq a => GEq a a where
>     geq = (==)
>
> instance GEq a b where
>     geq _ _ = False
> }}}
>

> {{{
> GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
> Prelude> :load GEq.hs
> [1 of 1] Compiling Main             ( GEq.hs, interpreted )
> Ok, modules loaded: Main.
> *Main> geq::a->b->Bool
>
> <interactive>:3:1:
>     Overlapping instances for GEq a1 b1 arising from a use of ‘geq’
>     Matching instances:
>       instance GEq a b -- Defined at GEq.hs:9:10
>       instance [overlapping] Eq a => GEq a a -- Defined at GEq.hs:6:30
>     (The choice depends on the instantiation of ‘a1, b1’
>      To pick the first instance above, use IncoherentInstances
>      when compiling the other instance declarations)
>     In the expression: geq :: a -> b -> Bool
>     In an equation for ‘it’: it = geq :: a -> b -> Bool
> *Main>
> }}}
>
> In order to
> {{{#!hs
> {-# LANGUAGE KindSignatures, GADTs #-}
> data Dyn :: * where
>     Dyn :: a -> Dyn
>
> instance Eq Dyn where
>     (==) = geq
> }}}

New description:

 {{{#!hs
 {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}

 class GEq a b where
     geq :: a -> b -> Bool

 instance {-# OVERLAPPING #-} Eq a => GEq a a where
     geq = (==)

 instance GEq a b where
     geq _ _ = False
 }}}


 {{{
 GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
 Prelude> :load GEq.hs
 [1 of 1] Compiling Main             ( GEq.hs, interpreted )
 Ok, modules loaded: Main.
 *Main> geq::a->b->Bool

 <interactive>:3:1:
     Overlapping instances for GEq a1 b1 arising from a use of ‘geq’
     Matching instances:
       instance GEq a b -- Defined at GEq.hs:9:10
       instance [overlapping] Eq a => GEq a a -- Defined at GEq.hs:6:30
     (The choice depends on the instantiation of ‘a1, b1’
      To pick the first instance above, use IncoherentInstances
      when compiling the other instance declarations)
     In the expression: geq :: a -> b -> Bool
     In an equation for ‘it’: it = geq :: a -> b -> Bool
 *Main>
 }}}

 In order to
 {{{#!hs
 {-# LANGUAGE KindSignatures, GADTs #-}
 data Dyn :: * where
     Dyn :: a -> Dyn

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

--

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


More information about the ghc-tickets mailing list