Skip to content

Commit b574afe

Browse files
committed
Stdlib namespace for Core modules
1 parent d23fa92 commit b574afe

File tree

270 files changed

+1763
-2109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+1763
-2109
lines changed

compiler/core/res_compmisc.ml

+4-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ let initial_env ?modulename () =
5454
let initial = Env.initial_safe_string in
5555
let env =
5656
if !Clflags.nopervasives then initial
57-
else open_implicit_module "Pervasives" initial
57+
else
58+
initial
59+
|> open_implicit_module "Pervasives"
60+
|> open_implicit_module "Stdlib"
5861
in
5962
List.fold_left
6063
(fun env m -> open_implicit_module m env)

compiler/ml/ast_untagged_variants.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ let type_to_instanceof_backed_obj (t : Types.type_expr) =
179179
| Tconstr (path, _, _) when Path.same path Predef.path_array -> Some Array
180180
| Tconstr (path, _, _) -> (
181181
match Path.name path with
182-
| "Js_date.t" -> Some Date
183-
| "Js_re.t" -> Some RegExp
182+
| "Stdlib_Date.t" -> Some Date
183+
| "Stdlib_RegExp.t" -> Some RegExp
184184
| "Js_file.t" -> Some File
185185
| "Js_blob.t" -> Some Blob
186186
| _ -> None)

lib/es6/Pervasives.js

-21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11

22

3-
import * as $$Error from "./Error.js";
4-
import * as Primitive_object from "./Primitive_object.js";
53
import * as Primitive_exceptions from "./Primitive_exceptions.js";
64

75
function failwith(s) {
@@ -117,21 +115,6 @@ function $at(l1, l2) {
117115
}
118116
}
119117

120-
function assertEqual(a, b) {
121-
if (!Primitive_object.notequal(a, b)) {
122-
return;
123-
}
124-
throw {
125-
RE_EXN_ID: "Assert_failure",
126-
_1: [
127-
"Pervasives.res",
128-
596,
129-
4
130-
],
131-
Error: new Error()
132-
};
133-
}
134-
135118
let max_int = 2147483647;
136119

137120
let infinity = Infinity;
@@ -144,8 +127,6 @@ let min_float = 2.22507385850720138e-308;
144127

145128
let epsilon_float = 2.22044604925031308e-16;
146129

147-
let panic = $$Error.panic;
148-
149130
export {
150131
failwith,
151132
invalid_arg,
@@ -166,7 +147,5 @@ export {
166147
bool_of_string_opt,
167148
int_of_string_opt,
168149
$at,
169-
panic,
170-
assertEqual,
171150
}
172151
/* No side effect */

lib/es6/Stdlib.js

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
2+
3+
import * as Stdlib_Error from "./Stdlib_Error.js";
4+
import * as Primitive_object from "./Primitive_object.js";
5+
6+
function assertEqual(a, b) {
7+
if (!Primitive_object.notequal(a, b)) {
8+
return;
9+
}
10+
throw {
11+
RE_EXN_ID: "Assert_failure",
12+
_1: [
13+
"Stdlib.res",
14+
117,
15+
4
16+
],
17+
Error: new Error()
18+
};
19+
}
20+
21+
let $$Array;
22+
23+
let $$BigInt;
24+
25+
let Console;
26+
27+
let $$DataView;
28+
29+
let $$Date;
30+
31+
let Dict;
32+
33+
let Exn;
34+
35+
let $$Error;
36+
37+
let Float;
38+
39+
let Int;
40+
41+
let $$Intl;
42+
43+
let $$JSON;
44+
45+
let List;
46+
47+
let $$Math;
48+
49+
let Null;
50+
51+
let Nullable;
52+
53+
let $$Object;
54+
55+
let Option;
56+
57+
let Ordering;
58+
59+
let $$Promise;
60+
61+
let $$RegExp;
62+
63+
let Result;
64+
65+
let $$String;
66+
67+
let $$Symbol;
68+
69+
let Type;
70+
71+
let $$Iterator;
72+
73+
let $$AsyncIterator;
74+
75+
let $$Map;
76+
77+
let $$WeakMap;
78+
79+
let $$Set;
80+
81+
let $$WeakSet;
82+
83+
let $$ArrayBuffer;
84+
85+
let $$TypedArray;
86+
87+
let $$Float32Array;
88+
89+
let $$Float64Array;
90+
91+
let $$Int8Array;
92+
93+
let $$Int16Array;
94+
95+
let $$Int32Array;
96+
97+
let $$Uint8Array;
98+
99+
let $$Uint16Array;
100+
101+
let $$Uint32Array;
102+
103+
let $$Uint8ClampedArray;
104+
105+
let $$BigInt64Array;
106+
107+
let $$BigUint64Array;
108+
109+
let panic = Stdlib_Error.panic;
110+
111+
export {
112+
$$Array,
113+
$$BigInt,
114+
Console,
115+
$$DataView,
116+
$$Date,
117+
Dict,
118+
Exn,
119+
$$Error,
120+
Float,
121+
Int,
122+
$$Intl,
123+
$$JSON,
124+
List,
125+
$$Math,
126+
Null,
127+
Nullable,
128+
$$Object,
129+
Option,
130+
Ordering,
131+
$$Promise,
132+
$$RegExp,
133+
Result,
134+
$$String,
135+
$$Symbol,
136+
Type,
137+
$$Iterator,
138+
$$AsyncIterator,
139+
$$Map,
140+
$$WeakMap,
141+
$$Set,
142+
$$WeakSet,
143+
$$ArrayBuffer,
144+
$$TypedArray,
145+
$$Float32Array,
146+
$$Float64Array,
147+
$$Int8Array,
148+
$$Int16Array,
149+
$$Int32Array,
150+
$$Uint8Array,
151+
$$Uint16Array,
152+
$$Uint32Array,
153+
$$Uint8ClampedArray,
154+
$$BigInt64Array,
155+
$$BigUint64Array,
156+
panic,
157+
assertEqual,
158+
}
159+
/* No side effect */
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/es6/Int.js lib/es6/Stdlib_Int.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
import * as $$Array from "./Array.js";
3+
import * as Stdlib_Array from "./Stdlib_Array.js";
44

55
function fromString(x, radix) {
66
let maybeInt = radix !== undefined ? parseInt(x, radix) : parseInt(x);
@@ -46,7 +46,7 @@ function range(start, end, optionsOpt) {
4646
let range$2 = options.inclusive === true ? range$1 + 1 | 0 : range$1;
4747
length = Math.ceil(range$2 / abs(step)) | 0;
4848
}
49-
return $$Array.fromInitializer(length, i => start + Math.imul(i, step) | 0);
49+
return Stdlib_Array.fromInitializer(length, i => start + Math.imul(i, step) | 0);
5050
}
5151

5252
function rangeWithOptions(start, end, options) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/es6/Intl_NumberFormat_Grouping.js lib/es6/Stdlib_Intl_NumberFormat_Grouping.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22

3-
import * as Type from "./Type.js";
3+
import * as Stdlib_Type from "./Stdlib_Type.js";
44

55
function parseJsValue(value) {
6-
let value$1 = Type.Classify.classify(value);
6+
let value$1 = Stdlib_Type.Classify.classify(value);
77
if (typeof value$1 !== "object") {
88
return;
99
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/es6/List.js lib/es6/Stdlib_List.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
import * as $$Array from "./Array.js";
3+
import * as Stdlib_Array from "./Stdlib_Array.js";
44
import * as Primitive_int from "./Primitive_int.js";
55
import * as Primitive_option from "./Primitive_option.js";
66

@@ -648,7 +648,7 @@ function toArray(x) {
648648

649649
function toShuffled(xs) {
650650
let v = toArray(xs);
651-
$$Array.shuffle(v);
651+
Stdlib_Array.shuffle(v);
652652
return fromArray(v);
653653
}
654654

File renamed without changes.
File renamed without changes.

lib/es6/Null.js lib/es6/Stdlib_Null.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
import * as Option from "./Option.js";
3+
import * as Stdlib_Option from "./Stdlib_Option.js";
44
import * as Primitive_option from "./Primitive_option.js";
55

66
function fromOption(option) {
@@ -12,11 +12,11 @@ function fromOption(option) {
1212
}
1313

1414
function equal(a, b, eq) {
15-
return Option.equal(a === null ? undefined : Primitive_option.some(a), b === null ? undefined : Primitive_option.some(b), eq);
15+
return Stdlib_Option.equal(a === null ? undefined : Primitive_option.some(a), b === null ? undefined : Primitive_option.some(b), eq);
1616
}
1717

1818
function compare(a, b, cmp) {
19-
return Option.compare(a === null ? undefined : Primitive_option.some(a), b === null ? undefined : Primitive_option.some(b), cmp);
19+
return Stdlib_Option.compare(a === null ? undefined : Primitive_option.some(a), b === null ? undefined : Primitive_option.some(b), cmp);
2020
}
2121

2222
function getOr(value, $$default) {

lib/es6/Nullable.js lib/es6/Stdlib_Nullable.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
import * as Option from "./Option.js";
3+
import * as Stdlib_Option from "./Stdlib_Option.js";
44
import * as Primitive_option from "./Primitive_option.js";
55

66
function fromOption(option) {
@@ -11,11 +11,11 @@ function fromOption(option) {
1111
}
1212

1313
function equal(a, b, eq) {
14-
return Option.equal((a == null) ? undefined : Primitive_option.some(a), (b == null) ? undefined : Primitive_option.some(b), eq);
14+
return Stdlib_Option.equal((a == null) ? undefined : Primitive_option.some(a), (b == null) ? undefined : Primitive_option.some(b), eq);
1515
}
1616

1717
function compare(a, b, cmp) {
18-
return Option.compare((a == null) ? undefined : Primitive_option.some(a), (b == null) ? undefined : Primitive_option.some(b), cmp);
18+
return Stdlib_Option.compare((a == null) ? undefined : Primitive_option.some(a), (b == null) ? undefined : Primitive_option.some(b), cmp);
1919
}
2020

2121
function getOr(value, $$default) {
File renamed without changes.

lib/es6/Option.js lib/es6/Stdlib_Option.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
import * as $$Error from "./Error.js";
3+
import * as Stdlib_Error from "./Stdlib_Error.js";
44
import * as Primitive_option from "./Primitive_option.js";
55

66
function filter(opt, p) {
@@ -21,7 +21,7 @@ function getExn(x, message) {
2121
if (x !== undefined) {
2222
return Primitive_option.valFromOption(x);
2323
} else {
24-
return $$Error.panic(message !== undefined ? message : "Option.getExn called for None value");
24+
return Stdlib_Error.panic(message !== undefined ? message : "Option.getExn called for None value");
2525
}
2626
}
2727

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/js/Pervasives.js

-21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict';
22

3-
let $$Error = require("./Error.js");
4-
let Primitive_object = require("./Primitive_object.js");
53
let Primitive_exceptions = require("./Primitive_exceptions.js");
64

75
function failwith(s) {
@@ -117,21 +115,6 @@ function $at(l1, l2) {
117115
}
118116
}
119117

120-
function assertEqual(a, b) {
121-
if (!Primitive_object.notequal(a, b)) {
122-
return;
123-
}
124-
throw {
125-
RE_EXN_ID: "Assert_failure",
126-
_1: [
127-
"Pervasives.res",
128-
596,
129-
4
130-
],
131-
Error: new Error()
132-
};
133-
}
134-
135118
let max_int = 2147483647;
136119

137120
let infinity = Infinity;
@@ -144,8 +127,6 @@ let min_float = 2.22507385850720138e-308;
144127

145128
let epsilon_float = 2.22044604925031308e-16;
146129

147-
let panic = $$Error.panic;
148-
149130
exports.failwith = failwith;
150131
exports.invalid_arg = invalid_arg;
151132
exports.Exit = Exit;
@@ -165,6 +146,4 @@ exports.bool_of_string = bool_of_string;
165146
exports.bool_of_string_opt = bool_of_string_opt;
166147
exports.int_of_string_opt = int_of_string_opt;
167148
exports.$at = $at;
168-
exports.panic = panic;
169-
exports.assertEqual = assertEqual;
170149
/* No side effect */

0 commit comments

Comments
 (0)