diff options
Diffstat (limited to 'otherlibs/labltk/support/may.ml')
-rw-r--r-- | otherlibs/labltk/support/may.ml | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/otherlibs/labltk/support/may.ml b/otherlibs/labltk/support/may.ml new file mode 100644 index 000000000..202b561d9 --- /dev/null +++ b/otherlibs/labltk/support/may.ml @@ -0,0 +1,10 @@ + +(* Very easy hack for option type *) +let may f = function + Some x -> Some (f x) +| None -> None + +let maycons f x l = + match x with + Some x -> f x :: l + | None -> l |