package imap

  1. Overview
  2. Docs

Sets of message numbers

The numbers are either "sequence numbers" or "unique identification numbers". The sets are in the "formal" sense. That is, the order and the reptitions matter. The elements are kept in the order they are given.

The elements of the set are unsigned 32-bit integers. This is the data type that represents both IMAP sequence numbers and unique identification numbers, except for zero. Zero will be interpreted as being IMAP '*', the highest possible number of the messages in the mailbox.

Briefly, an expression such as 1:3,4,5:12,18:* will be represented by the OCaml list [(1, 3); (4, 4); (5, 12); (18, 0)].

type num = Uint32.t
type t = (num * num) list

The type of sets, a formal, ordered, union of intervals.

val empty : t

The empty set.

val all : t

The interval of all positive numbers.

val single : num -> t

The interval consisting of a single number.

val single_int : int -> t
val interval : num -> num -> t

The set consisting of a single interval.

val from : num -> t

The half-interval starting from n (inclusive). It corresponds to the IMAP expression "n:*".

val add : num -> t -> t

add n s adds a single number n to the set s.

val add_interval : num -> num -> t -> t

add_interval n m s adds the whole interval between numbers n and m (including both n and m) to the set s.

val union : t -> t -> t

union s1 s2 forms the union of the s1 and s2.

val of_list : num list -> t
val iter2 : (num -> num -> unit) -> t -> t -> unit