Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Alternative to Haskell type classes?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: [Caml-list] Alternative to Haskell type classes?
Hi,

I'm just curious about OCaml's stance on Haskell's type classes, and
also whether there are alternative ways of achieving the same thing in
OCaml.

There are some damn useful small things that Haskell's type classes
can do, that I find interesting.

First is Show, like the base method toString in Java, etc. The other
is Enum which lets you convert an enum type to an int, and back again.

I've heard comments on it before for the Num type class, saying how it
hurts performance .. why can't the compiler specialise uses of type
classes so that such overhead is eliminated? They're just overloaded
functions, whose type for each individual invocation is completely
known I believe.

Jonathan