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