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 6B6EBBC57 for ; Tue, 16 Nov 2010 12:43:34 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.59,205,1288566000"; d="scan'208";a="78203278" Received: from saorge.inria.fr (HELO [138.96.248.57]) ([138.96.248.57]) by mail4-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-CAMELLIA256-SHA; 16 Nov 2010 12:43:34 +0100 Subject: Re: [Caml-list] Option functions (or lack thereof) + operator for composition From: Thomas Gazagnaire To: Serge Le Huitouze Cc: caml-list@yquem.inria.fr In-Reply-To: <1853021343.44703.1289906871683.JavaMail.root@zmbs4.inria.fr> References: <1853021343.44703.1289906871683.JavaMail.root@zmbs4.inria.fr> Content-Type: text/plain; charset="UTF-8" Date: Tue, 16 Nov 2010 12:43:30 +0100 Message-ID: <1289907810.2954.148.camel@saorge.inria.fr> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; haskell:01 caml-list:01 functions:01 functions:01 define:02 define:02 expression:02 match:02 match:02 let:03 let:03 expressions:04 misc:06 inria:06 trick:06 Hi, > 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 > * ... > You are not forced to use match expression, you can just define : let is_none x = match x with None -> true | Some _ -> false and is_some x = not (is_none x) and then use these functions in your code ... > In Haskell, I would write "ignore $ f x y", which I find much lighter weight. Just define: let ($) f x = f x and that should do the trick Thomas