Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Option functions (or lack thereof) + operator for composition
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-11-16 (11:51)
From: David Allsopp <dra-news@m...>
Subject: RE: [Caml-list] Option functions (or lack thereof) + operator for composition
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:
> 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...

ExtLib is well-worth having and it's very easy to install (just run ocaml in its source tree - findlib recommended but I've got a feeling that 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

You might also take a look at the batteries project ( which I believe includes most if not all of ExtLib.