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 38A35BC57 for ; Tue, 16 Nov 2010 18:44:32 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvwAADZR4kxCbwQZkWdsb2JhbACUX44AFQEBAQEHDQoHEQQewB6FSwSEWokK X-IronPort-AV: E=Sophos;i="4.59,206,1288566000"; d="scan'208";a="78536927" Received: from out1.smtp.messagingengine.com ([66.111.4.25]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 16 Nov 2010 18:44:29 +0100 Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.messagingengine.com (Postfix) with ESMTP id 477B7415 for ; Tue, 16 Nov 2010 12:44:26 -0500 (EST) Received: from frontend2.messagingengine.com ([10.202.2.161]) by compute3.internal (MEProxy); Tue, 16 Nov 2010 12:44:26 -0500 X-Sasl-enc: pu4v4ifbBHN3mT1pNXG5/1EJg88r4/8gw3mH3BrQ2Je9 1289929466 Received: from [192.168.1.206] (64-71-1-165.static.wiline.com [64.71.1.165]) by mail.messagingengine.com (Postfix) with ESMTPSA id ED17F5E7636 for ; Tue, 16 Nov 2010 12:44:25 -0500 (EST) Message-ID: <4CE2C34E.7030407@ens-lyon.org> Date: Tue, 16 Nov 2010 09:45:50 -0800 From: Martin Jambon User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20101023 Lightning/1.0b3pre Thunderbird/3.1.3 MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Option functions (or lack thereof) + operator for composition References: <1853021343.44703.1289906871683.JavaMail.root@zmbs4.inria.fr> <1289907810.2954.148.camel@saorge.inria.fr> <20101116115115.GA4149@rhodium.pps.jussieu.fr> In-Reply-To: <20101116115115.GA4149@rhodium.pps.jussieu.fr> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ens-lyon:01 0100,:01 trivial:01 trivial:01 wrote:01 wrote:01 caml-list:01 functions:01 functions:01 jambon:01 jambon:01 define:02 expression:02 match:02 match:02 On 11/16/10 03:51, Gabriel Kerneis wrote: > On Tue, Nov 16, 2010 at 12:43:30PM +0100, Thomas Gazagnaire wrote: >> 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 ... > > Or even simpler: > let is_none = (=) None > let is_some = (!=) None > Note that you can use this directly, for instance: > List.filter ((!=) None) l I would like to add that I also follow this general approach consisting in defining such trivial functions where I need them. Being trivial does not mean that they are going to be used everywhere. It makes the code easier to *read*. My 2 cents. Martin