Skip to content

Commit 7783def

Browse files
committed
Present -> Value, and add equivalent unboxed variant type for Null.t
1 parent 1171f4c commit 7783def

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

jscomp/others/js.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ end
8686

8787
(**/**)
8888

89-
type +'a null
89+
type +'a null =
90+
| Value of 'a
91+
| Null [@as null]
92+
[@@unboxed]
9093
(**
9194
Nullable value of this type can be either null or 'a. This type is equivalent to Js.Null.t.
9295
*)
@@ -97,7 +100,7 @@ type +'a undefined
97100
*)
98101

99102
type +'a nullable =
100-
| Present of 'a
103+
| Value of 'a
101104
| Null [@as null]
102105
| Undefined [@as undefined]
103106
[@@unboxed]

jscomp/others/js_null.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
(** Provides functionality for dealing with the `'a Js.null` type *)
2626

2727

28-
type + 'a t = 'a Js.null
28+
type + 'a t = 'a Js.null =
29+
| Value of 'a
30+
| Null [@as null]
31+
[@@unboxed]
2932

3033
external to_opt : 'a t -> 'a option = "#null_to_opt"
3134
external toOption : 'a t -> 'a option = "#null_to_opt"

jscomp/others/js_null.mli

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626

2727
(** Provides functionality for dealing with the `Js.null('a)` type *)
2828

29-
type +'a t = 'a Js.null
29+
type +'a t = 'a Js.null =
30+
| Value of 'a
31+
| Null [@as null]
32+
[@@unboxed]
3033
(** Local alias for `Js.null('a)` *)
3134

3235
external return : 'a -> 'a t = "%identity"

jscomp/others/js_null_undefined.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
(** Contains functionality for dealing with values that can be both `null` and `undefined` *)
2626

2727
type + 'a t = 'a Js.nullable =
28-
| Present of 'a
28+
| Value of 'a
2929
| Null [@as null]
3030
| Undefined [@as undefined]
3131
[@@unboxed]

jscomp/others/js_null_undefined.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
(** Contains functionality for dealing with values that can be both `null` and `undefined` *)
2626

2727
type +'a t = 'a Js.nullable =
28-
| Present of 'a
28+
| Value of 'a
2929
| Null [@as null]
3030
| Undefined [@as undefined]
3131
[@@unboxed]

jscomp/runtime/js.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ end
5757
(**/**)
5858

5959

60-
type + 'a null
60+
type + 'a null =
61+
| Value of 'a
62+
| Null [@as null]
63+
[@@unboxed]
6164
(** nullable, value of this type can be either [null] or ['a]
6265
this type is the same as type [t] in {!Null}
6366
*)
@@ -67,7 +70,7 @@ type + 'a undefined
6770
this type is the same as type [t] in {!Undefined} *)
6871

6972
type + 'a nullable =
70-
| Present of 'a
73+
| Value of 'a
7174
| Null [@as null]
7275
| Undefined [@as undefined]
7376
[@@unboxed]

0 commit comments

Comments
 (0)