Commit d8f57f86 authored by POTTIER Francois's avatar POTTIER Francois

Implement [mapreduce] for [option], [ref], [result].

parent 164f5d9b
(* This file provides useful / reasonable visitor methods for many of the
built-in types of OCaml. *)
(* The classes defined in this file are automatically inherited by
auto-generated visitors. If this is not desired, this behavior can be
turned off at generation time by specifying [nude = true]. *)
(* Some of the code in this file can be (or has been) auto-generated by
the [visitors] package itself: see [test/VisitorsRuntimeBootstrap].
To avoid a complicated process and to facilitate code review, we
keep this code under manual control in this file. *)
(* -------------------------------------------------------------------------- *)
(* [array_equal eq xs1 xs2] tests whether the arrays [xs1] and [xs2] have the
......@@ -539,6 +551,37 @@ class virtual ['self] mapreduce = object (self : 'self)
let xs, sxs = self # visit_list f env xs in
x :: xs, self#plus sx sxs
method private visit_option: 'env 'a_0 'a_1 .
('env -> 'a_0 -> 'a_1 * 's) ->
'env -> 'a_0 option -> 'a_1 option * 's
= fun visit_'a env this ->
match this with
| None ->
None, self#zero
| Some c0 ->
let r0, s0 = visit_'a env c0 in
Some r0, s0
method private visit_ref: 'env 'a_0 'a_1 .
('env -> 'a_0 -> 'a_1 * 's) ->
'env -> 'a_0 ref -> 'a_1 ref * 's
= fun visit_'a env this ->
let r0, s0 = visit_'a env this.contents in
{ contents = r0 }, s0
method private visit_result: 'env 'a_0 'a_1 'b_0 'b_1 .
('env -> 'a_0 -> 'a_1 * 's) ->
('env -> 'b_0 -> 'b_1 * 's) ->
'env -> ('a_0, 'b_0) result -> ('a_1, 'b_1) result * 's
= fun visit_'a visit_'b env this ->
match this with
| Ok c0 ->
let r0, s0 = visit_'a env c0 in
Ok r0, s0
| Error c0 ->
let r0, s0 = visit_'b env c0 in
Error r0, s0
(* TEMPORARY *)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment