You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The BuckleScript announcement can be found on the <ahref="https://www.techatbloomberg.com/blog/bucklescript-1-0-release-arrived/">Tech at Bloomberg blog</a></p>
426
+
<p>The BuckleScript announcement can be found on the <ahref="https://www.techatbloomberg.com/blog/bucklescript-1-0-release-arrived/">Tech at Bloomberg blog</a></p>
Copy file name to clipboardexpand all lines: site/docsource/Build-system-support.adoc
+23-23
Original file line number
Diff line number
Diff line change
@@ -15,25 +15,25 @@ inlining, arity inference and other information.
15
15
16
16
=== BuckleScript build system: `bsb`
17
17
18
-
BuckleScript proivdes a native build tool on top of Google's https://github.com/ninja-build/ninja/releases[ninja-build].
19
-
It is designed for a fast feedback loop (typically 100ms feedback loop) and works cross platform.
18
+
BuckleScript provides a native build tool on top of Google's https://github.com/ninja-build/ninja/releases[ninja-build].
19
+
It is designed for a fast feedback loop (typically 100ms feedback loop) and works cross platform.
20
20
21
21
// [INFO]
22
22
// ======
23
23
// Currently for non-Windows users, they need to install ninja first (version >= 1.7.1).
24
-
// Please don't be confused with the npm ninja,
24
+
// Please don't be confused with the npm ninja,
25
25
// we are using Google's https://github.com/ninja-build/ninja/releases[ninja-build].
26
26
// ======
27
27
28
-
`bsb` can be running in any subdirectory. It is a schema based build tool and the schema is
28
+
`bsb` can be running in any subdirectory. It is a schema based build tool and the schema is
29
29
http://bloomberg.github.io/bucklescript/docson/#build-schema.json[available]. It is strongly recommended to **check out the http://bloomberg.github.io/bucklescript/docson/#build-schema.json[schema]**
30
30
after you finish reading the tutorials below.
31
31
32
-
If your editor supports JSON schema validation and auto-completion like https://code.visualstudio.com/docs/languages/json[VSCode],
32
+
If your editor supports JSON schema validation and auto-completion like https://code.visualstudio.com/docs/languages/json[VSCode],
33
33
below is a configuration to help you get auto-completion and validation for free:
34
34
35
35
.settings.json
36
-
[source,js]
36
+
[source,js]
37
37
------------
38
38
{
39
39
"json.schemas": [
@@ -45,20 +45,20 @@ below is a configuration to help you get auto-completion and validation for free
45
45
}
46
46
],
47
47
// ....
48
-
}
48
+
}
49
49
------------
50
50
51
-
The build system is installed as `bsb.exe` in `bs-platform/bin/bsb.exe`. Due to a known issue in npm,
52
-
we create a JS wrapper (which is accessible in `.bin` too) so the user can call
53
-
either `bsb` (slightly higher latency but symlinked into `.bin`) or `bsb.exe`
51
+
The build system is installed as `bsb.exe` in `bs-platform/bin/bsb.exe`. Due to a known issue in npm,
52
+
we create a JS wrapper (which is accessible in `.bin` too) so the user can call
53
+
either `bsb` (slightly higher latency but symlinked into `.bin`) or `bsb.exe`
54
54
55
55
56
56
Here is a *minimal* configuration:
57
57
58
58
.bsconfig.json
59
59
[source,js]
60
60
-----------
61
-
{
61
+
{
62
62
"name": "test", // package name, required <1>
63
63
"sources": "src" // <2>
64
64
}
@@ -68,8 +68,8 @@ Here is a *minimal* configuration:
68
68
69
69
70
70
The entry point is `bsb`.
71
-
It will check if there is already `build.ninja` in the build directory,
72
-
and if not or it needs to be regenerated it will generate the file `build.ninja`
71
+
It will check if there is already `build.ninja` in the build directory,
72
+
and if not or it needs to be regenerated it will generate the file `build.ninja`
73
73
and delegate the hard work to `ninja`.
74
74
75
75
@@ -96,7 +96,7 @@ The directory layout (after building) would be
96
96
└── test
97
97
-----------
98
98
<1> Will generate amdjs modules if flags are turned on
99
-
<2> Will generate goog modules if flags are turned on
99
+
<2> Will generate goog modules if flags are turned on
100
100
101
101
We wrap `bsb.exe` as `bsb` so that it will work across different platforms.
102
102
@@ -106,7 +106,7 @@ We wrap `bsb.exe` as `bsb` so that it will work across different platforms.
106
106
bsb // <1>
107
107
bsb -w // <2>
108
108
--------------------
109
-
<1> Do the plain build
109
+
<1> Do the plain build
110
110
<2> Do the plain build and watch
111
111
112
112
@@ -145,7 +145,7 @@ List your dependency in `bs-dependencies` and install it via `npm install` as be
@@ -251,7 +251,7 @@ Now, we have a repo https://github.com/bobzhang/bucklescript-have-tea[bucklescri
251
251
<1> List `bucklescript-tea` as dependency
252
252
<2> List `bs-platform` as peer dependency
253
253
254
-
Suppose you are in `bucklescript-have-tea` top directory,
254
+
Suppose you are in `bucklescript-have-tea` top directory,
255
255
256
256
[source,sh]
257
257
----------
@@ -268,17 +268,17 @@ You can also change the `package-specs` to have another module format, for examp
268
268
[source,js]
269
269
----------
270
270
{
271
-
... ,
271
+
... ,
272
272
"package-specs" : ["amdjs", "commonjs"],
273
273
...
274
274
}
275
275
----------
276
276
277
-
Rerun the command
277
+
Rerun the command
278
278
279
279
[source,sh]
280
280
----------
281
-
bsb -clean-world -make-world
281
+
bsb -clean-world -make-world
282
282
----------
283
283
284
284
You will get both `commonjs` and `amdjs` support. In the end, we suggest you http://bloomberg.github.io/bucklescript/docson/#build-schema.json[check out the schema] and enjoy the build!
@@ -288,7 +288,7 @@ You will get both `commonjs` and `amdjs` support. In the end, we suggest you htt
288
288
=== Build using Make
289
289
[WARNING]
290
290
========
291
-
`bsb` is the officially recommended build system. This section is included here only for people who
291
+
`bsb` is the officially recommended build system. This section is included here only for people who
Copy file name to clipboardexpand all lines: site/docsource/Exception-handling.adoc
+23-23
Original file line number
Diff line number
Diff line change
@@ -8,35 +8,35 @@ To catch Js exception on OCaml side, we categorize all JS exceptions to belong t
8
8
9
9
[source,ocaml]
10
10
--------------
11
-
let example1 () =
12
-
match Js.Json.exnParse {| {"x" }|} with
13
-
| exception Js.Exn.Error err ->
11
+
let example1 () =
12
+
match Js.Json.exnParse {| {"x" }|} with
13
+
| exception Js.Exn.Error err ->
14
14
Js.log @@ Js.Exn.stack err;
15
15
None
16
-
| v -> Some v
16
+
| v -> Some v
17
17
18
-
let example2 () =
19
-
try Some (Js.Json.exnParse {| {"x"}|}) with
18
+
let example2 () =
19
+
try Some (Js.Json.exnParse {| {"x"}|}) with
20
20
Js.Exn.Error _ -> None
21
21
--------------
22
22
23
23
The exception definition of `Js.Exn.Error` is as below:
24
24
25
25
[source,ocaml]
26
26
--------------
27
-
type t =
27
+
type t =
28
28
< stack : string Js.undefined ;
29
-
message : string Js.undefined ;
29
+
message : string Js.undefined ;
30
30
name : string Js.undefined;
31
31
fileName : string Js.undefined
32
32
> Js.t
33
33
34
-
exception Error of t
34
+
exception Error of t
35
35
--------------
36
36
37
37
### Raise JS style exception
38
38
39
-
We provide such functions
39
+
We provide such functions
40
40
41
41
[source,ocaml]
42
42
--------------
@@ -55,28 +55,28 @@ Please consult module `Js.Error` for more details
55
55
56
56
##`bs.open`: Type safe external data-source handling (@@since 1.7.0)
57
57
58
-
There are some cases, the data-source could either come from JS land or OCaml land, it is very hard to give precise type information.
58
+
There are some cases, the data-source could either come from JS land or OCaml land, it is very hard to give precise type information.
59
59
For example, for an external promise whose creation could come from JS API, its failed value caused by `Promise.reject` could be in any shape.
60
60
61
-
BuckleScript provides a solution to filter out OCaml structured exception data from the mixed data source,
62
-
it preserves the type safety while allow uesrs to deal with mixed source.
61
+
BuckleScript provides a solution to filter out OCaml structured exception data from the mixed data source,
62
+
it preserves the type safety while allow users to deal with mixed source.
63
63
64
-
It makes use of OCaml's extensible variant, so that uers can pack mix value of type `exn` with JS data-source
64
+
It makes use of OCaml's extensible variant, so that users can pack mix value of type `exn` with JS data-source
65
65
66
66
.Example
67
67
[source,ocaml]
68
68
--------------
69
69
let handleData = function [@bs.open]
70
70
| Invalid_argument _ -> 0
71
-
| Not_found -> 1
72
-
| Sys_error _ -> 2
71
+
| Not_found -> 1
72
+
| Sys_error _ -> 2
73
73
74
74
val handleData : 'a -> int option // <1>
75
75
--------------
76
76
<1> For any input source, as long as it matches the exception pattern (nested pattern match supported), the matched value is returned, otherwise return None.
Copy file name to clipboardexpand all lines: site/docsource/FAQ.adoc
+2-2
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
6
6
How does IO work in the browser?::
7
-
In general, it is very hard to simulate IO in the browser, we recommend users write bindings to NodeJS directly for server side, or use `Js.log` in client side, see disucssions in {issues}/748[#748]
7
+
In general, it is very hard to simulate IO in the browser, we recommend users write bindings to NodeJS directly for server side, or use `Js.log` in client side, see discussions in {issues}/748[#748]
8
8
9
9
The compiler does not build?::
10
10
In production mode, the compiler is a single file in
@@ -70,7 +70,7 @@ Error: The type of this expression, ([ `Arity_1 of '_a ], '_a) Js.fn,
70
70
contains type variables that cannot be generalized
71
71
--------
72
72
73
-
The issue here isn't that the function is polymorphic. You can use (and probably have used) polymorphic uncurried functions without any problem as inline callbacks. But you can't export them. The issue here is the combination of using the uncurried calling convention, polymorphism and exporting (by default). It's an unfortunate limitation partly due to how OCaml's type system incorporates side-effects, and partly due to how BuckleScript handles uncurrying. The simplest solution is in most cases to just not export it, by adding an interface to the module. Alternatively, if you really, really need to export it, you can do so in its curried form, and then wrap it in an uncurried lanbda at the call site. E.g.:
73
+
The issue here isn't that the function is polymorphic. You can use (and probably have used) polymorphic uncurried functions without any problem as inline callbacks. But you can't export them. The issue here is the combination of using the uncurried calling convention, polymorphism and exporting (by default). It's an unfortunate limitation partly due to how OCaml's type system incorporates side-effects, and partly due to how BuckleScript handles uncurrying. The simplest solution is in most cases to just not export it, by adding an interface to the module. Alternatively, if you really, really need to export it, you can do so in its curried form, and then wrap it in an uncurried lambda at the call site. E.g.:
Copy file name to clipboardexpand all lines: site/docsource/Get_started.adoc
+3-3
Original file line number
Diff line number
Diff line change
@@ -31,10 +31,10 @@ hello>tree -d .
31
31
To enter watch mode, you can run `npm run watch`,
32
32
then you can edit `src/demo.ml` and see it compiled on the fly, and changes are updated on `lib/js/src/demo.js`
33
33
34
-
If you happen to use VSCode as editor, we provide `.vscode/tasks.json` as well, type `Tasks>build`, it will enter watch mode, the great thing is that VSCode comes with
35
-
a `Problems` panel which has a much nicer UI.
34
+
If you happen to use VSCode as editor, we provide `.vscode/tasks.json` as well, type `Tasks>build`, it will enter watch mode, the great thing is that VSCode comes with
35
+
a `Problems` panel which has a much nicer UI.
36
36
37
-
Currently there are not too many project templates, you can contribute more project templates here https://github.com/bloomberg/bucklescript/tree/master/jscomp/bsb/templates[here],
37
+
Currently there are not too many project templates, you can contribute more project templates here https://github.com/bloomberg/bucklescript/tree/master/jscomp/bsb/templates[here],
0 commit comments