[Haskell-cafe] typeclass namespace rational?

Jonathan Geddes geddes.jonathan at gmail.com
Mon Nov 15 22:31:28 EST 2010


cafe,

Data Constructors and Type Constructors don't share the same
namespace. You see code like the following all the time:

> data MyRecord = MyRecord {...}

This is possible because Data Constructors are used in different parts
of the code than Type Constructors so there's never any ambiguity.

Type Classes, on the other hand, share the same namespace as Type
Constructors. You can't define this:

>class String s where
>    ...
>
>instance String String where
>    ...
>instance String ByteString where
>   ...
>instance String Text where
>   ...

Not that I'm running out of valid haskell identifiers or anything :P,
I'm just wondering: what's the rationale behind keeping Type Classes
and Type Constructors in the same namespace? I can't think of any
ambiguity there would be if they each had their own namespace. And In
some cases it would be convenient to be able to define both a concrete
representation and an abstract one with the same name as in the String
class example above.

--Jonathan


More information about the Haskell-Cafe mailing list