caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Option functions (or lack thereof) + operator for composition
@ 2010-11-16 11:27 Serge Le Huitouze
  2010-11-16 11:49 ` [Caml-list] " David Allsopp
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Serge Le Huitouze @ 2010-11-16 11:27 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-11-16 17:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1853021343.44703.1289906871683.JavaMail.root@zmbs4.inria.fr>
2010-11-16 11:43 ` [Caml-list] Option functions (or lack thereof) + operator for composition Thomas Gazagnaire
2010-11-16 11:51   ` Gabriel Kerneis
2010-11-16 17:45     ` Martin Jambon
2010-11-16 11:27 Serge Le Huitouze
2010-11-16 11:49 ` [Caml-list] " David Allsopp
2010-11-16 14:23   ` Michael Ekstrand
2010-11-16 13:30 ` Jacques Garrigue
2010-11-16 13:52   ` Serge Le Huitouze
2010-11-16 14:19     ` dmitry grebeniuk
2010-11-16 14:26 ` Michael Ekstrand
2010-11-16 15:18   ` bluestorm
2010-11-16 15:26 ` bluestorm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).