"cartesian classes"

David Bergman davidb@home.se
Tue, 26 Nov 2002 13:36:01 -0500


(I am having problem with my lovely Outlook program, so here I send it
again, to the whole group; sorry, Frank...)

Frank Atanassow wrote:
=20
> David Bergman wrote (on 26-11-02 01:29 -0500):
>> I would like to know if anyone (maybe Mark P) knows the status of=20
>> "Cartesian classes" in different Haskell implementations. I.e., does=20
>> anyone implement the suggested functional dependencies or the less=20
>> general parameterized type classes?
>>=20
>> I have need for the multi-variable classes quite often (especially in

>> a genetic algorithm framework I am building in Haskell). Although I=20
>> would hesitate to extend beyond Haskell 98, if there exist a common=20
>> view on how to best implement Cartesian classes (read "it will be=20
>> part of Haskell 2") and/or a stable implementation for it, I am=20
>> willing to be a bit adventurous...

> What do you mean by "cartesian classes"? Do you mean multi-parameter=20
> type classes?

> They're supported by GHC and Hugs, but not NHC98 or HBC. The same goes

> for functional dependencies.

Yes, I meant what is commonly known as multi-parameter type classes,
although that name IMHO does not make much sense, since only the
explicitly parameterized type class should qualify as a any-parameter
type class, with the (non-Haskell syntax) "b in C a", where "a" is the
parameter, "C a" the resulting type class, and, finally, "b" the (type)
element of the class.

Side note: functional dependencies would, admittedly, produce parameters
for classes, but only implicitly so.

In a regular class declaration, "C a", I would argue that "C" is the
class, not being single-parameter, but zero-parameter. It is sometimes
unfortunate that the syntax of Haskell makes this look like a
constructor...

What I meant by cartesian is that using several variables, you would get
(also in non-Haskell syntax) "(a, b, c) in C", i.e., the class actually
being a subclass of the third cartesian power of the universal
(implicit) type class.

If both GHC and Hugs support functional dependencies, I would probably
dare to wander off into the mysterious land of Haskell 2.

A very concrete, but na=EFve, question: what is the syntax for defining
functional dependencies in Hugs and GHC? Since Mark Jones' syntax was
abstract in his paper, it is kind of hard to deduce an ASCII equivalence
(I have tried to figure out how to create a curly arrow from the
keyboard ;-)

Thanks,

David