OCAML_TEST_INC = -I $(shell ocamlfind query oUnit)
OCAML_TEST_LIB = $(shell ocamlfind query oUnit)/oUnit.cmxa
-STDEXT_OBJS = filenameext stringext arrayext hashtblext listext pervasiveext threadext ring \
+STDEXT_OBJS = fun listext filenameext stringext arrayext hashtblext pervasiveext threadext ring \
qring fring opt bigbuffer unixext range vIO trie config date encodings fe fecomms \
- forkhelpers gzip sha1sum zerocheck base64 backtrace tar
+ forkhelpers gzip sha1sum zerocheck base64 backtrace tar mapext
INTF = $(foreach obj, $(STDEXT_OBJS),$(obj).cmi)
LIBS = stdext.cma stdext.cmxa
let comp f g x = f (g x)
let (++) f g x = comp f g x
-let comp2 f g a b = f (g a b)
+let comp2 f g a b = ((++) ++ (++)) f g a b
let (+++) f g a b = comp2 f g a b
-
-let (|>) a f = f a
-
-let ($) f a = f a
val flip : ('a -> 'b -> 'c) -> ('b -> 'a -> 'c)
val on : ('b -> 'b -> 'c) -> ('a -> 'b) -> 'a -> 'a -> 'c
val comp : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c)
-val comp2 : ('b -> 'c) -> ('a1 -> 'a2 -> 'b) -> ('a1 -> 'a2 -> 'c)
-val (+++) : ('c -> 'd) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'd
-val (++) : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c
-(** Forward pipe operator: facilitates left-to-right function composition. *)
-val (|>) : 'a -> ('a -> 'b) -> 'b
-val ($) : ('a -> 'b) -> 'a -> 'b
let assoc_default k l d =
if List.mem_assoc k l then List.assoc k l else d
+
+(* Like the Lisp cons *)
+let cons a b = a :: b
+
end
is not in the list. *)
val assoc_default : 'a -> ('a * 'b) list -> 'b -> 'b
+ (* Like Lisp cons*)
+ val cons : 'a -> 'a list -> 'a list
+
end
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)
+
+(* Perhaps it's better to use `option' from the ocaml-extlib extension
+ * to the standard library instead? (Although it would not suffice,
+ * since it's not a super-set of our `opt'.)
+ * (http://code.google.com/p/ocaml-extlib/)
+ *)
+
+open Pervasiveext
+
let iter f = function
| Some x -> f x
| None -> ()
match opt with
| Some x -> f x accu
| None -> accu
+
+let cat_options a = List.map unbox (List.filter is_boxed a)
val to_list : 'a option -> 'a list
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b option -> 'a
val fold_right : ('a -> 'b -> 'b) -> 'a option -> 'b -> 'b
+val cat_options : 'a option list -> 'a list
clean_f ();
result
+(* Those should go into the Opt module: *)
+
let maybe_with_default d f v =
match v with None -> d | Some x -> f x
let ignore_string v = let (_: string) = v in ()
let ignore_float v = let (_: float) = v in ()
let ignore_bool v = let (_: bool) = v in ()
+
+(* To avoid some parens: *)
+(* composition of functions: *)
+let (++) f g x = Fun.comp f g x
+
+(* and application *)
+let ($) f a = f a
val ignore_string : string -> unit
val ignore_float : float -> unit
val ignore_bool : bool -> unit
+
+val (++) : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c)
+val ($) : ('a -> 'b) -> 'a -> 'b