[Haskell-cafe] namespaces for values, types, and classes

Duncan Coutts duncan.coutts at googlemail.com
Sat Nov 28 15:42:25 EST 2009

On Fri, 2009-11-27 at 11:07 +0100, Sebastian Fischer wrote:

> We cannot write
>       class Name a where ...
>       instance Name Name where ...

Yes! Very annoying.

I want to be able to make a type that is the most general instance of a
single-parameter type class. This is a useful OOish thing to do.

For example:

class Compiler c where
  getInstalledPackages :: c -> ...
  compileModule        :: c -> ...

instance Compiler GHC where ...
instance Compiler NHC where ...

and sometimes I want a list of compilers...

newtype Compiler where
    Compiler :: Compiler c => c -> Compiler
  deriving Compiler

compilers :: [Compiler]
compilers = [Compiler ghc, Compiler nhc]

> Does anyone know why types and values are in separate namespaces but  
> classes and types are not?

I think it's because you cannot currently distinguish them in module


More information about the Haskell-Cafe mailing list