Skip to content

Commit edc1abd

Browse files
committed
remove Js booleans
1 parent 917e30c commit edc1abd

File tree

13 files changed

+12
-104
lines changed

13 files changed

+12
-104
lines changed

jscomp/build_tests/bucklescript-tea/src/tea_json.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ module Encoder = struct
532532

533533
let float (v : float) = Json.of_type Json.Number v
534534

535-
let bool (v : bool) = Json.of_type Json.Boolean (if v then Js.true_ else Js.false_)
535+
let bool (v : bool) = Json.of_type Json.Boolean v
536536

537537
let null = Json.of_type Json.Null Json.null
538538

jscomp/others/.depend

-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ belt_SetString.cmj : belt_internalSetString.cmj belt_internalAVLset.cmj \
8686
belt_MutableStack.cmj : belt_MutableStack.cmi
8787
belt_MutableQueue.cmj : belt_Array.cmj belt_MutableQueue.cmi
8888
node_child_process.cmj : node.cmj
89-
js_boolean.cmj : js_boolean.cmi
9089
js_math.cmj :
9190
js_dict.cmj : js_array.cmj js_dict.cmi
9291
js_date.cmj :
@@ -146,7 +145,6 @@ belt_SetInt.cmi :
146145
belt_SetString.cmi :
147146
belt_MutableStack.cmi :
148147
belt_MutableQueue.cmi :
149-
js_boolean.cmi :
150148
js_dict.cmi :
151149
js_cast.cmi :
152150
dom.cmi : dom_storage.cmi

jscomp/others/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ SOURCE_LIST= node_path node_fs node_process dict node_module js_array js_string
5151
belt_MutableStack\
5252
belt_MutableQueue\
5353
node_child_process \
54-
js_boolean js_math\
54+
js_math\
5555
js_dict js_date js_global js_cast js_promise\
5656
dom dom_storage\
5757
belt_HashMapInt\

jscomp/others/js_boolean.ml

-28
This file was deleted.

jscomp/others/js_boolean.mli

-27
This file was deleted.

jscomp/outcome_printer/outcome_printer_ns.ml

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ let out_ident ppf s =
4141
-> "Js.Array"
4242
| "Js_string"
4343
-> "Js.String"
44-
| "Js_boolean"
45-
-> "Js.Boolean"
4644
| "Js_re"
4745
-> "Js.Re"
4846
| "Js_promise"

jscomp/repl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ var cmi_files =
8181
// `lazy`,
8282
`js`, `js_unsafe`, `js_re`, `js_array`, `js_null`, `js_undefined`, `js_internal`,
8383
`js_types`, `js_null_undefined`, `js_dict`, `js_exn`, `js_string`, `js_vector`,
84-
`js_boolean`, `js_date`, `js_global`, `js_math`, `js_obj`, `js_int`,
84+
`js_date`, `js_global`, `js_math`, `js_obj`, `js_int`,
8585
`js_result`, `js_list`, `js_typed_array`,
8686
`js_promise`, `js_option`, `js_float`, `js_json`,
8787
`arrayLabels`, `bytesLabels`, `complex`, `gc`, `genlex`, `listLabels`,

jscomp/runtime/js.ml

+2-6
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ external nullToOption : 'a null -> 'a option = "#null_to_opt"
6767
external test : 'a nullable -> bool = "#is_nil_undef"
6868
external testAny : 'a -> bool = "#is_nil_undef"
6969

70-
type boolean = bool
71-
(** The JS boolean type, can be [Js.true_] or [Js.false_] *)
7270

7371
(* I'd like to move this and the other types into a Js_core module that can be
7472
included back here, but the dependency hackery confuses me *)
@@ -79,16 +77,15 @@ type (+'a, +'e) promise
7977

8078

8179
(* tag::predefined_js_values[]*)
82-
let true_ : boolean = true
83-
let false_ : boolean = false
80+
8481
external null : 'a null = "#null"
8582
(* The same as {!Js.Null.empty} will be compiled as [null]*)
8683
external undefined : 'a undefined = "#undefined"
8784
(* The same as {!Js.Undefined.empty} will be compiled as [undefined]*)
8885
(* end::predefined_js_values[]*)
8986

9087
(* tag::utility_functions[]*)
91-
external to_bool : boolean -> bool = "%identity"
88+
9289
external typeof : 'a -> string = "#typeof"
9390
(** [typeof x] will be compiled as [typeof x] in JS *)
9491
external log : 'a -> unit = "log"
@@ -134,7 +131,6 @@ module Exn = Js_exn
134131
{! Js_dict}, {! Js_array}, {! Js_string} and {! Js_re} for more details *)
135132

136133
module Array = Js_array
137-
module Boolean = Js_boolean
138134
module Date = Js_date
139135
module Dict = Js_dict
140136
module Global = Js_global

jscomp/runtime/js.mli

-17
Original file line numberDiff line numberDiff line change
@@ -82,34 +82,19 @@ external test : 'a nullable -> bool = "#is_nil_undef"
8282
(** The same as {!test} except that it is more permissive on the types of input *)
8383
external testAny : 'a -> bool = "#is_nil_undef"
8484

85-
type boolean = bool
86-
[@@ocaml.deprecated "Use type bool instead"]
87-
(** The value could be either {!Js.true_} or {!Js.false_}.
88-
Note in BuckleScript, [boolean] has different representation from OCaml's [bool],
89-
see conversion functions in {!Boolean} *)
9085

9186
type (+'a, +'e) promise
9287
(** The promise type, defined here for interoperation across packages
9388
@deprecated please use {!Js.Promise}
9489
*)
9590

96-
97-
val true_ : bool
98-
[@@ocaml.deprecated "Use true directly"]
99-
100-
val false_ : bool
101-
[@@ocaml.deprecated "Use false directly"]
102-
10391
external null : 'a null = "#null"
10492
(** The same as [empty] in {!Js.Null} will be compiled as [null]*)
10593

10694
external undefined : 'a undefined = "#undefined"
10795
(** The same as [empty] {!Js.Undefined} will be compiled as [undefined]*)
10896

10997

110-
external to_bool : bool -> bool = "%identity"
111-
[@@ocaml.deprecated "This function is not needed any more"]
112-
(** convert Js boolean to OCaml bool *)
11398

11499
external typeof : 'a -> string = "#typeof"
115100
(** [typeof x] will be compiled as [typeof x] in JS
@@ -172,8 +157,6 @@ module Array = Js_array
172157
(** Provide bindings to Js array*)
173158
module String = Js_string
174159
(** Provide bindings to JS string *)
175-
module Boolean = Js_boolean
176-
(** Provide utilities for {!boolean} *)
177160

178161
module Re = Js_re
179162
(** Provide bindings to Js regex expression *)

jscomp/test/mario_game.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ let keydown evt =
16611661
| 40 | 83 -> pressed_keys.down <- true
16621662
| 66 -> pressed_keys.bbox <- (pressed_keys.bbox + 1) mod 2
16631663
| _ -> ()
1664-
in Js.true_
1664+
in true
16651665

16661666
(* Keyup event handler translates a key release *)
16671667
let keyup evt =
@@ -1672,7 +1672,7 @@ let keyup evt =
16721672
| 37 | 65 -> pressed_keys.left <- false
16731673
| 40 | 83 -> pressed_keys.down <- false
16741674
| _ -> ()
1675-
in Js.true_
1675+
in true
16761676

16771677
end
16781678
module Procedural_generator : sig
@@ -2012,8 +2012,8 @@ let load _ =
20122012
| Some el -> Dom_html.elementToCanvasElement el
20132013
in
20142014
let context = (Dom_html.canvasElementToJsObj canvas)##getContext "2d" in
2015-
let _ = Dom_html.addEventListener Dom_html.document "keydown" (Director.keydown) Js.true_ in
2016-
let _ = Dom_html.addEventListener Dom_html.document "keyup" (Director.keyup) Js.true_ in
2015+
let _ = Dom_html.addEventListener Dom_html.document "keydown" (Director.keydown) true in
2016+
let _ = Dom_html.addEventListener Dom_html.document "keyup" (Director.keyup) true in
20172017
let () = Pg.init () in
20182018
let _ = Director.update_loop canvas (Pg.generate level_width level_height context) (level_width,level_height) in
20192019
print_endline "asd";
@@ -2032,9 +2032,9 @@ let preload _ =
20322032
let img = (Html.createImg Dom_html.document) in
20332033
(Dom_html.imageElementToJsObj img)##src #= (img_src) ;
20342034
ignore(Dom_html.addEventListenerImg img "load"
2035-
( (fun ev -> inc_counter(); Js.true_)) Js.true_)) imgs
2035+
( (fun ev -> inc_counter(); true)) true)) imgs
20362036

20372037

2038-
let _ = (Dom_html.windowToJsObj Dom_html.window)##onload #= (fun _ -> ignore (preload()); Js.true_)
2038+
let _ = (Dom_html.windowToJsObj Dom_html.window)##onload #= (fun _ -> ignore (preload()); true)
20392039

20402040
end

lib/js/js.js

-9
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ var MapperRt = 0;
55

66
var Internal = 0;
77

8-
var true_ = true;
9-
10-
var false_ = false;
11-
128
var Null = 0;
139

1410
var Undefined = 0;
@@ -23,8 +19,6 @@ var $$Array = 0;
2319

2420
var $$String = 0;
2521

26-
var $$Boolean = 0;
27-
2822
var Re = 0;
2923

3024
var Promise = 0;
@@ -61,16 +55,13 @@ var Console = 0;
6155

6256
exports.MapperRt = MapperRt;
6357
exports.Internal = Internal;
64-
exports.true_ = true_;
65-
exports.false_ = false_;
6658
exports.Null = Null;
6759
exports.Undefined = Undefined;
6860
exports.Nullable = Nullable;
6961
exports.Null_undefined = Null_undefined;
7062
exports.Exn = Exn;
7163
exports.$$Array = $$Array;
7264
exports.$$String = $$String;
73-
exports.$$Boolean = $$Boolean;
7465
exports.Re = Re;
7566
exports.Promise = Promise;
7667
exports.$$Date = $$Date;

lib/js/js_boolean.js

-1
This file was deleted.

lib/whole_compiler.ml

+1-3
Original file line numberDiff line numberDiff line change
@@ -75550,7 +75550,7 @@ let if_ (a : t) (b : t) c =
7555075550
end
7555175551

7555275552

75553-
75553+
(** TODO: the smart constructor is not exploited yet*)
7555475554
(** [l || r ] *)
7555575555
let sequor l r = if_ l true_ r
7555675556

@@ -117137,8 +117137,6 @@ let out_ident ppf s =
117137117137
-> "Js.Array"
117138117138
| "Js_string"
117139117139
-> "Js.String"
117140-
| "Js_boolean"
117141-
-> "Js.Boolean"
117142117140
| "Js_re"
117143117141
-> "Js.Re"
117144117142
| "Js_promise"

0 commit comments

Comments
 (0)