From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA28635 for caml-redistribution@pauillac.inria.fr; Fri, 10 Mar 2000 08:56:47 +0100 (MET) Resent-Message-Id: <200003100756.IAA28635@pauillac.inria.fr> Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA28935 for ; Wed, 8 Mar 2000 20:03:14 +0100 (MET) Received: from csla.csl.sri.com (csla.csl.sri.com [192.12.33.2]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id UAA14022 for ; Wed, 8 Mar 2000 20:03:11 +0100 (MET) Received: from cylinder.csl.sri.com (IDENT:filliatr@cylinder.csl.sri.com [130.107.15.112]) by csla.csl.sri.com (8.9.1/8.9.1) with ESMTP id LAA16989; Wed, 8 Mar 2000 11:03:06 -0800 (PST) Received: (from filliatr@localhost) by cylinder.csl.sri.com (8.9.3/8.8.7) id LAA01629; Wed, 8 Mar 2000 11:03:04 -0800 X-Authentication-Warning: cylinder.csl.sri.com: filliatr set sender to filliatr@cylinder.csl.sri.com using -f From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14534.41960.928650.590869@cylinder.csl.sri.com> Date: Wed, 8 Mar 2000 11:03:04 -0800 (PST) To: Markus Mottl Cc: caml-list@inria.fr (OCAML) Subject: Re: additions to standard library? In-Reply-To: <200003071524.QAA12371@miss.wu-wien.ac.at> References: <200003071524.QAA12371@miss.wu-wien.ac.at> X-Mailer: VM 6.62 under Emacs 20.4.1 Reply-To: filliatr@csl.sri.com (Jean-Christophe Filliatre) Resent-From: weis@pauillac.inria.fr Resent-Date: Fri, 10 Mar 2000 08:56:47 +0100 Resent-To: caml-redistribution@pauillac.inria.fr In his message of Tue March 7, 2000, Markus Mottl writes: > it sometimes happens that I need functions on abstract data types in the > standard library which are not available there, but could be considered as > "usual" operations on such data. Also some other very commonly useful > functions could be added. I agree. One may think that the functions you suggest can actually be defined outside the standard library using iterators like fold (not for Stack.top, however). For instance, one can define set_exists as ====================================================================== # module Myset = Set.Make(struct type t = ... let compare = ... end);; ... # let set_exists p s = try Myset.fold (fun x _ -> if p x then failwith "t") s (); false with Failure "t" -> true;; val set_exists : (Myset.elt -> bool) -> Myset.t -> bool = ====================================================================== But when using functorial interfaces like Set.Make, you have to redefine these functions for each application of the functor. Thus, you really need these functions to be defined in the functor i.e. together with the datatype (and, by the way, you can then define these functions a bit more efficiently---without using exceptions). -- Jean-Christophe Filliatre Computer Science Laboratory Phone (650) 859-5173 SRI International FAX (650) 859-2844 333 Ravenswood Ave. email filliatr@csl.sri.com Menlo Park, CA 94025, USA web http://www.csl.sri.com/~filliatr