From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id D5DB4BB84 for ; Thu, 15 Jan 2009 13:13:36 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAFi3bkmCNhAB/2dsb2JhbADPCIVu X-IronPort-AV: E=Sophos;i="4.37,269,1231110000"; d="scan'208";a="22518716" Received: from kurims.kurims.kyoto-u.ac.jp ([130.54.16.1]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 15 Jan 2009 13:13:35 +0100 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.8/8.13.8) with ESMTP id n0FCDKBQ020384; Thu, 15 Jan 2009 21:13:21 +0900 (JST) Date: Thu, 15 Jan 2009 21:13:35 +0900 (JST) Message-Id: <20090115.211335.27794984.garrigue@math.nagoya-u.ac.jp> To: dra-news@metastack.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] What is a future of ocaml? From: Jacques Garrigue In-Reply-To: <001801c9765e$4fabc3b0$ef034b10$@com> References: <1231924711.2711.11.camel@serphost.localdomain> <496DEC48.7000906@wp.pl> <001801c9765e$4fabc3b0$ef034b10$@com> X-Mailer: Mew version 5.2 on Emacs 22.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 ocaml:01 inference:01 annotations:01 variants:01 annotations:01 haskell:01 variants:01 principality:01 -principal:01 recovers:01 principality:01 functors:01 trivial:01 polymorphic:01 From: "David Allsopp" > Dawid Toton wrote: > > Could anybody explain why it's impossible to have type classes in OCaml? > > I don't think it's impossible - but I believe that if you introduce type > classes then you "damage" Hindley-Milner type inference and you can no > longer derive a principal typing for an arbitrary ML expression without > resorting to type annotations. Whether this is a problem or not is a matter > of taste - but it does make the language harder to call "ML" if you lose one > of its central features! That said, there are of course two big features > (objects and polymorphic variants) in OCaml already which do require > annotations. The reason is mostly wrong :-) One can have both type classes and principal types; the problem with principal types in Haskell is more subtle thant that. And neither polymorphic variants nor object require type anotations in ocaml; they just make it much more painful to understand error messages. Principality is only broken by optional arguments and polymorphic methods, and there is a -principal flag that recovers some form of principality (requiring type annotations). This said, type classes have a lot of common features with modules or objects, so this would be yet another way to do some similar things. More problematic, type classes depend on the nominality of the type systems, while ocaml has a rich language of structural types. For instance, it is not completely clear how one could select instances of type classes for polymorphic variants, without introducing conflicts. I'm afraid the combination of type classes with modules and functors is not trivial either. Jacques Garrigue