Skip to content

Commit fae05c5

Browse files
committed
Deprecate Js.Result
1 parent 139e81e commit fae05c5

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

jscomp/others/belt_Result.ml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,43 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

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
2728

2829
let getExn = function
29-
| Js_result.Ok x -> x
30-
| Js_result.Error _ -> [%assert "getExn"]
30+
| Ok x -> x
31+
| Error _ -> [%assert "getExn"]
3132

3233
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
3536

3637
let mapWithDefault opt default f = mapWithDefaultU opt default (fun[@bs] x -> f x)
3738

3839
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
4142

4243
let map opt f = mapU opt (fun[@bs] x -> f x)
4344

4445
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
4748

4849
let flatMap opt f = flatMapU opt (fun[@bs] x -> f x)
4950

5051
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
5354

5455
let isOk = function
55-
| Js_result.Ok _ -> true
56-
| Js_result.Error _ -> false
56+
| Ok _ -> true
57+
| Error _ -> false
5758

5859
let isError = function
59-
| Js_result.Ok _ -> false
60-
| Js_result.Error _ -> true
60+
| Ok _ -> false
61+
| Error _ -> true
6162

6263
let eqU a b f = match (a, b) with
6364
| (Ok a, Ok b) -> f a b [@bs]

jscomp/others/belt_Result.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
Utilities for result data type.
2828
*)
2929

30-
type ('a,'b) t = ('a, 'b) Js_result.t = Ok of 'a | Error of 'b
30+
type ('a, 'b) t =
31+
| Ok of 'a
32+
| Error of 'b
3133

3234
val getExn : ('a, 'b) t -> 'a
3335
val mapWithDefaultU : ('a, 'c) t -> 'b -> ('a -> 'b [@bs]) -> 'b

jscomp/others/js_result.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
type (+'good, +'bad) t =
26-
| Ok of 'good
27-
| Error of 'bad
25+
type ('a, 'b) t = ('a, 'b) Belt_Result.t = Ok of 'a | Error of 'b
26+
[@@ocaml.deprecated "Please use `Belt.Result.t` instead"]

jscomp/others/js_result.mli

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
type (+'good, +'bad) t =
26-
| Ok of 'good
27-
| Error of 'bad
25+
type ('a, 'b) t = ('a, 'b) Belt_Result.t = Ok of 'a | Error of 'b
26+
[@@ocaml.deprecated "Please use `Belt.Result.t` instead"]

0 commit comments

Comments
 (0)