|
23 | 23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
|
24 | 24 |
|
25 | 25 |
|
26 |
| -type ('a,'b) t = ('a, 'b) Js_result.t |
| 26 | +type ('a,'b) t = ('a, 'b) Js_result.t = Ok of 'a | Error of 'b |
27 | 27 |
|
28 | 28 | let getExn = function
|
29 |
| - | Ok x -> x |
30 |
| - | Error _ -> [%assert "getExn"] |
| 29 | + | Js_result.Ok x -> x |
| 30 | + | Js_result.Error _ -> [%assert "getExn"] |
31 | 31 |
|
32 | 32 | let mapWithDefaultU opt default f = match opt with
|
33 |
| - | Ok x -> (f x [@bs]) |
34 |
| - | Error _ -> default |
| 33 | + | Js_result.Ok x -> (f x [@bs]) |
| 34 | + | Js_result.Error _ -> default |
35 | 35 |
|
36 | 36 | let mapWithDefault opt default f = mapWithDefaultU opt default (fun[@bs] x -> f x)
|
37 | 37 |
|
38 | 38 | let mapU opt f = match opt with
|
39 |
| - | Ok x -> Ok (f x [@bs]) |
40 |
| - | Error y -> Error y |
| 39 | + | Js_result.Ok x -> Js_result.Ok (f x [@bs]) |
| 40 | + | Js_result.Error y -> Js_result.Error y |
41 | 41 |
|
42 | 42 | let map opt f = mapU opt (fun[@bs] x -> f x)
|
43 | 43 |
|
44 | 44 | let flatMapU opt f = match opt with
|
45 |
| - | Ok x -> (f x [@bs]) |
46 |
| - | Error y -> Error y |
| 45 | + | Js_result.Ok x -> (f x [@bs]) |
| 46 | + | Js_result.Error y -> Js_result.Error y |
47 | 47 |
|
48 | 48 | let flatMap opt f = flatMapU opt (fun[@bs] x -> f x)
|
49 | 49 |
|
50 | 50 | let getWithDefault opt default = match opt with
|
51 |
| - | Ok x -> x |
52 |
| - | Error _ -> default |
| 51 | + | Js_result.Ok x -> x |
| 52 | + | Js_result.Error _ -> default |
53 | 53 |
|
54 | 54 | let isOk = function
|
55 |
| - | Ok _ -> true |
56 |
| - | Error _ -> false |
| 55 | + | Js_result.Ok _ -> true |
| 56 | + | Js_result.Error _ -> false |
57 | 57 |
|
58 | 58 | let isError = function
|
59 |
| - | Ok _ -> false |
60 |
| - | Error _ -> true |
| 59 | + | Js_result.Ok _ -> false |
| 60 | + | Js_result.Error _ -> true |
61 | 61 |
|
62 | 62 | let eqU a b f = match (a, b) with
|
63 | 63 | | (Ok a, Ok b) -> f a b [@bs]
|
|
0 commit comments