Class Multiplicity

Brian Huffman bhuffman@galois.com
Fri, 17 May 2002 09:31:19 -0700


On Thursday 16 May 2002 11:48 pm, Ashley Yakeley wrote:
> I have a curious Haskell design pattern. It's called "one class per
> function". 
> [...]
> I'm not sure if this is a good thing or a bad thing or what.

You might want to take a look at the class system for the language Concurrent 
Clean. It encourages a "one class per function" setup similar to the one you 
mentioned, but without nearly as much syntax.

The following is quoted from 
http://www.cs.kun.nl/~clean/About_Clean/tutorial/tutorial.html:

In Clean a class is a family of functions with the same name.... As a very 
simple example consider the class of increment functions.

class inc t :: t -> t

This says that the class inc has type variable t. There is only a single 
manipulation function in this class, which is also named inc. The type of 
this increment function is t -> t. Instances of this class for integers and 
reals are defined by:

instance inc Int 
where
    inc i = i+1 

instance inc Real 
where
   inc r = r+1.0

...

- Brian Huffman