From: Jean-Christophe Filliatre <filliatr@csl.sri.com>
To: Markus Mottl <mottl@miss.wu-wien.ac.at>
Cc: caml-list@inria.fr (OCAML)
Subject: Re: additions to standard library?
Date: Wed, 8 Mar 2000 11:03:04 -0800 (PST) [thread overview]
Message-ID: <14534.41960.928650.590869@cylinder.csl.sri.com> (raw)
In-Reply-To: <200003071524.QAA12371@miss.wu-wien.ac.at>
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
next prev parent reply other threads:[~2000-03-10 7:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-07 15:24 Markus Mottl
2000-03-08 19:03 ` Jean-Christophe Filliatre [this message]
2000-03-08 22:29 ` Markus Mottl
2000-03-10 10:51 ` Christian RINDERKNECHT
2000-03-09 13:18 ` Thorsten Ohl
2000-03-10 10:04 ` Francisco Valverde Albacete
2000-03-10 20:33 ` Markus Mottl
2000-03-14 23:15 ` Max Skaller
2000-03-11 18:49 ` Brian Rogoff
2000-03-12 1:54 ` Jerome Vouillon
[not found] ` <200003120239.DAA18581@miss.wu-wien.ac.at>
2000-03-14 17:53 ` Pierre Weis
2000-03-10 17:55 Manuel Fahndrich
2000-03-14 17:24 Don Syme
2000-03-21 21:08 ` John Max Skaller
2000-03-21 21:43 Don Syme
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14534.41960.928650.590869@cylinder.csl.sri.com \
--to=filliatr@csl.sri.com \
--cc=caml-list@inria.fr \
--cc=mottl@miss.wu-wien.ac.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).