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

Commit 945b246

Browse files
committed
Test stripping monadic ppx
I've built ppx_monad as a standalone binary, ran it through the file, printed it back to reason, and hand-adjusted the rest (since whitespace, comments, braces and tuples are lost during this pass). This code should be correct without needing to test.
1 parent aa00832 commit 945b246

File tree

2 files changed

+45
-36
lines changed

2 files changed

+45
-36
lines changed

src/rescript-editor-support/BuildSystem.re

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ let getCompiledBase = root => {
3434
Files.ifExists(root /+ "lib" /+ "bs");
3535
};
3636
let getStdlib = base => {
37-
let%try_wrap bsPlatformDir = getBsPlatformDir(base);
38-
bsPlatformDir /+ "lib" /+ "ocaml";
37+
Monads.Result.map(getBsPlatformDir(base), ~f=bsPlatformDir =>
38+
bsPlatformDir /+ "lib" /+ "ocaml"
39+
);
3940
};

src/rescript-editor-support/FindFiles.re

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -299,36 +299,40 @@ let findDependencyFiles = (~debug, base, config) => {
299299
let namespace = getNamespace(inner);
300300
let directories =
301301
getSourceDirectories(~includeDev=false, loc, inner);
302-
let%opt compiledBase = BuildSystem.getCompiledBase(loc);
303-
/* |! "No compiled base found"; */
304-
if (debug) {
305-
Log.log("Compiled base: " ++ compiledBase);
306-
};
307-
let compiledDirectories =
308-
directories |> List.map(Files.fileConcat(compiledBase));
309-
let compiledDirectories =
310-
namespace == None
311-
? compiledDirectories
312-
: [compiledBase, ...compiledDirectories];
313-
let files =
314-
findProjectFiles(
315-
~debug,
316-
namespace,
317-
loc,
318-
directories,
319-
compiledBase,
320-
);
321-
/* let files =
322-
switch (namespace) {
323-
| None =>
324-
files
325-
| Some(namespace) =>
326-
files
327-
|> List.map(((name, paths)) =>
328-
(namespace ++ "-" ++ name, paths)
329-
)
330-
}; */
331-
Some((compiledDirectories, files));
302+
Monads.Option.bind(
303+
BuildSystem.getCompiledBase(loc),
304+
~f=compiledBase => {
305+
/* |! "No compiled base found"; */
306+
if (debug) {
307+
Log.log("Compiled base: " ++ compiledBase);
308+
};
309+
let compiledDirectories =
310+
directories |> List.map(Files.fileConcat(compiledBase));
311+
let compiledDirectories =
312+
namespace == None
313+
? compiledDirectories
314+
: [compiledBase, ...compiledDirectories];
315+
let files =
316+
findProjectFiles(
317+
~debug,
318+
namespace,
319+
loc,
320+
directories,
321+
compiledBase,
322+
);
323+
/* let files =
324+
switch (namespace) {
325+
| None =>
326+
files
327+
| Some(namespace) =>
328+
files
329+
|> List.map(((name, paths)) =>
330+
(namespace ++ "-" ++ name, paths)
331+
)
332+
}; */
333+
Some((compiledDirectories, files));
334+
},
335+
);
332336
| None => None
333337
};
334338
}
@@ -343,8 +347,12 @@ let findDependencyFiles = (~debug, base, config) => {
343347
});
344348
let (directories, files) = List.split(depFiles);
345349
let files = List.concat(files);
346-
let%try stdlibDirectory = BuildSystem.getStdlib(base);
347-
let directories = [stdlibDirectory, ...List.concat(directories)];
348-
let results = files @ collectFiles(stdlibDirectory);
349-
Ok((directories, results));
350+
Monads.Result.bind(
351+
BuildSystem.getStdlib(base),
352+
~f=stdlibDirectory => {
353+
let directories = [stdlibDirectory, ...List.concat(directories)];
354+
let results = files @ collectFiles(stdlibDirectory);
355+
Ok((directories, results));
356+
},
357+
);
350358
};

0 commit comments

Comments
 (0)