
27 Feb
2007
27 Feb
'07
3:32 p.m.
When you type "class Foo" in Java or C++, it does three things:
1. It declares a new type called "Foo".
2. It declares a _set_ of types (i.e. a "class").
3. It declares that the type Foo (and all of its subtypes) is a member of the set of types Foo.
I would add: 4. Define a namespace, also called "Foo", for a set of values (and probably nested classes).
In Haskell, these three operations are distinct.
1. You declare a new type using "data" or "newtype".
2. You declare a new set of types using "class".
3. You declare that a type is a member of a class using "instance".
4. You define a new namespace using "module". Cheers, - Andreas -- Andreas Rossberg, rossberg@ps.uni-sb.de