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 89A1DBC57 for ; Tue, 16 Nov 2010 12:51:58 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ag4BAIX+4UxRZ90wkWdsb2JhbACiXBUBAQEBCQsKBxEDH75bhUsEilg X-IronPort-AV: E=Sophos;i="4.59,205,1288566000"; d="scan'208";a="87240116" Received: from mtaout02-winn.ispmail.ntl.com ([81.103.221.48]) by mail1-smtp-roc.national.inria.fr with ESMTP; 16 Nov 2010 12:51:58 +0100 Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20101116115157.CJUC19887.mtaout02-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com>; Tue, 16 Nov 2010 11:51:57 +0000 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout01-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20101116115157.URNI20122.aamtaout01-winn.ispmail.ntl.com@romulus.metastack.com>; Tue, 16 Nov 2010 11:51:57 +0000 Received: from remus.metastack.local ([172.16.0.1]) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id oAGBps5j022283 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Tue, 16 Nov 2010 11:51:54 GMT Received: from Remus.metastack.local ([fe80::547c:3c42:e1da:eda2]) by Remus.metastack.local ([fe80::547c:3c42:e1da:eda2%11]) with mapi; Tue, 16 Nov 2010 11:49:26 +0000 From: David Allsopp To: Serge Le Huitouze , "caml-list@yquem.inria.fr" Subject: RE: [Caml-list] Option functions (or lack thereof) + operator for composition Thread-Topic: [Caml-list] Option functions (or lack thereof) + operator for composition Thread-Index: AQHLhYD6uYBYFCRTo0Os3W7T+RyNh5Nz+/eA Date: Tue, 16 Nov 2010 11:49:24 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Organization: MetaStack Solutions Ltd. X-Scanned-By: MIMEDefang 2.65 on 81.102.132.77 X-Cloudmark-Analysis: v=1.1 cv=JvdXmxIgLJv2/GthKqHpGJEEHukvLcvELVXUanXFreg= c=1 sm=0 a=r2Q9SOzacN8A:10 a=kj9zAlcOel0A:10 a=xqWC_Br6kY4A:10 a=FP58Ms26AAAA:8 a=1XWaLZrsAAAA:8 a=t0ZsSdnvAAAA:8 a=wOYUJ5IPmDF62egtqGUA:9 a=wIF60hKF5CKLvups5gwgM7FZCE8A:4 a=CjuIK1q_8ugA:10 a=m0vdzGwz03IA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 X-Spam: no; 0.00; ocaml:01 ocaml:01 findlib:01 findlib:01 sourceforge:01 wrote:01 defines:01 caml-list:01 functions:01 functions:01 dependency:01 dependency:01 tree:02 match:02 match:02 Serge Le Huitouze wrote: > 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 =3D ref None in > * let updateButtonsStatus () =3D > * button_remove#misc#set_sensitive > * (match !curSelectedRow with None -> false | _ -> true) > * in > * ... >=20 > 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... ExtLib is well-worth having and it's very easy to install (just run ocaml i= nstall.ml in its source tree - findlib recommended but I've got a feeling t= hat it can install without findlib as well). It's also very stable, feature= -wise, so you're not really adding a tricky dependency. It's now hosted on = Google Code at http://code.google.com/p/ocaml-extlib/downloads/list You might also take a look at the batteries project (http://batteries.forge= .ocamlcore.org) which I believe includes most if not all of ExtLib. David