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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 4AA45BC57 for ; Tue, 16 Nov 2010 12:27:46 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah0BAMv54UzRVdg0kGdsb2JhbACUW414CBUBAQEBCQkMBxEDH6Q7iWKCGIUQLohZAQEDBYVGBIpY X-IronPort-AV: E=Sophos;i="4.59,205,1288566000"; d="scan'208";a="87223519" Received: from mail-qw0-f52.google.com ([209.85.216.52]) by mail1-smtp-roc.national.inria.fr with ESMTP; 16 Nov 2010 12:27:44 +0100 Received: by qwj8 with SMTP id 8so614788qwj.39 for ; Tue, 16 Nov 2010 03:27:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=FNzB6STWfpyrXq+XzGcwQbe13klAG5RCx5UAUNSfhL8=; b=dZ9+v5QrGmkmoxkrke3wFCbZPRiZxC6ynRczEU0ll4MIvCNMUijhXonakOZOdhYRgy ENloQ2eErqDdEhRywvrvYCM1iGpO2vxpMHgrcf6yR5lxq33D4M7VqhMbQTnU0rrThudT IgPXBbSouddh1vHBpANUxokK6zVe0+IcYuIi0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=wyQ+6h4oGyqLYLsI9JkTSysC01ar2oZJjWisY0lcsxhhygAaQYP9KdxS9A/5fqYcAI mvgBWucNKP6VOVpIq5Pg+kocf7IqDp/4y1+NJ1jhcYbbGyt/Z9nEUYdGMpzKHAv+3mnP 5i3nm90JfxtQcV0BejNC0J4oB+x57d7hEiJpg= MIME-Version: 1.0 Received: by 10.229.245.144 with SMTP id lu16mr2504187qcb.44.1289906863496; Tue, 16 Nov 2010 03:27:43 -0800 (PST) Received: by 10.229.215.141 with HTTP; Tue, 16 Nov 2010 03:27:43 -0800 (PST) Date: Tue, 16 Nov 2010 12:27:43 +0100 Message-ID: Subject: Option functions (or lack thereof) + operator for composition From: Serge Le Huitouze To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; lablgtk:01 ocaml:01 haskell:01 ocaml:01 grief:98 sourceforge:01 precedence:01 precedence:01 defines:01 functions:01 functions:01 dependency:01 parentheses:01 match:02 match:02 Hi, While writing a sample program (with lablgtk2), I found a few things annoying and thought I would ask here what you guys think. 1. Option type **************** It seems that there is no predefined function to test an "'a option" for being specifically "None" or "Some _". This seems to be confirmed by the very existence of: http://ocaml-lib.sourceforge.net/doc/Option.html which defines such functions ("is_none" and "is_some"). I found it weird to be forced to use "match" expressions in my code for doing that, e.g.: * let curSelectedRow = ref None in * let updateButtonsStatus () = * button_remove#misc#set_sensitive * (match !curSelectedRow with None -> false | _ -> true) * in * ... I could add the OCaml library mentioned above, but I don't know how to do it (and where to find it) and, since my code is supposed to go into some other code, I'd prefer avoiding adding yet another dependency to it... 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? Thanks for reading. Best regards. --Serge