caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@yquem.inria.fr
Subject: Some hints for Mbox-module signature
Date: Sun, 6 Mar 2005 00:46:38 +0100	[thread overview]
Message-ID: <20050305234638.GA450@first.in-berlin.de> (raw)

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


             reply	other threads:[~2005-03-06  0:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-05 23:46 Oliver Bandel [this message]
2005-03-06  2:48 ` [Caml-list] " Robert Roessler

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=20050305234638.GA450@first.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@yquem.inria.fr \
    /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).