| 1 | type 'a t = 'a option |
| 2 | |
| 3 | let return x = Some x |
| 4 | |
| 5 | let map t ~f = |
| 6 | match t with |
| 7 | | None -> None |
| 8 | | Some x -> Some (f x) |
| 9 | ;; |
| 10 | |
| 11 | let bind t ~f = |
| 12 | match t with |
| 13 | | None -> None |
| 14 | | Some x -> f x |
| 15 | ;; |
| 16 | |
| 17 | let both t1 t2 = |
| 18 | match t1, t2 with |
| 19 | | Some t1, Some t2 -> Some (t1, t2) |
| 20 | | _ -> None |
| 21 | ;; |
| 22 | |
| 23 | let bind4 t1 t2 t3 t4 ~f = |
| 24 | match t1, t2, t3, t4 with |
| 25 | | Some t1, Some t2, Some t3, Some t4 -> f t1 t2 t3 t4 |
| 26 | | _ -> None |
| 27 | ;; |
| 28 | |
| 29 | let map4 t1 t2 t3 t4 ~f = |
| 30 | match t1, t2, t3, t4 with |
| 31 | | Some t1, Some t2, Some t3, Some t4 -> Some (f t1 t2 t3 t4) |
| 32 | | _ -> None |
| 33 | ;; |
| 34 | |
| 35 | module Let_syntax = struct |
| 36 | module Let_syntax = struct |
| 37 | let return = return |
| 38 | let map = map |
| 39 | let bind = bind |
| 40 | let both = both |
| 41 | let map4 = map4 |
| 42 | let bind4 = bind4 |
| 43 | |
| 44 | module Open_on_rhs = struct end |
| 45 | end |
| 46 | end |