Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (90 sloc) 3.379 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (*
19 @author Rudy Sicard
20 @author Pascal Rigaux
21 @author Mehdi Bouaziz
22 @author Mathieu Barbin
23 @author François-Régis Sinot
24 @author Henri Binsztok
25 *)
26
27 val default : 'a -> 'a option -> 'a
28 val default_lazy : 'a Lazy.t -> 'a option -> 'a
5b18026 [enhance] Stdlib: Comments in Standard Library
Arthur Milchior authored
29 (** true if the argument is None*)
fccc685 Initial open-source release
MLstate authored
30 val is_none : 'a option -> bool
5b18026 [enhance] Stdlib: Comments in Standard Library
Arthur Milchior authored
31 (** true if the argument is Some _*)
fccc685 Initial open-source release
MLstate authored
32 val is_some : 'a option -> bool
33
34 (**
35 [if_none o a b] {[if is_none then a else b]}
36 *)
37 val if_none : 'a option -> 'b -> 'b -> 'b
38
39 (**
40 if_some o a b <=> if is_some then a else b
41 *)
42 val if_some : 'a option -> 'b -> 'b -> 'b
43 val get : 'a option -> 'a
44 val get_exn : exn -> 'a option -> 'a
45 val map : ('a -> 'b) -> 'a option -> 'b option
46 val map2 : ('a -> 'b -> 'c) -> 'a option -> 'b option -> 'c option
47
48 (** apply the optional function *)
49 val apply : ('a -> 'a) option -> 'a -> 'a
50
51
52 val fold : ('a -> 'b -> 'a) -> 'a -> 'b option -> 'a
53 val fold_right : ('b -> 'acc -> 'acc) -> 'b option -> 'acc -> 'acc
54 val foldmap : ('a -> 'b -> 'a * 'c) -> 'a -> 'b option -> 'a * 'c option
55
56 (** Like foldmap but returns the same object physically if
57 the traverse function returns the same object.
58 Used for optimizing traversal constructions *)
59 val foldmap_stable :
60 ('a -> 'b -> 'a * 'b) -> 'a -> 'b option -> 'a * 'b option
61
62 val iter : ('a -> unit) -> 'a option -> unit
63
64 (**
65 Like map but can change a [Some(v)] to a [none]
66 *)
67 val bind : ('a -> 'b option) -> 'a option -> 'b option
68 val to_list : 'a option -> 'a list
69 val default_map : 'a -> ('b -> 'a) -> 'b option -> 'a
70 val default_lazy_map : 'a Lazy.t -> ('b -> 'a) -> 'b option -> 'a
71 val join : 'a option option -> 'a option
72 val make_compare : ('a -> 'b -> int) -> 'a option -> 'b option -> int
73 val merge : ('a -> 'a -> 'a) -> 'a option -> 'a option -> 'a option
74 val to_string : ('a -> string) -> 'a option -> string
75
76 (**
77 [pp_none] Print [none] or directly the value if Some
78 *)
79 val pp_none :
80 (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a option -> unit
81
82 (**
83 [pp] does not print anything for [None], and print the value if [Some]
84 *)
85 val pp : ('a -> 'b -> unit) -> 'a -> 'b option -> unit
86
87 (**
88 [pp_sep sep pp fmt opt]
89 Does not print anything for [None].
90 Print the separator, and the value if [Some]
91 *)
92 val pp_sep :
93 (unit, Format.formatter, unit) format ->
94 (Format.formatter -> 'a -> unit) ->
95 Format.formatter -> 'a option -> unit
96
97 (**
98 Print the default if [None], and the value if [Some]
99 *)
100 val pp_default : 'a -> ('b -> 'a -> 'c) -> 'b -> 'a option -> 'c
101
102 (**
103 Print [None] and [Some value]
104 *)
105 val pp_meta :
106 (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a option -> unit
107
108 val exists : ('a -> bool) -> 'a option -> bool
109 val for_all : ('a -> bool) -> 'a option -> bool
Something went wrong with that request. Please try again.