Commit | Line | Data |
---|---|---|
feec80c3 C |
1 | (* |
2 | * Std - Additional functions | |
3 | * Copyright (C) 2003 Nicolas Cannasse | |
4 | * | |
5 | * This library is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU Lesser General Public | |
7 | * License as published by the Free Software Foundation; either | |
8 | * version 2.1 of the License, or (at your option) any later version, | |
9 | * with the special exception on linking described in file LICENSE. | |
10 | * | |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Lesser General Public | |
17 | * License along with this library; if not, write to the Free Software | |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 | *) | |
20 | ||
21 | (** Additional functions. *) | |
22 | ||
23 | val input_lines : in_channel -> string Enum.t | |
24 | (** Returns an enumeration over lines of an input channel, as read by the | |
25 | [input_line] function. *) | |
26 | ||
27 | val input_chars : in_channel -> char Enum.t | |
28 | (** Returns an enumeration over characters of an input channel. *) | |
29 | ||
30 | val input_list : in_channel -> string list | |
31 | (** Returns the list of lines read from an input channel. *) | |
32 | ||
33 | val input_all : in_channel -> string | |
34 | (** Return the whole contents of an input channel as a single | |
35 | string. *) | |
36 | ||
37 | val print_bool : bool -> unit | |
38 | (** Print a boolean to stdout. *) | |
39 | ||
40 | val prerr_bool : bool -> unit | |
41 | (** Print a boolean to stderr. *) | |
42 | ||
43 | val input_file : ?bin:bool -> string -> string | |
44 | (** returns the data of a given filename. *) | |
45 | ||
46 | val output_file : filename:string -> text:string -> unit | |
47 | (** creates a filename, write text into it and close it. *) | |
48 | ||
49 | val string_of_char : char -> string | |
50 | (** creates a string from a char. *) | |
51 | ||
52 | external identity : 'a -> 'a = "%identity" | |
53 | (** the identity function. *) | |
54 | ||
55 | val unique : unit -> int | |
56 | (** returns an unique identifier every time it is called. *) | |
57 | ||
58 | val dump : 'a -> string | |
59 | (** represent a runtime value as a string. Since types are lost at compile | |
60 | time, the representation might not match your type. For example, None | |
61 | will be printed 0 since they share the same runtime representation. *) | |
62 | ||
63 | val print : 'a -> unit | |
64 | (** print the representation of a runtime value on stdout. | |
65 | See remarks for [dump]. *) | |
66 | ||
67 | val finally : (unit -> unit) -> ('a -> 'b) -> 'a -> 'b | |
68 | (** [finally fend f x] calls [f x] and then [fend()] even if [f x] raised | |
69 | an exception. *) |