Copy system environment into initial env, and also add %stdlib.
[goals.git] / src / utils.mli
1 (* Goalfile utilities
2  * Copyright (C) 2019 Richard W.M. Jones
3  * Copyright (C) 2019 Red Hat Inc.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *)
19
20 val failwithf : ('a, unit, string, 'b) format4 -> 'a
21 (** Like [failwith] but supports printf-like arguments. *)
22
23 val (//) : string -> string -> string
24 (** The {!Filename.concat} function. *)
25
26 val is_directory : string -> bool
27 (** Return true iff parameter is a directory. *)
28
29 val filter_map : ('a -> 'b option) -> 'a list -> 'b list
30 (** [filter_map f l] applies [f] to every element of [l], filters
31     out the [None] elements and returns the list of the arguments of
32     the [Some] elements. *)
33
34 val string_find : string -> string -> int
35 (** [string_find str sub] finds the index of [sub] in [str].  If
36     not found, returns -1. *)
37
38 val split : string -> string -> string * string
39 (** [split sep str] splits [str] at the first occurrence of the
40     separator [sep], returning the part before and the part after.
41     If separator is not found, return the whole string and an
42     empty string. *)
43
44 val nsplit : ?max:int -> string -> string -> string list
45 (** [nsplit ?max sep str] splits [str] into multiple strings at each
46     separator [sep].
47
48     As with the Perl split function, you can give an optional
49     [?max] parameter to limit the number of strings returned.  The
50     final element of the list will contain the remainder of the
51     input string. *)
52
53 val isspace : char -> bool
54 val triml : ?test:(char -> bool) -> string -> string
55 val trimr : ?test:(char -> bool) -> string -> string
56 val trim : ?test:(char -> bool) -> string -> string
57 (** Trim strings at left, right or both. *)
58
59 val absolute_path : string -> string
60 (** Convert any path into an absolute path. *)