From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 41547BB81 for ; Fri, 2 Dec 2005 01:12:12 +0100 (CET) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.201]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jB20CBo1019421 for ; Fri, 2 Dec 2005 01:12:11 +0100 Received: by zproxy.gmail.com with SMTP id j2so181818nzf for ; Thu, 01 Dec 2005 16:12:11 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=qZYULV1oNvUBsNyJoyYH4Eq7UAOK7v33NNjNVBlwlr5QyCTzWroOUjRHVYVQrnIu7NBNTayYheFQkI9pNT5hDBjfpwXcbPKCZKkZFcypkGyD8EhxCwIlagNGoqAv/qH7Upka3a2DHCKuUoQjQwyMsduqpev/+QNRk0tqgqyoA+g= Received: by 10.64.150.8 with SMTP id x8mr1220094qbd; Thu, 01 Dec 2005 16:12:07 -0800 (PST) Received: by 10.65.35.10 with HTTP; Thu, 1 Dec 2005 16:12:07 -0800 (PST) Message-ID: Date: Fri, 2 Dec 2005 13:12:07 +1300 From: Jonathan Roewen To: caml-list@yquem.inria.fr Subject: [Caml-list] Alternative to Haskell type classes? MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Miltered: at nez-perce with ID 438F915B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 haskell:01 ocaml's:01 haskell's:01 ocaml:01 haskell's:01 enum:01 enum:01 compiler:01 invocation:01 functions:01 int:01 overhead:03 uses:06 classes:06 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 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