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 SAA06753; Tue, 24 Aug 2004 18:31:15 +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 SAA07398 for ; Tue, 24 Aug 2004 18:31:14 +0200 (MET DST) Received: from us19.unix.fas.harvard.edu (us19.unix.fas.harvard.edu [140.247.35.199]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i7OGVDRM015907 for ; Tue, 24 Aug 2004 18:31:13 +0200 Received: from ls01.fas.harvard.edu (ls01.fas.harvard.edu [140.247.34.101]) by us19.unix.fas.harvard.edu (8.12.11/8.12.11) with ESMTP id i7OGVCse025572 for ; Tue, 24 Aug 2004 12:31:12 -0400 Received: by ls01.fas.harvard.edu (Postfix, from userid 19885) id E5B741C004; Tue, 24 Aug 2004 12:31:07 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by ls01.fas.harvard.edu (Postfix) with ESMTP id DE95324024 for ; Tue, 24 Aug 2004 12:31:07 -0400 (EDT) Date: Tue, 24 Aug 2004 12:31:07 -0400 (EDT) From: Michael Alexander Hamburg Cc: caml-list@pauillac.inria.fr Subject: Re: [Caml-list] Re: Correct locations for macro camlp4 extensions In-Reply-To: Message-ID: References: <1093281685.412a2795efb43@webmail.fas.harvard.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 412B6D51.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 camlp:01 haskell:01 camlp:01 parentheses:01 expr:01 expr:01 haskell:01 tweaked:01 alexander:01 o'caml:02 wrote:03 infix:03 emulate:03 snip:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, 24 Aug 2004, Jan Kybic wrote: > > Which Haskell operator features does this emulate? I know you can make an > > operator without any camlp4 that does right-associative application, basically > > What I had in mind is function decomposition '.', you write > > ( f . g . h ) x instead of h ( g ( f x ) ) > > The other operator is '$': > > f $ g $ h x instead of f ( g ( h x ) ) > > both can save a lot of parentheses. > ... snip ... > (* infix operator $, functional composition *) > expr: AFTER "apply" > [[ f = expr; "$"; g = expr -> <:expr< fun x -> $f$ ($g$ x) >> ]]; > > I don't think this is what you want. The Haskell $ is a regular right-associative operator; in particluar, it will treat f $ g x y as f (g x y) whereas this code will treat it as f (g x) y You can do it the Haskell way in O'Caml too, you would just have to make $ right-associative, which shoulndn't be so hard (I think the example for o can be tweaked to do it). Mike ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners