Skip to content

Commit

Permalink
type s instead kind
Browse files Browse the repository at this point in the history
  • Loading branch information
mununki committed Jul 3, 2023
1 parent 68e6506 commit 7a8880b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions jscomp/others/js_json.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ type rec t =
| Array(array<t>)

module Kind = {
type rec kind<_> =
| String: kind<Js_string.t>
| Number: kind<float>
| Object: kind<Js_dict.t<t>>
| Array: kind<array<t>>
| Boolean: kind<bool>
| Null: kind<Js_types.null_val>
type rec s<_> =
| String: s<Js_string.t>
| Number: s<float>
| Object: s<Js_dict.t<t>>
| Array: s<array<t>>
| Boolean: s<bool>
| Null: s<Js_types.null_val>
}

type tagged_t =
Expand Down Expand Up @@ -74,7 +74,7 @@ let classify = (x: t): tagged_t => {
}
}

let test = (type a, x: 'a, v: Kind.kind<a>): bool =>
let test = (type a, x: 'a, v: Kind.s<a>): bool =>
switch v {
| Kind.Number => Js.typeof(x) == "number"
| Kind.Boolean => Js.typeof(x) == "boolean"
Expand Down
16 changes: 8 additions & 8 deletions jscomp/others/js_json.resi
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ type rec t =

module Kind: {
/** Underlying type of a JSON value */
type rec kind<_> =
| String: kind<Js_string.t>
| Number: kind<float>
| Object: kind<Js_dict.t<t>>
| Array: kind<array<t>>
| Boolean: kind<bool>
| Null: kind<Js_types.null_val>
type rec s<_> =
| String: s<Js_string.t>
| Number: s<float>
| Object: s<Js_dict.t<t>>
| Array: s<array<t>>
| Boolean: s<bool>
| Null: s<Js_types.null_val>
}

type tagged_t =
Expand All @@ -65,7 +65,7 @@ type tagged_t =
let classify: t => tagged_t

/** `test(v, kind)` returns `true` if `v` is of `kind`. */
let test: ('a, Kind.kind<'b>) => bool
let test: ('a, Kind.s<'b>) => bool

/** `decodeString(json)` returns `Some(s)` if `json` is a `string`, `None` otherwise. */
let decodeString: t => option<Js_string.t>
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/js_json_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ let () = {

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

0 comments on commit 7a8880b

Please sign in to comment.