Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 3eb03e4

Browse files
committed
Convert RescriptEditorSupport.re to unmonad
1 parent 5e804eb commit 3eb03e4

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

src/rescript-editor-support/RescriptEditorSupport.re

+38-35
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,47 @@ let capabilities =
2525

2626
let getInitialState = params => {
2727
let rootUri = Json.get("rootUri", params) |?> Json.string |?> Uri2.parse;
28-
let%try rootUri = rootUri |> RResult.orError("Not a uri");
29-
let rootPath = Uri2.toPath(rootUri);
30-
31-
Files.mkdirp(rootPath /+ "node_modules" /+ ".lsp");
32-
Log.setLocation(rootPath /+ "node_modules" /+ ".lsp" /+ "debug.log");
33-
Log.log("Hello - from " ++ Sys.executable_name);
34-
35-
Rpc.sendNotification(
36-
stdout,
37-
"client/registerCapability",
38-
J.o([
39-
(
40-
"registrations",
41-
J.l([
42-
J.o([
43-
("id", J.s("watching")),
44-
("method", J.s("workspace/didChangeWatchedFiles")),
45-
(
46-
"registerOptions",
47-
J.o([
48-
(
49-
"watchers",
50-
J.l([
51-
J.o([("globPattern", J.s("**/bsconfig.json"))]),
52-
J.o([("globPattern", J.s("**/.merlin"))]),
53-
]),
54-
),
55-
]),
56-
),
28+
switch (rootUri |> RResult.orError("Not a uri")) {
29+
| Error(e) => Error(e)
30+
| Ok(rootUri) =>
31+
let rootPath = Uri2.toPath(rootUri);
32+
33+
Files.mkdirp(rootPath /+ "node_modules" /+ ".lsp");
34+
Log.setLocation(rootPath /+ "node_modules" /+ ".lsp" /+ "debug.log");
35+
Log.log("Hello - from " ++ Sys.executable_name);
36+
37+
Rpc.sendNotification(
38+
stdout,
39+
"client/registerCapability",
40+
J.o([
41+
(
42+
"registrations",
43+
J.l([
44+
J.o([
45+
("id", J.s("watching")),
46+
("method", J.s("workspace/didChangeWatchedFiles")),
47+
(
48+
"registerOptions",
49+
J.o([
50+
(
51+
"watchers",
52+
J.l([
53+
J.o([("globPattern", J.s("**/bsconfig.json"))]),
54+
J.o([("globPattern", J.s("**/.merlin"))]),
55+
]),
56+
),
57+
]),
58+
),
59+
]),
5760
]),
58-
]),
59-
),
60-
]),
61-
);
61+
),
62+
]),
63+
);
6264

63-
let state = TopTypes.empty();
65+
let state = TopTypes.empty();
6466

65-
Ok(state);
67+
Ok(state);
68+
};
6669
};
6770

6871
let parseArgs = args => {

0 commit comments

Comments
 (0)