[Haskell] Separate Namespaces and Type Classes

S.M.Kahrs S.M.Kahrs at kent.ac.uk
Thu Jul 8 07:48:51 EDT 2004


> one should be able to define two instances having the same signature, as 
> long as they are in different namespaces
[snip]
> But now, ghc complains about two instances of Foo Integer, although 
> there should be none in the namespace main.

It's a Haskell problem, not a ghc one.

Class instances are not constrained by module boundaries.
Other people have found this to be a problem,
e.g. in combination with tools like Strafunski - you just
cannot encapsulate a class instance in a module.

It's a design flaw in Haskell.

> I have not found any documentation on why ghc behaves like this and 
> whether this conforms to the haskell language specification.
> Is there any haskell compiler out there that is able to compile the 
> above example?

I think Clean (a very similar language) permits to limit the scope
of class instances.

Stefan


More information about the Haskell mailing list