Haskell naming conventions

Lennart Augustsson lennart at augustsson.net
Fri Dec 26 02:12:14 EST 2003


Sean L. Palmer wrote:

> class Eq a where
>         (==) :: a -> a -> Bool
>  
> That actually declares a /type class/, not a class.  So why the use of 
> the keyword class?  Is it done merely to confuse C++ and Java 
> programmers?  The concept of type class in Haskell apparently roughly 
> corresponds to the concept of "interface" in Java.  So why not call it 
> interface? 
>  
According to dictionary.com one of the definitions of the word class is:

   A set, collection, group, or configuration containing members regarded
   as having certain attributes or traits in common; a kind or category.

And what the members of class Eq have in common is that they have a
function (==).  So to me it seems that the word "class" is very well
chosen; it describes what's going on.

Now, I admit that if you think you can take concepts with similar names
from other programming languages and apply them to Haskell you might
get confused.  You might come across what is called "false friends" in
natural language, i.e., words that look the same but mean different
things.

	-- Lennart



More information about the Haskell mailing list