Browse thread
additions to standard library?
-
Markus Mottl
- Jean-Christophe Filliatre
- Thorsten Ohl
- Jerome Vouillon
[
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: | Jean-Christophe Filliatre <filliatr@c...> |
| Subject: | Re: additions to standard library? |
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 = <fun>
======================================================================
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