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 DAA01921; Tue, 6 Apr 2004 03:08:02 +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 DAA01899 for ; Tue, 6 Apr 2004 03:07:59 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3617uYM031915 for ; Tue, 6 Apr 2004 03:07:57 +0200 Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id KAA04553; Tue, 6 Apr 2004 10:07:51 +0900 (JST) To: ker527mail@yahoo.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] failwith, raise and type inference In-Reply-To: <20040405225238.33087.qmail@web40613.mail.yahoo.com> References: <200404022028.WAA20083@pauillac.inria.fr> <20040405225238.33087.qmail@web40613.mail.yahoo.com> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20040406100751U.garrigue@kurims.kyoto-u.ac.jp> Date: Tue, 06 Apr 2004 10:07:51 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 failwith:01 inference:01 jacques:01 haskell's:01 failwith:01 foo:01 haskell's:01 foo:01 precedences:01 jacques:01 ocaml:01 caml:01 garrigue:01 garrigue:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 55 From: Ker Lutyn > I wonder if we could have Haskell's $ operator added to OCaml. It would make > this idiom and a lot of my code nicer. > > failwith $ "foo" ^ "bar" > > Defining it myself as > > let ($) f x = f x > > doesn't work because of precedence and associativity. The caml sources > frequently define > > let (++) x f = f x > > which is a similar idea - but lots of times Haskell's $ is what you want. This doesn't look very much related to the original thread. But you just have to find an operator with the right associativity. let (@<) f x = f x ;; print_string @< String.capitalize @< "foo" ^ "bar" ;; Since the first character decides the associativity, you might also choose @@, @>, or anything you like. ^^, ^@, ... would have the same associativity and precedence also. Look at section 6.7 of the manual for infix operators and their precedences. Jacques Garrigue ------------------- 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