Neil Mitchell | 6 Jul 00:56

Definition of hidden instance members (bug in GHC or Hugs+Yhc)

Hi,

This is either a GHC bug, or a Yhc+Hugs bug - I'm not sure which, but
the compilers disagree:

import Prelude hiding ((==))
data Foo = Foo
instance Eq Foo where
    (==) a b = True

GHC says:
Temp.hs:14:4: `==' is not a (visible) method of class `Eq'

Yhc and Hugs both successfully compile the module.

Does anyone know which compiler(s) are in the wrong, and need bugs filing?

Thanks

Neil
Neil Mitchell | 6 Jul 01:02

Re: Definition of hidden instance members (bug in GHC or Hugs+Yhc)

>  This is either a GHC bug, or a Yhc+Hugs bug - I'm not sure which, but
>  the compilers disagree:
>
>  import Prelude hiding ((==))
>  data Foo = Foo
>  instance Eq Foo where
>     (==) a b = True

I was thinking that GHC's behaviour seems more sensible, but the
following fails:

import qualified Module as M

instance MClass Foo where
     M.foo = undefined

M. is not allowed as a prefix of a function, which makes resolving
ambiguities hard unless the compiler solves the issue for you (as Hugs
and Yhc do)

Thanks

Neil

Re: Re: Definition of hidden instance members (bug in GHC or Hugs+Yhc)


On 2008 Jul 5, at 19:02, Neil Mitchell wrote:

>> This is either a GHC bug, or a Yhc+Hugs bug - I'm not sure which, but
>> the compilers disagree:
>>
>> import Prelude hiding ((==))
>> data Foo = Foo
>> instance Eq Foo where
>>    (==) a b = True
>
> I was thinking that GHC's behaviour seems more sensible, but the
> following fails:
>
> import qualified Module as M
>
> instance MClass Foo where
>     M.foo = undefined
>
> M. is not allowed as a prefix of a function, which makes resolving
> ambiguities hard unless the compiler solves the issue for you (as Hugs
> and Yhc do)

But this works for me in ghc:

foo.hs:
> import Mod as M
>
> data Bar a = Bar Int a
>
(Continue reading)

Claus Reinke | 6 Jul 01:15

Re: Re: Definition of hidden instance members (bug inGHC or Hugs+Yhc)

> M. is not allowed as a prefix of a function, which makes resolving
> ambiguities hard unless the compiler solves the issue for you (as Hugs
> and Yhc do)

See also:

http://www.haskell.org/pipermail/haskell-prime/2008-April/002569.html
http://hackage.haskell.org/trac/ghc/ticket/2237

Claus
Simon Peyton-Jones | 7 Jul 12:43

RE: Re: Definition of hidden instance members (bug in GHC or Hugs+Yhc)

I think GHC is right here. See
http://haskell.org/onlinereport/decls.html#instance-decls
esp the bit starting "It is illegal to give a binding..."

Simon

| -----Original Message-----
| From: haskell-cafe-bounces <at> haskell.org [mailto:haskell-cafe-bounces <at> haskell.org] On Behalf Of Neil
| Mitchell
| Sent: 06 July 2008 00:03
| To: Haskell Cafe
| Subject: [Haskell-cafe] Re: Definition of hidden instance members (bug in GHC or Hugs+Yhc)
|
| >  This is either a GHC bug, or a Yhc+Hugs bug - I'm not sure which, but
| >  the compilers disagree:
| >
| >  import Prelude hiding ((==))
| >  data Foo = Foo
| >  instance Eq Foo where
| >     (==) a b = True
|
| I was thinking that GHC's behaviour seems more sensible, but the
| following fails:
|
| import qualified Module as M
|
| instance MClass Foo where
|      M.foo = undefined
|
| M. is not allowed as a prefix of a function, which makes resolving
(Continue reading)

Ross Paterson | 6 Jul 01:10

Re: Definition of hidden instance members (bug in GHC or Hugs+Yhc)

On Sun, Jul 06, 2008 at 12:00:07AM +0100, Neil Mitchell wrote:
> This is either a GHC bug, or a Yhc+Hugs bug - I'm not sure which, but
> the compilers disagree:
> 
> import Prelude hiding ((==))
> data Foo = Foo
> instance Eq Foo where
>     (==) a b = True
> 
> GHC says:
> Temp.hs:14:4: `==' is not a (visible) method of class `Eq'
> 
> Yhc and Hugs both successfully compile the module.
> 
> Does anyone know which compiler(s) are in the wrong, and need bugs filing?

GHC is correct.  Report 4.3.2: "It is illegal to give a binding for a
class method that is not in scope, but the name under which it is in
scope is immaterial; in particular, it may be a qualified name."
In this case neither == nor Prelude.== is in scope.

Gmane