[nhc-bugs] Instances of qualified imported classes

Ian Lynagh igloo at earth.li
Mon Oct 20 14:58:08 EDT 2003


Hi,

While getting hat to work with ghc6 I've come across the following
issue:

If Bar.hs is this:

-----
module Bar where

class Bar a where
    bar :: a -> Bool
-----

and Foo.hs is this:

-----
module Foo where

import qualified Bar 

data Foo = Foo

instance Bar.Bar Foo where
    bar _ = True
-----

then ghc 6.0.1 is happy enough, but nhc98 v1.16 doesn't like bar being
used unqualified:

$ make clean
rm -f *.o *.hi
$ make ghc
ghc6 -c Bar.hs
ghc6 -c Foo.hs
$ make clean
rm -f *.o *.hi
$ make nhc
nhc98 -c Bar.hs
nhc98 -c Foo.hs
======  Errors when renaming:
The identifier bar instantiated at 9:5 does not belong to this class.
make: *** [nhc] Error 1
$ 

If I qualify bar:

-----
module Foo where

import qualified Bar 

data Foo = Foo

instance Bar.Bar Foo where
    Bar.bar _ = True
-----

then the roles are reversed:

$ make clean
rm -f *.o *.hi
$ make ghc
ghc6 -c Bar.hs
ghc6 -c Foo.hs
Foo.hs:11: Qualified name in function definition: Bar.bar
make: *** [ghc] Error 1
$ make clean
rm -f *.o *.hi
$ make nhc
nhc98 -c Bar.hs
nhc98 -c Foo.hs
$ 

hugs agrees with GHC 6 on both, and the report seems to agree on the
latter (I haven't looked for what it says on the former, but it seems
reasonable behaviour).


Thanks
Ian



More information about the Nhc-bugs mailing list