[Haskell] Annoying naming clashes

Graham Klyne GK at ninebynine.org
Tue Jun 15 07:05:46 EDT 2004


At 11:30 15/06/04 +0200, Wolfgang Jeltsch wrote:
>I'd say, classes in Haskell are similar to interfaces in Java.

I started my Haskell programming with that viewpoint, but got tripped up by it.

A Java interface can be used as a type in its own right, but a Haskell 
class cannot.  For example, you can't have a list of Eq's, only a list of 
some type that happens to be an Eq.  The different list members can't be 
differently-typed instances of Eq.

To emulate a Java interface, I have ended up creating algebraic data types 
whose components are functions.  (I don't claim that's a good approach to 
Haskell programming, just what I ended up doing.)

#g


------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact



More information about the Haskell mailing list