From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 45A38BBAF for ; Mon, 9 Aug 2010 01:29:44 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgEDAGDaXkzRVdY0kGdsb2JhbACYNIgICBUBAQEBCQkMBxEDH6gfiRCCEYR5LohUAQEDBYU1BIk7 X-IronPort-AV: E=Sophos;i="4.55,339,1278280800"; d="scan'208";a="65169034" Received: from mail-bw0-f52.google.com ([209.85.214.52]) by mail1-smtp-roc.national.inria.fr with ESMTP; 09 Aug 2010 01:29:43 +0200 Received: by bwz17 with SMTP id 17so1119906bwz.39 for ; Sun, 08 Aug 2010 16:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=KqjpQwIblOw4KrwDniojWruGz4euyyPF6Cd+4ySALDY=; b=KK+U/OYT2A5QKCvml510RlwtNuB6T1pSVvfuvEM0y3GhoQXqU04i/bum528lTC5cq2 v5/B2cYZhBAl7Exo0VAhVUo6jxaGyR0ZFi9VavgFd9UjYM5F9eOJCU7n2nyHs5c2qhnq wiIMzkF0JCQhBoDOM/TxSISpPlf2WvSXMtGA0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=x0/uTwAsWdDWtWJRlBXHTGbya6p/tqR6q0jg/7vR4kF9+LKynw4Ix67hgeKvtfkSJr tBosUWAoE/D9ViovwY0oPtFmqUgWHx+HLftnSuuMI2UJi6AXj7vMu4JcEVkt7cfGPgtq DCBmVCjm59gZjqdrbQdfSDhoqfYb9czV3vGxc= MIME-Version: 1.0 Received: by 10.204.160.146 with SMTP id n18mr2437088bkx.116.1281310182863; Sun, 08 Aug 2010 16:29:42 -0700 (PDT) Received: by 10.204.54.68 with HTTP; Sun, 8 Aug 2010 16:29:42 -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> Date: Sun, 8 Aug 2010 19:29:42 -0400 Message-ID: Subject: Re: [Caml-list] interest in a much simpler, but modern, Caml? From: Jeremy Bem To: bluestorm Cc: Nicolas Pouillard , caml-list List , Florian Weimer Content-Type: multipart/alternative; boundary=0015175cd4504bf391048d5846c1 X-Spam: no; 0.00; notation:01 ocaml:01 infix:01 val:01 bool:01 infix:01 haskell:01 polluting:01 iter:01 notation:01 ocaml:01 haskell:01 polluting:01 unqualified:98 unqualified:98 --0015175cd4504bf391048d5846c1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Sun, Aug 8, 2010 at 5:47 PM, bluestorm wrote: > >> > > Is there a better approach to polymorphic equality floating around= ? > >> > > >> > Besides type classes? I'm not sure. It's probably possible to remo= ve > >> > 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 hand= y > >> here: > >> > >> if Int.(x =3D 42) then ... else ... > > > > That's very nice. I 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. > I don't believe there is really any issue here. Certain modules are simply not intended to opened to be opened globally. This is already the case: witness the many standard library modules that define "length", "map", "iter", etc. -Jeremy --0015175cd4504bf391048d5846c1 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Sun, Aug 8, 2010 at 5:47 PM, bluestor= m <bluesto= rm.dylc@gmail.com> wrote:
>> > > Is there a better approach to polymorp= hic equality floating around?
>> >
>> > Besides type classes? =A0I'm not sure. =A0It's probab= ly possible to remove
>> > this feature from the language, with a little bit of syntacti= c
>> > 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 conservati= ve enough for
> this project, but this comes very close indeed.
> I haven't really had a chance to explore OCaml 3.12 yet, as it cam= e out
> while I was working on this, but I will give this serious consideratio= n.

This approach is very nice indeed, but to make it practical you have<= br> to have one of the two following features :
- a more restricted form of "open" statement that does not blindl= y
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 -> in= t ->
bool" in the "int.ml<= /a>" file for example. That's notoriously painful to
handle if you use the "open" statement : a bunch of "open&qu= ot; 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, s= uch as
"from Int import (mod, of_char, to_char)" instead of the full ope= n :
only a few identifiers are unqualified, and you still use Int.(=3D),
Int.(+) instead of polluting the global namespace.

-Jeremy

--0015175cd4504bf391048d5846c1--