Skip to content
This repository
Newer
Older
100644 41 lines (34 sloc) 1.444 kb
fccc6851 »
2011-06-21 Initial open-source release
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 This module implements a fake 'return' function
20
21 The main reason for using this is when you want to traverse
22 a data structure and stop at some point with a value.
23 You can use it to defined a find function from an iter function for instance:
24 {[ let find predicate =
25 set_checkpoint (fun label ->
26 iter (fun elt -> if predicate elt then return label (Some elt));
27 None
28 ) ]}
29 *)
30 type 'a label
31 val set_checkpoint : ('a label -> 'a) -> 'a
32 val return : 'a label -> 'a -> _
33 val set_checkpoint_opt : ('a label -> unit) -> 'a option
34 val set_checkpoint_either : ('returned label -> 'normal) -> ('normal,'returned) Base.either
35
36 (**
37 If no break are done, return [Some a],
38 or else return [None]
39 *)
40 val set_checkpoint_none : (unit label -> 'a) -> 'a option
Something went wrong with that request. Please try again.