Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding GHC error "Qualified name in binding position"

If I create a module AModule with a typeclass Foo,

module AModule where
class Foo a where
   bar :: a

and in another module BModule import AModule qualified and try to make some type an instance of Foo, i.e.

module B where
import qualified AModule as A
instance A.Foo Int where
   A.bar = 0

GHC tells me "Qualified name in binding position: A.bar".

From what I understand, this is related to GHC ticket 3197, which is labeled as fixed. I'm running GHC 6.12.1 and am still getting the error. Am I just misunderstanding something here?

like image 302
gspr Avatar asked Oct 25 '10 09:10

gspr


1 Answers

You don't need the A. inside the instance declaration (See Haskell 98 report §4.3.2).

The following compiles on 6.12.3:

instance A.Foo Int where    -- # A. here
   bar = 0                  -- # no A. here

main = print (A.bar :: Int) -- # A. here
like image 63
kennytm Avatar answered Nov 04 '22 02:11

kennytm