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 48212BC57 for ; Tue, 16 Nov 2010 14:53:06 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AncCABIb4kzRVditkGdsb2JhbACiVwgVAQEBAQkJDAcRAx+kPolighiFFC6IWQEBAwWFRgSKWIsX X-IronPort-AV: E=Sophos;i="4.59,206,1288566000"; d="scan'208";a="78319781" Received: from mail-qy0-f173.google.com ([209.85.216.173]) by mail4-smtp-sop.national.inria.fr with ESMTP; 16 Nov 2010 14:53:01 +0100 Received: by qyl33 with SMTP id 33so5013096qyl.18 for ; Tue, 16 Nov 2010 05:53:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=70d8fMQPDzmyjbErRm24hlmX6eASjUxUM5sRBP1i9fw=; b=eH7Qdv2JkqQHpD+efaSPhN7f3olPR/bC1ebUgRIk75c4TaOGXvlnvitrQkeqG2gZYx EF8ARKU0uakz+kMKJH7HnG1G/yZovYgY7K1XFdAZccNEuBg0XPb1mUxjlIINxW0GNTea EuxiZdTH63WLZeGohXCMFmuAtdpLira4x7PDk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=Ws+BW4SWdHrFCjyqWXQE/Yzx2AjKaM8CfWBkSxxTNTfEq3PEaGojIPpXA0xyyas3gy c1YaUwAKG6Yf8aSKPM71+yTKpnqcZRYZBlT10h1DhwpiOxBcXZP2h7bqkIyFDD3qyIw1 W0xCrkSWC3Lta7Qmg3WLr2mJgc8S/IHPGfubU= MIME-Version: 1.0 Received: by 10.229.214.76 with SMTP id gz12mr6319156qcb.196.1289915580021; Tue, 16 Nov 2010 05:53:00 -0800 (PST) Received: by 10.229.215.141 with HTTP; Tue, 16 Nov 2010 05:52:59 -0800 (PST) In-Reply-To: <97D1DAE6-9E21-4A87-87FC-72B3BCF2F071@gmail.com> References: <97D1DAE6-9E21-4A87-87FC-72B3BCF2F071@gmail.com> Date: Tue, 16 Nov 2010 14:52:59 +0100 Message-ID: Subject: Re: [Caml-list] Option functions (or lack thereof) + operator for composition From: Serge Le Huitouze To: caml-list@yquem.inria.fr, Jacques Garrigue Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; val:01 val:01 ocaml's:01 lablgtk:01 restricting:01 lablgtk:01 precedence:01 naming:01 caml-list:01 functions:01 int:01 int:01 variables:02 warnings:03 warnings:03 >> To get rid of many warnings, I wrapped some calls (the "connect" calls of >> my widgets) into "ignore (f x y)" statements. > > You can, but unfortunately $ does not have the right associativity. > > # let ($) f x = f x;; > val ( $ ) : ('a -> 'b) -> 'a -> 'b = > # ignore $ 1+1;; > - : unit = () > # succ $ succ 3;; > - : int = 5 > # succ $ succ $ succ 3;; > > If you want the compositionality, you can use something starting with @: > > # let (@@) f x = f x;; > val ( @@ ) : ('a -> 'b) -> 'a -> 'b = > # succ @@ succ @@ succ 3;; > - : int = 6 > Wow, tricky! Not as tricky as Perl naming scheme for variables, but still tricky! ;-) So I have to learn the precedence and associaticity table in section 6.7 of OCaml's reference manual!!! > Note however that there is a simpler way to circumvent the problem: > use the "-w s" option on the command line, disabling the statement warning. > All my lablgtk code uses this flag :-) Warnings should be gotten rid of, so I don't like the idea of making them silent. But restricting silence to the statement warning is probably OK. And I'll take your words for it, since, obviously, you have more experience with lablgtk than myself! ;-) But, on the other hand, maybe you can harmlessly use "-w s", whereas it may bite me, given my poor understanding of this stuff... Thanks. --Serge