From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA23063; Thu, 26 Apr 2001 02:57:53 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA22983 for ; Thu, 26 Apr 2001 02:57:52 +0200 (MET DST) Received: from shell5.ba.best.com (shell5.ba.best.com [206.184.139.136]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f3Q0voX05055 for ; Thu, 26 Apr 2001 02:57:50 +0200 (MET DST) Received: from localhost (bpr@localhost) by shell5.ba.best.com (8.9.3/8.9.2/best.sh) with ESMTP id RAA04958; Wed, 25 Apr 2001 17:57:49 -0700 (PDT) Date: Wed, 25 Apr 2001 17:57:49 -0700 (PDT) From: Brian Rogoff To: Charles Martin cc: caml-list@inria.fr Subject: Re: [Caml-list] operators: compose and Haskell's $ operator In-Reply-To: <5.0.2.1.0.20010425164708.021928c0@chasm.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 25 Apr 2001, Charles Martin wrote: > Does someone out there have an out-of-the box solution for adding > composition and an equivalent for Haskell's $ operator to OCaml? > > I've been using let (<<) f g x = f (g x) for composition, but an You should be warned that that doesn't mix nicely with CamlP4's quotation syntax. >equivalent for the $ operator eludes me, as it needs to be right >associative and of low precedence. Maybe <->? Let's test it # let ( <-> ) f x = f x;; val ( <-> ) : ('a -> 'b) -> 'a -> 'b = # (fun x -> x + 1) <-> (5 / 2) + 3;; - : int = 6 # (fun x -> x + 1) <-> (5 / 2) * 3;; - : int = 7 > Maybe someone with some Haskell envy has figured something out using > camlp4? I admit I have a little Haskell envy (type classes and the `infix` syntax :), but I can probably live with some parentheses ... -- Brian ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr