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=1.5 required=5.0 tests=AWL,NO_REAL_NAME,SPF_FAIL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 7B15DBC68 for ; Tue, 14 Nov 2006 05:30:14 +0100 (CET) Received: from selenite.metnet.navy.mil (selenite.metnet.navy.mil [192.16.167.32]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kAE4U6Z0016338 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 14 Nov 2006 05:30:13 +0100 Received: (qmail 24170 invoked by uid 107); 14 Nov 2006 04:30:03 -0000 Received: from unknown (HELO Adric.metnet.fnmoc.navy.mil) (10.100.105.102) by selenite.metnet.navy.mil with SMTP; 14 Nov 2006 04:30:03 -0000 Received: by Adric.metnet.fnmoc.navy.mil (Postfix, from userid 760) id BD07FAC04; Mon, 13 Nov 2006 20:29:39 -0800 (PST) To: caml-list@inria.fr Subject: Re: Simple idea for making a function infix Reply-To: oleg@pobox.com Errors-To: oleg@okmij.org From: oleg@pobox.com Message-Id: <20061114042939.BD07FAC04@Adric.metnet.fnmoc.navy.mil> Date: Mon, 13 Nov 2006 20:29:39 -0800 (PST) X-Miltered: at discorde with ID 4559464E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; infix:01 oleg:01 haskell's:01 notation:01 infix:01 syntax:01 haskell:01 haskell:01 ocaml:01 ocaml:01 val:01 char:01 char:01 functions:01 int:01 Haskell's back-quote notation has a notable limitation as it applies to identifiers only. That is, we gain infix identifiers rather than infix expressions. As it turns out, we can obtain infix expressions without any change of syntax or any backticks: http://www.haskell.org/pipermail/haskell-prime/2006-March/000935.html http://www.haskell.org/haskellwiki/Infix_expressions It seems that the second solution of the above page is similar to the one just proposed for OCaml. For ease of comparison, in Haskell, ($) is defined as [x $ y = x y] and flip flips the order of the arguments. The first solution on that page can be rendered in Ocaml as follows: let (>--) x y = (x,y);; let (<--) (x,f) y = f x y;; Now we can write # 3 >-- min <-- 4;; - : int = 3 We gain not only infix identifiers but infix expressions as well: let a = Array.make 3 'a';; val a : char array = [|'a'; 'a'; 'a'|] 1 >-- Array.set a <-- 'b'; a;; - : char array = [|'a'; 'b'; 'a'|] so we can use even three-argument functions as sort of `infix'...