Skip to content

Commit 139e81e

Browse files
committed
Add constructors
1 parent df16b63 commit 139e81e

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

jscomp/others/belt_Result.ml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,41 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525

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
2727

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

3232
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
3535

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

3838
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
4141

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

4444
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
4747

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

5050
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
5353

5454
let isOk = function
55-
| Ok _ -> true
56-
| Error _ -> false
55+
| Js_result.Ok _ -> true
56+
| Js_result.Error _ -> false
5757

5858
let isError = function
59-
| Ok _ -> false
60-
| Error _ -> true
59+
| Js_result.Ok _ -> false
60+
| Js_result.Error _ -> true
6161

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

jscomp/others/belt_Result.mli

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

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

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

0 commit comments

Comments
 (0)