Initial commit.
[guestfs-browser.git] / utils.mli
1 (* Guestfs Browser.
2  * Copyright (C) 2010 Red Hat Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *)
18
19 (** General-purpose utility code used everywhere. *)
20
21 type ('a, 'b) either = Left of 'a | Right of 'b
22   (** A value which is either an ['a] or a ['b], just like Haskell's
23       "Either" type. *)
24
25 val verbose : bool ref
26   (** If this contains [true] then {!debug} will send debugging
27       messages to stderr, else debugging messages are dropped. *)
28
29 val debug : ('a, out_channel, unit) format -> 'a
30   (** A printf-like function for writing debugging messages. *)
31
32 val failwith : ('a, out_channel, unit) format -> 'a
33   (** Replacement for standard OCaml [failwith] function.  This can
34       take a printf-like argument list, and also logs errors on stderr
35       when verbose is enabled. *)