Skip to content

Commit 2a47b10

Browse files
committed
New interface to the Choose primitive
1 parent 4fdb3f4 commit 2a47b10

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

ioSystem.ml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ module String = struct
4141
buffer
4242
end
4343

44-
module Sum = struct
45-
type ('a, 'b) t =
46-
| Left of 'a
47-
| Right of 'b
48-
49-
let destruct (s : ('a, 'b) t) (c_x : 'a -> 'c) (c_y : 'b -> 'c) : 'c =
50-
match s with
51-
| Left x -> c_x x
52-
| Right y -> c_y y
53-
end
54-
5544
(** The command line arguments of the program. *)
5645
let argv : string list =
5746
Array.to_list Sys.argv
@@ -68,11 +57,9 @@ let join (x : 'a Lwt.t) (y : 'b Lwt.t) : ('a * 'b) Lwt.t =
6857
| (Some x, Some y) -> Lwt.return (x, y)
6958
| _ -> Lwt.fail_with "The join expected two answers.")
7059

71-
(** First. *)
72-
let first (x : 'a Lwt.t) (y : 'b Lwt.t) : ('a, 'b) Sum.t Lwt.t =
73-
Lwt.pick [
74-
Lwt.bind x (fun x -> Lwt.return @@ Sum.Left x);
75-
Lwt.bind y (fun y -> Lwt.return @@ Sum.Right y)]
60+
(** Choose. *)
61+
let choose (x1 : 'a Lwt.t) (x2 : 'a Lwt.t) : 'a Lwt.t =
62+
Lwt.pick [x1; x2]
7663

7764
(** List the files of a directory. *)
7865
let list_files (directory : string) : string list option Lwt.t =

0 commit comments

Comments
 (0)