Skip to content

Commit 695bb47

Browse files
committed
Kind.t
1 parent bba4ec0 commit 695bb47

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

jscomp/others/js_json.res

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ type rec t =
3535
| Array(array<t>)
3636

3737
module Kind = {
38-
type rec kind<_> =
39-
| String: kind<Js_string.t>
40-
| Number: kind<float>
41-
| Object: kind<Js_dict.t<t>>
42-
| Array: kind<array<t>>
43-
| Boolean: kind<bool>
44-
| Null: kind<Js_types.null_val>
38+
type json = t
39+
type rec t<_> =
40+
| String: t<Js_string.t>
41+
| Number: t<float>
42+
| Object: t<Js_dict.t<json>>
43+
| Array: t<array<json>>
44+
| Boolean: t<bool>
45+
| Null: t<Js_types.null_val>
4546
}
4647

4748
type tagged_t =
@@ -74,7 +75,7 @@ let classify = (x: t): tagged_t => {
7475
}
7576
}
7677

77-
let test = (type a, x: 'a, v: Kind.kind<a>): bool =>
78+
let test = (type a, x: 'a, v: Kind.t<a>): bool =>
7879
switch v {
7980
| Kind.Number => Js.typeof(x) == "number"
8081
| Kind.Boolean => Js.typeof(x) == "boolean"

jscomp/others/js_json.resi

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ type rec t =
4141
| Array(array<t>)
4242

4343
module Kind: {
44+
type json = t
4445
/** Underlying type of a JSON value */
45-
type rec kind<_> =
46-
| String: kind<Js_string.t>
47-
| Number: kind<float>
48-
| Object: kind<Js_dict.t<t>>
49-
| Array: kind<array<t>>
50-
| Boolean: kind<bool>
51-
| Null: kind<Js_types.null_val>
46+
type rec t<_> =
47+
| String: t<Js_string.t>
48+
| Number: t<float>
49+
| Object: t<Js_dict.t<json>>
50+
| Array: t<array<json>>
51+
| Boolean: t<bool>
52+
| Null: t<Js_types.null_val>
5253
}
5354

5455
type tagged_t =
@@ -65,7 +66,7 @@ type tagged_t =
6566
let classify: t => tagged_t
6667

6768
/** `test(v, kind)` returns `true` if `v` is of `kind`. */
68-
let test: ('a, Kind.kind<'b>) => bool
69+
let test: ('a, Kind.t<'b>) => bool
6970

7071
/** `decodeString(json)` returns `Some(s)` if `json` is a `string`, `None` otherwise. */
7172
let decodeString: t => option<Js_string.t>

jscomp/test/js_json_test.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ let () = {
145145

146146
/* Check that the given json value is an array and that its element
147147
* a position [i] is equal to both the [kind] and [expected] value */
148-
let eq_at_i = (type a, loc: string, json: J.t, i: int, kind: J.Kind.kind<a>, expected: a): unit => {
148+
let eq_at_i = (type a, loc: string, json: J.t, i: int, kind: J.Kind.t<a>, expected: a): unit => {
149149
let ty = J.classify(json)
150150
switch ty {
151151
| J.JSONArray(x) =>

0 commit comments

Comments
 (0)