From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id CD1D8BC57 for ; Tue, 16 Nov 2010 15:27:05 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsEFAIIj4kyty1O7/2dsb2JhbACUX44Acb53hUsEhFqJCho X-IronPort-AV: E=Sophos;i="4.59,206,1288566000"; d="scan'208";a="78349800" Received: from elehack.net ([173.203.83.187]) by mail4-smtp-sop.national.inria.fr with ESMTP; 16 Nov 2010 15:26:55 +0100 Received: from [192.168.42.103] (unknown [68.168.162.166]) by elehack.net (Postfix) with ESMTPSA id 3BC5EC860A for ; Tue, 16 Nov 2010 08:26:51 -0600 (CST) Message-ID: <4CE294A1.5050100@elehack.net> Date: Tue, 16 Nov 2010 08:26:41 -0600 From: Michael Ekstrand User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Lightning/1.0b2 Thunderbird/3.1.6 MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Option functions (or lack thereof) + operator for composition References: In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; haskell:01 ocaml:01 grief:98 wrote:01 precedence:01 precedence:01 defines:01 dmitry:01 caml-list:01 functions:01 parentheses:01 override:03 warnings:03 cleanup:04 serge:05 On 11/16/2010 05:27 AM, Serge Le Huitouze wrote: > 2. Operator for composition (and its precedence) > ******************************************************** > To get rid of many warnings, I wrapped some calls (the "connect" calls of > my widgets) into "ignore (f x y)" statements. > I've no particular grief in using "ignore", but I find the parentheses > *really* annoying. > > In Haskell, I would write "ignore $ f x y", which I find much lighter weight. > > I'm not familiar with operators and their precedence, but I wonder: is it > possible to do something similar with OCaml? Batteries provides operators for things like this. It defines the '**>' operator for function application; it's an odd name, but it has the right associativity. As Dmitry mentioned, some override (&). Batteries also provides composition operators |- and -|, and a pipeline operator |> (opposite of **>). With that operator, you can write: f x y |> ignore thereby putting the emphasis on "f x y" and relegating "ignore" to a cleanup at the end. - Michael