Module Lifetime


module Lifetime: sig .. end
Datastructure for life timelines.

Provides a datastructure for representing sets of days as a list of intervals, suitable for rLepresenting the lifetime of a package in an archive.


exception Empty
Raised when a function expects a non-empty lifetime
type day = int 
Represented as calendar days from an unspecified origin.
type lifetime 
val io_lifetime : lifetime Io.literate
val io_day : day Io.literate
val day_of_ymd : int * int * int -> day
Convert a date in Gregorian (year,month,day) format to a calendar day.
val ymd_of_day : day -> int * int * int
Inverse function of day_of_date.
val empty : lifetime
A lifetime containing no days.
val load : string -> lifetime
Load lifetime data from a file using Io.
val save : string -> lifetime -> unit
Save lifetime data to a file using Io.
val output : Pervasives.out_channel -> lifetime -> unit
Output lifetime data to a channel using Io.
val singleton : day -> lifetime
Create a lifetime with the given single day.
val add_day : lifetime -> day -> lifetime
Add a day to a lifetime.
val is_empty : lifetime -> bool
Returns true if the lifetime contains no days.
val range : lifetime -> day * day
range lf returns a pair (a,b) where a is the first day and b is the last day in the lifetime. Raises Empty if lf is empty.
val iterate_over_intervals : (day * day -> unit) -> lifetime -> unit
Iterate over the intervals in the lifetime. A single day is represented by a pair (d,d).
val iterate_over_days : (day -> unit) -> lifetime -> unit
Iterate over every single day in the lifetime.