small changes

This commit is contained in:
Simon Cruanes 2013-05-31 12:29:59 +02:00
parent a45fccca98
commit de7246b75c
2 changed files with 6 additions and 3 deletions

View file

@ -168,6 +168,7 @@ module Fut = struct
let map f fut = let map f fut =
let res, send = create () in let res, send = create () in
subscribe fut (fun x -> send (f x)); subscribe fut (fun x -> send (f x));
subscribe res (fun _ -> ignore fut); (* keep ref *)
res res
let first l = let first l =

View file

@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(** {2 Behavior tree} *) (** {2 Behavior tree} *)
(** A behavior tree *)
type tree = private type tree = private
| Test of bool React.event (* test the next occurrence *) | Test of bool React.event (* test the next occurrence *)
| TestFun of (unit -> bool) (* call and test value *) | TestFun of (unit -> bool) (* call and test value *)
@ -59,12 +60,13 @@ type tree = private
| Select of select_strategy * tree list (* select one subtree *) | Select of select_strategy * tree list (* select one subtree *)
| Parallel of parallel_strategy * tree list (* run all subtrees in parallel *) | Parallel of parallel_strategy * tree list (* run all subtrees in parallel *)
| Closure of (unit -> tree) (* build a tree dynamically *) | Closure of (unit -> tree) (* build a tree dynamically *)
| Succeed | Succeed (* always succeed *)
| Fail | Fail (* always fail *)
(** A behavior tree *)
and select_strategy = tree list -> (unit -> tree option) and select_strategy = tree list -> (unit -> tree option)
(** How to select a subtree to run. It may yield a different result each (** How to select a subtree to run. It may yield a different result each
time it is called. *) time it is called. *)
and parallel_strategy = and parallel_strategy =
| PSForall (** succeeds when all subtrees succeed *) | PSForall (** succeeds when all subtrees succeed *)
| PSExists (** succeeds when some subtree succeeds (kill the others) *) | PSExists (** succeeds when some subtree succeeds (kill the others) *)