Browse thread
Re: [Caml-list] Option functions (or lack thereof) + operator for composition
- Thomas Gazagnaire
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Thomas Gazagnaire <thomas.gazagnaire@i...> |
| Subject: | Re: [Caml-list] Option functions (or lack thereof) + operator for composition |
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