From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id B60F1BBAF for ; Sun, 8 Aug 2010 23:47:42 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AisCACvDXkzRVdg0kGdsb2JhbACgPAgVAQEBAQkJDAcRAx+nNYkQghGEfC6IVAEBAwWFNQSJO4gI X-IronPort-AV: E=Sophos;i="4.55,338,1278280800"; d="scan'208";a="67403263" Received: from mail-qw0-f52.google.com ([209.85.216.52]) by mail4-smtp-sop.national.inria.fr with ESMTP; 08 Aug 2010 23:47:42 +0200 Received: by qwf7 with SMTP id 7so7980220qwf.39 for ; Sun, 08 Aug 2010 14:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:sender:received :in-reply-to:references:from:date:x-google-sender-auth:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=z07xYnn/qVSxpgZQpBxRX9bQOs/6KV+ZRkifhHaOwZQ=; b=pPhr31hOskx8s2E1hamJC39vIs1TMb053B1UFfkCA1vVUolbo+UQsUM83emQAcFWVK Pm4swTD/wD/bjC2OW8HRP43HJVfc0/s/Fucs2cp6rBM17VdZTNuqdpTNrZ0dMSnaiNZv MYG3eielYgICeea8OfyJe4gSq5yR/jjehtSYs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; b=TN5i8s/55hcfOd4k37kl3k1aXMhhn1cv+u3uqAegzbP9DC9qyB2nT6E6M/QiiHGBXn LnD7/evwhRMLFMM1oHW06n/B7YG5RE3V4XXIAx40Pn3qqJDFs/SCllXNhEJQpQpDPQnz R+K7kQTVZ3nxX05gOFU6oozRS3TQsA8AjfM20= Received: by 10.224.112.209 with SMTP id x17mr7959945qap.304.1281304061108; Sun, 08 Aug 2010 14:47:41 -0700 (PDT) MIME-Version: 1.0 Sender: gabriel.scherer@gmail.com Received: by 10.229.46.204 with HTTP; Sun, 8 Aug 2010 14:47:20 -0700 (PDT) In-Reply-To: References: <877hk1m1df.fsf@mid.deneb.enyo.de> <87bp9dkkca.fsf@mid.deneb.enyo.de> <4c5f194e.8644d80a.7fef.69e6@mx.google.com> From: bluestorm Date: Sun, 8 Aug 2010 23:47:20 +0200 X-Google-Sender-Auth: 7XBJR4H9qW8OIGrg3mpJbfpEHP8 Message-ID: Subject: Re: [Caml-list] interest in a much simpler, but modern, Caml? To: Jeremy Bem Cc: Nicolas Pouillard , caml-list List , Florian Weimer Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; notation:01 ocaml:01 infix:01 val:01 bool:01 infix:01 haskell:01 polluting:01 submodule:01 unqualified:98 equality:01 polymorphic:01 char:01 char:01 syntactic:01 >> > > Is there a better approach to polymorphic equality floating around? >> > >> > Besides type classes? =A0I'm not sure. =A0It's probably possible to re= move >> > this feature from the language, with a little bit of syntactic >> > overhead to pass around a matching comparison function. >> >> Yes for instance the very concise local opening notation comes in handy >> here: >> >> if Int.(x =3D 42) then ... else ... > > That's very nice. =A0I don't think type classes are conservative enough f= or > this project, but this comes very close indeed. > I haven't really had a chance to explore OCaml 3.12 yet, as it came out > while I was working on this, but I will give this serious consideration. This approach is very nice indeed, but to make it practical you have to have one of the two following features : - a more restricted form of "open" statement that does not blindly import *all* the module values - nested modules If you don't have any of these, you have to declare infix operators directly inside the module. You'd have a "val (=3D) : int -> int -> bool" in the "int.ml" file for example. That's notoriously painful to handle if you use the "open" statement : a bunch of "open" statements in a non-careful order and your infix operators become unusable because you don't know anymore where they come from. What you really need is some form of "explicit open", =E0 la Python or Haskell, such as "from Int import (mod, of_char, to_char)" instead of the full open : only a few identifiers are unqualified, and you still use Int.(=3D), Int.(+) instead of polluting the global namespace. The other way to solve the problem is to put the dangerous infix operators into a submodule, eg. Infix or Ops. You have a Int module with int-specific functions that are not likely to silently conflict with values of other modules, and an Int.Infix module meant to be used in that "local open" form : Int.Infix(x + 1 =3D 2).