1
1
2
2
## Runtime representation
3
3
4
- Below is a description of how OCaml values are encoded in JavaScript,
5
- the *internal* description means **users should not rely on its actual
4
+ Below is a description of how OCaml values are encoded in JavaScript,
5
+ the *internal* description means **users should not rely on its actual
6
6
encoding (and it is subject to change)** . We recommend that you write
7
7
setter/getter functions to manipulate safely OCaml values from JavaScript.
8
8
@@ -80,7 +80,7 @@ Simple Variants: (Variants with only one non-nullary constructor)
80
80
[source,ocaml]
81
81
--------------
82
82
type tree =
83
- \| Leaf
83
+ \| Leaf
84
84
\| Node of int * tree * tree
85
85
(* Leaf --> 0 *)
86
86
(* Node(a,b,c) --> [a,b,c]*)
@@ -90,7 +90,7 @@ Complex Variants: (Variants with more than one non-nullary constructor)
90
90
91
91
[source,ocaml]
92
92
-------------
93
- type u =
93
+ type u =
94
94
\| A of string
95
95
\| B of int
96
96
(* A a --> [a].tag=0 -- tag 0 assignment is optional *)
@@ -123,29 +123,22 @@ For example:
123
123
val Js.to_bool: Js.boolean -> bool
124
124
-----
125
125
126
- | `'a Js.Null.t` a| either `'a` or `null`
126
+ | `'a Js.Null.t` a| either `'a` or `null`. `Js.Null.empty` represents `null` too.
127
127
128
128
[source,ocaml]
129
129
.Js.Null module
130
130
--------------
131
131
val to_opt : 'a t -> 'a option
132
-
132
+ val from_opt : 'a option -> 'a t
133
133
val return : 'a -> 'a t
134
-
135
134
val test : 'a t -> bool
136
135
--------------
137
136
138
- | `'a Js.Undefined.t` a| either `'a` or `undefined`
139
-
140
- [source,ocaml]
141
- .Js.Undefined
142
- --------------
143
- val to_opt : 'a t -> 'a option
144
- val return : 'a -> 'a t
145
- val test : 'a t -> bool
146
- --------------
137
+ | `'a Js.Undefined.t` a| either `'a` or `undefined`.
138
+ Same operations as `'a Js.Null.t`.
147
139
148
- |`'a Js.Null_undefined.t` a| either `'a`, `null` or `undef`
140
+ |`'a Js.Null_undefined.t` a| either `'a`, `null` or `undef`.
141
+ Same operations as `'a Js.Null.t`.
149
142
|==============
150
143
151
144
NOTE: `Js.to_opt` is optimized when the `option` is not escaped
0 commit comments