[Haskell-cafe] Trouble with record syntax and classes

Andreas Rossberg rossberg at ps.uni-sb.de
Tue Feb 27 10:32:31 EST 2007


<ajb at spamcop.net> wrote:
>
> 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 at ps.uni-sb.de


More information about the Haskell-Cafe mailing list