From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 1F766BC75 for ; Sun, 6 Mar 2005 01:03:25 +0100 (CET) Received: from first.in-berlin.de (dialin-145-254-055-060.arcor-ip.net [145.254.55.60]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2603N5U009351 for ; Sun, 6 Mar 2005 01:03:24 +0100 Received: by first.in-berlin.de (Postfix, from userid 501) id 497BBB40B4; Sun, 6 Mar 2005 00:46:38 +0100 (CET) Date: Sun, 6 Mar 2005 00:46:38 +0100 From: Oliver Bandel To: caml-list@yquem.inria.fr Subject: Some hints for Mbox-module signature Message-ID: <20050305234638.GA450@first.in-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6i X-Miltered: at nez-perce with ID 422A48CB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; oliver:01 bandel:01 oliver:01 in-berlin:01 mli:01 val:01 val:01 bool:01 bool:01 iter:01 iter:01 functor:01 closures:01 functor:01 bandel:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.2 X-Spam-Level: Hello, some weeks ago I wrote a small tool to clean up mbox-files, throwing out multiple mails of an mbox file (throw away mails with same body). Now I just had the idea to write a module that can be used for more flexible programming then, not specialized to do one certain task on mbox-files. So, wheras the mentioned program only is used to throw away mails with same contents of the body, the Mbox-module should be useful for many tasks, e.g. selecting mails with a certain header-entry or body-contents or something like that (maybe, selecting by size). Here is, what tonight comes into my mind as a signature for such a module (mbox.mli). ================================================================== type mbox_t type mail_t exception Could_not_write_mbox exception Could_not_read_mbox val Mbox.create : string -> mbox_t val Mbox.append : mbox_t -> mbox_t -> mbox_t val Mbox.read : mbox_t -> unit val Mbox.write : mbox_t -> unit val Mbox.write_force : mbox_t -> unit val Mbox.change_name : mbox_t -> string -> unit val Mbox.rewind : mbox_t -> unit val Mbox.next_mail : unit -> mail_t val Mbox.match : (string -> bool) -> mail_t -> bool val Mbox.match_header : (string -> bool) -> mail_t -> bool val Mbox.match_body : (string -> bool) -> mail_t -> bool val Mbox.grep : string -> mail_t -> string list val Mbox.function : (string -> 'a) -> (mail_t -> 'a) (* iter/map/filter are preserving the order of the mails *) val Mbox.iter : (mail_t -> unit) -> mbox_t -> unit val Mbox.map : (mail_t -> 'a) -> mbox_t -> 'a list val Mbox.filter : (mail_t -> bool) -> mbox_t -> string -> mbox_t val Mbox.sort : (string -> string -> int) -> mbox_t -> mbox_t ================================================================== I think about using mbox_t and mail_t as an abstract type. What about Mbox.function. Does it make sense to use a functor for the functionality, or better using closures? This function is intended to create functions that can be used with Mbox.iter, Mbox.map, Mbox.filter. Do you think this signature makes sense? Are there functions to add? Are there functions that seems to be unnecessary? Do I really need rewind/next_mail? My thought was: they can be used for reading directly from the file, instead of reading in the whole file into memory, as Mbox.read is intended to do. But how to use such a function together with Mbox.iter/map/filter? Should I add another function, so that Mbox.next_mail (maybe "Mbox.next" is a sufficient name?) can be used together with the iter/map/filter? Functor? Closure? If you have any suggestions, please let me know about it. Thanks In Advance, Oliver Bandel