Skip to content

Commit c768c28

Browse files
Open ReScript Core by default
1 parent 87673cb commit c768c28

13 files changed

+44
-45
lines changed

rescript.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
],
1212
"uncurried": true,
1313
"ppx-flags": [],
14-
"bsc-flags": [],
14+
"bsc-flags": [
15+
"-open RescriptCore"
16+
],
1517
"sources": [
1618
{
1719
"dir": "src",

src/Blog.res

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
module Link = Next.Link
17-
open RescriptCore
1817

1918
let defaultPreviewImg = "/static/Art-3-rescript-launch.jpg"
2019

src/BlogArticle.res

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
builds are taking too long. I think we will be fine for now.
1717
Link to NextJS discussion: https://github.com/zeit/next.js/discussions/11728#discussioncomment-3501
1818
*/
19-
open RescriptCore
2019

2120
let middleDotSpacer = " " ++ (String.fromCharCode(183) ++ " ")
2221

src/Design.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// NOTE: This file will later be important to document our
22
// design tokens etc.
3-
open RescriptCore
3+
44
module ColorSquare = {
55
@react.component
66
let make = (~className="") => {

src/DocsOverview.res

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
open RescriptCore
21
module Card = {
32
@react.component
43
let make = (~title: string, ~hrefs: array<(string, string)>) => {

src/SyntaxLookup.res

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ module Status = {
5555

5656
let compare = (a, b) =>
5757
switch (a, b) {
58-
| (Deprecated, Deprecated) | (Active, Active) => 0
59-
| (Active, Deprecated) => -1
60-
| (Deprecated, Active) => 1
58+
| (Deprecated, Deprecated) | (Active, Active) => Ordering.equal
59+
| (Active, Deprecated) => Ordering.less
60+
| (Deprecated, Active) => Ordering.greater
6161
}
6262
}
6363

@@ -76,7 +76,7 @@ module Item = {
7676

7777
let compare = (a, b) =>
7878
switch Status.compare(a.status, b.status) {
79-
| 0 => String.compare(a.name, b.name)
79+
| 0. => String.compare(a.name, b.name)
8080
| x => x
8181
}
8282
}
@@ -299,15 +299,15 @@ let default = (props: props) => {
299299
})
300300
})
301301
->Js.Dict.entries
302-
->Belt.Array.reduce([], (acc, entry) => {
302+
->Array.reduce([], (acc, entry) => {
303303
let (title, items) = entry
304-
if Js.Array.length(items) === 0 {
304+
if Array.length(items) === 0 {
305305
acc
306306
} else {
307307
let children =
308308
items
309-
->Belt.SortArray.stableSortBy(Item.compare)
310-
->Belt.Array.map(item => {
309+
->Array.toSorted(Item.compare)
310+
->Array.map(item => {
311311
let onMouseDown = evt => {
312312
ReactEvent.Mouse.preventDefault(evt)
313313
onSearchValueChange(item.name)

src/bindings/RescriptCompilerApi.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ module LocMsg = {
128128
let result = Js.Dict.empty()
129129

130130
for i in 0 to Js.Array.length(arr) - 1 {
131-
let locMsg = Js.Array2.unsafe_get(arr, i)
131+
let locMsg = Array.getUnsafe(arr, i)
132132
let id = makeId(locMsg)
133133

134134
// The last element with the same id wins

src/common/Ansi.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ module Lexer = {
182182
switch x {
183183
| Some(result) =>
184184
let groups = Js.Re.captures(result)
185-
switch Js.Nullable.toOption(groups[1]) {
185+
switch groups[1]->Option.flatMap(o => o->Js.Nullable.toOption) {
186186
| Some(str) =>
187187
switch Js.String2.split(str, ";") {
188188
| ["0"] => ClearSgr({loc, raw})

src/common/BlogApi.res

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ let getAllPosts = () => {
7676
}
7777
})
7878

79-
Js.Array2.concat(nonArchivedPosts, archivedPosts)->Js.Array2.sortInPlaceWith((a, b) => {
79+
Array.concat(nonArchivedPosts, archivedPosts)->Array.toSorted((a, b) =>
8080
String.compare(Node.Path.basename(b.path), Node.Path.basename(a.path))
81-
})
81+
)
8282
}
8383

8484
let getLivePosts = () => {
@@ -97,9 +97,9 @@ let getLivePosts = () => {
9797
}
9898
})
9999

100-
livePosts->Js.Array2.sortInPlaceWith((a, b) => {
100+
livePosts->Array.toSorted((a, b) =>
101101
String.compare(Node.Path.basename(b.path), Node.Path.basename(a.path))
102-
})
102+
)
103103
}
104104

105105
let getArchivedPosts = () => {
@@ -119,9 +119,9 @@ let getArchivedPosts = () => {
119119
}
120120
})
121121

122-
archivedPosts->Js.Array2.sortInPlaceWith((a, b) => {
122+
archivedPosts->Array.toSorted((a, b) =>
123123
String.compare(Node.Path.basename(b.path), Node.Path.basename(a.path))
124-
})
124+
)
125125
}
126126

127127
module RssFeed = {
@@ -156,7 +156,7 @@ module RssFeed = {
156156
let getLatest = (~max=10, ~baseUrl="https://rescript-lang.org", ()): array<item> => {
157157
let items =
158158
getAllPosts()
159-
->Js.Array2.map(post => {
159+
->Array.map(post => {
160160
let fm = post.frontmatter
161161
let description = Js.Null.toOption(fm.description)->Belt.Option.getWithDefault("")
162162
{
@@ -166,7 +166,7 @@ module RssFeed = {
166166
pubDate: DateStr.toDate(fm.date),
167167
}
168168
})
169-
->Js.Array2.slice(~start=0, ~end_=max)
169+
->Array.slice(~start=0, ~end=max)
170170
items
171171
}
172172

src/common/Url.res

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ let parse = (route: string): t => {
6464
(NoVersion, fullpath, [])
6565
} else {
6666
let version = switch fullpath[foundVersionIndex] {
67-
| "latest" => Latest
68-
| v => Version(v)
67+
| Some("latest") => Latest
68+
| Some(v) => Version(v)
69+
| None => NoVersion
6970
}
7071
(
7172
version,

src/components/AnsiPre.res

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// This file was automatically converted to ReScript from 'AnsiPre.re'
22
// Check the output and make sure to delete the original file
33
open Ansi
4-
open RescriptCore
54

65
type colorTarget =
76
| Fg

src/vendor/Json_decode.res

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let string = json =>
4343
let char = json => {
4444
let s = string(json)
4545
if String.length(s) == 1 {
46-
String.get(s, 0)
46+
OCamlCompat.String.get(s, 0)
4747
} else {
4848
\"@@"(raise, DecodeError("Expected single-character string, got " ++ _stringify(json)))
4949
}
@@ -72,26 +72,26 @@ let array = (decode, json) =>
7272
let length = Js.Array.length(source)
7373
let target = _unsafeCreateUninitializedArray(length)
7474
for i in 0 to length - 1 {
75-
let value = try decode(Array.unsafe_get(source, i)) catch {
75+
let value = try decode(Array.getUnsafe(source, i)) catch {
7676
| DecodeError(msg) =>
7777
\"@@"(raise, DecodeError(msg ++ ("\n\tin array at index " ++ string_of_int(i))))
7878
}
7979

80-
Array.unsafe_set(target, i, value)
80+
Array.setUnsafe(target, i, value)
8181
}
8282
target
8383
} else {
8484
\"@@"(raise, DecodeError("Expected array, got " ++ _stringify(json)))
8585
}
8686

87-
let list = (decode, json) => array(decode, json)->Array.to_list
87+
let list = (decode, json) => array(decode, json)->List.fromArray
8888

8989
let pair = (decodeA, decodeB, json) =>
9090
if Js.Array.isArray(json) {
9191
let source: array<Js.Json.t> = Obj.magic((json: Js.Json.t))
9292
let length = Js.Array.length(source)
9393
if length == 2 {
94-
try (decodeA(Array.unsafe_get(source, 0)), decodeB(Array.unsafe_get(source, 1))) catch {
94+
try (decodeA(Array.getUnsafe(source, 0)), decodeB(Array.getUnsafe(source, 1))) catch {
9595
| DecodeError(msg) => \"@@"(raise, DecodeError(msg ++ "\n\tin pair/tuple2"))
9696
}
9797
} else {
@@ -112,9 +112,9 @@ let tuple3 = (decodeA, decodeB, decodeC, json) =>
112112
let length = Js.Array.length(source)
113113
if length == 3 {
114114
try (
115-
decodeA(Array.unsafe_get(source, 0)),
116-
decodeB(Array.unsafe_get(source, 1)),
117-
decodeC(Array.unsafe_get(source, 2)),
115+
decodeA(Array.getUnsafe(source, 0)),
116+
decodeB(Array.getUnsafe(source, 1)),
117+
decodeC(Array.getUnsafe(source, 2)),
118118
) catch {
119119
| DecodeError(msg) => \"@@"(raise, DecodeError(msg ++ "\n\tin tuple3"))
120120
}
@@ -134,10 +134,10 @@ let tuple4 = (decodeA, decodeB, decodeC, decodeD, json) =>
134134
let length = Js.Array.length(source)
135135
if length == 4 {
136136
try (
137-
decodeA(Array.unsafe_get(source, 0)),
138-
decodeB(Array.unsafe_get(source, 1)),
139-
decodeC(Array.unsafe_get(source, 2)),
140-
decodeD(Array.unsafe_get(source, 3)),
137+
decodeA(Array.getUnsafe(source, 0)),
138+
decodeB(Array.getUnsafe(source, 1)),
139+
decodeC(Array.getUnsafe(source, 2)),
140+
decodeD(Array.getUnsafe(source, 3)),
141141
) catch {
142142
| DecodeError(msg) => \"@@"(raise, DecodeError(msg ++ "\n\tin tuple4"))
143143
}
@@ -162,7 +162,7 @@ let dict = (decode, json) =>
162162
let l = Js.Array.length(keys)
163163
let target = Js.Dict.empty()
164164
for i in 0 to l - 1 {
165-
let key = Array.unsafe_get(keys, i)
165+
let key = Array.getUnsafe(keys, i)
166166
let value = try decode(Js.Dict.unsafeGet(source, key)) catch {
167167
| DecodeError(msg) => \"@@"(raise, DecodeError(msg ++ "\n\tin dict"))
168168
}
@@ -208,7 +208,7 @@ let oneOf = (decoders, json) => {
208208
let rec inner = (decoders, errors) =>
209209
switch decoders {
210210
| list{} =>
211-
let formattedErrors = "\n- " ++ Js.Array.joinWith("\n- ", Array.of_list(List.rev(errors)))
211+
let formattedErrors = "\n- " ++ Js.Array.joinWith("\n- ", List.toArray(List.reverse(errors)))
212212
\"@@"(
213213
raise,
214214
DecodeError(

src/vendor/Json_encode.res

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ external float: float => Js.Json.t = "%identity"
66
external int: int => Js.Json.t = "%identity"
77
external bool: bool => Js.Json.t = "%identity"
88

9-
let char = c => string(String.make(1, c))
9+
let char = c => string(OCamlCompat.String.make(1, c))
1010

1111
let date = d => string(Js.Date.toJSONUnsafe(d))
1212

@@ -25,24 +25,24 @@ let withDefault = (d, encode, x) =>
2525
external jsonDict: Js_dict.t<Js.Json.t> => Js.Json.t = "%identity"
2626
let dict = (encode, d) => {
2727
let pairs = Js.Dict.entries(d)
28-
let encodedPairs = Array.map(((k, v)) => (k, encode(v)), pairs)
28+
let encodedPairs = pairs->Array.map(((k, v)) => (k, encode(v)))
2929
jsonDict(Js.Dict.fromArray(encodedPairs))
3030
}
3131

3232
let object_ = (props): Js.Json.t => jsonDict(Js.Dict.fromList(props))
3333

3434
external jsonArray: array<Js.Json.t> => Js.Json.t = "%identity"
35-
let array = (encode, l) => jsonArray(Array.map(x => encode(x), l))
35+
let array = (encode, l) => jsonArray(l->Array.map(x => encode(x)))
3636
let list = (encode, x) =>
3737
switch x {
3838
| list{} => jsonArray([])
3939
| list{hd, ...tl} as l =>
40-
let a = Array.make(List.length(l), encode(hd))
40+
let a = encode(hd)->Array.make(~length=List.length(l))
4141
let rec fill = (i, x) =>
4242
switch x {
4343
| list{} => a
4444
| list{hd, ...tl} =>
45-
Array.unsafe_set(a, i, encode(hd))
45+
Array.setUnsafe(a, i, encode(hd))
4646
fill(i + 1, tl)
4747
}
4848

0 commit comments

Comments
 (0)