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
# Implementation for Seamless Scope-Safe Metaprogramming through Polymorphic Subtype Inference (Short Paper)
2
2
3
-
What would TypeScript look like if it had been designed with type inference and soundness in mind?
3
+
Our artifact implements the quasiquote syntax, type inference algorithm, and code generation on the MLscript compiler.
4
+
The artifact consists of two parts:
4
5
5
-
We provide one possible answer in MLscript, an object-oriented and functional programming language with records, generic classes, mix-in traits, first-class unions and intersections, instance matching, and ML-style principal type inference.
6
-
These features can be used to implement expressive class hierarchies as well as extensible sums and products.
6
+
- The main project is written in Scala and powered by sbt,
7
+
which includes the original MLscript compiler, our implementation, and corresponding test cases for quasiquote;
8
+
- The web demo allows users to compile and run general MLscript with our quasiquote system programs directly in browsers
9
+
and check type inference and execution results.
7
10
8
-
MLscript supports union, intersection, and complement (or negation) connectives, making sure they form a Boolean algebra, and add enough structure to derive a sound and complete type inference algorithm.
11
+
Our quasiquote system is implemented in the main project, on which the web demo is based.
9
12
10
-
## Getting Started
11
-
12
-
### Project Structure
13
-
14
-
#### Sub-Projects
15
-
16
-
- The ts2mls sub-project allows you to use TypeScript libraries in MLscript. It can generate libraries' declaration information in MLscript by parsing TypeScript AST, which can be used in MLscript type checking.
17
-
18
-
#### Directories
19
-
20
-
- The `shared/src/main/scala/mlscript` directory contains the sources of the MLscript compiler.
21
-
22
-
- The `shared/src/test/scala/mlscript` directory contains the sources of the testing infrastructure.
23
-
24
-
- The `shared/src/test/diff` directory contains the actual tests.
25
-
26
-
- The `ts2mls/js/src/main/scala/ts2mls` directory contains the sources of the ts2mls module.
27
-
28
-
- The `ts2mls/js/src/test/scala/ts2mls` directory contains the sources of the ts2mls declaration generation test code.
29
-
30
-
- The `ts2mls/jvm/src/test/scala/ts2mls` directory contains the sources of the ts2mls diff test code.
13
+
We implement our system as a part of [MLscript](https://github.com/hkust-taco/mlscript) with first-class support.
14
+
Both the parser and type checker of code quotation are integrated with the MLscript compiler,
15
+
which is written in Scala.
31
16
32
-
- The `ts2mls/js/src/test/typescript` directory contains the TypeScript test code.
33
-
34
-
- The `ts2mls/js/src/test/diff` directory contains the declarations generated by ts2mls.
35
-
36
-
### Prerequisites
17
+
## Getting Started
37
18
19
+
### Software Dependencies
38
20
You need [JDK supported by Scala][supported-jdk-versions], [sbt][sbt], [Node.js][node.js], and TypeScript to compile the project and run the tests.
39
21
22
+
### Installation
40
23
We recommend you to install JDK and sbt via [coursier][coursier]. The versions of Node.js that passed our tests are from v16.14 to v16.17, v17 and v18. Run `npm install` to install TypeScript. **Note that ScalaJS cannot find the global installed TypeScript.** We explicitly support TypeScript v4.7.4.
Running the main MLscript tests only requires the Scala Build Tool installed.
50
32
In the terminal, run `sbt mlscriptJVM/test`.
51
33
@@ -55,38 +37,15 @@ In the terminal, run `sbt ts2mlsTest/test`.
55
37
You can also run all tests simultaneously.
56
38
In the terminal, run `sbt test`.
57
39
58
-
### Running tests individually
59
-
60
40
Individual tests can be run with `-z`.
61
41
For example, `~mlscriptJVM/testOnly mlscript.DiffTests -- -z parser` will watch for file changes and continuously run all parser tests (those that have "parser" in their name).
62
42
63
-
You can also indicate the test you want in `shared/src/test/scala/mlscript/DiffTests.scala`:
64
-
65
-
```scala
66
-
// Allow overriding which specific tests to run, sometimes easier for development:
67
-
privatevalfocused=Set[Str](
68
-
// Add the test file path here like this:
69
-
"shared/src/test/diff/mlscript/Methods.mls"
70
-
).map(os.RelPath(_))
71
-
```
72
-
73
-
To run the tests in ts2mls sub-project individually,
74
-
you can indicate the test you want in `ts2mls/js/src/test/scala/ts2mls/TSTypeGenerationTests.scala`:
75
-
76
-
```scala
77
-
privatevaltestsData=List(
78
-
// Put all input files in the `Seq`
79
-
// Then indicate the output file's name
80
-
(Seq("Array.ts"), "Array.d.mls")
81
-
)
82
-
```
43
+
### Evaluation
44
+
Running the main MLscript tests only requires the Scala Build Tool installed.
45
+
In the terminal, run `sbt mlscriptJVM/test`.
83
46
84
-
### Running the web demo locally
47
+
To watch for file changes and continuously run the quasiquote tests,
48
+
execute `~mlscriptJVM/testOnly mlscript.DiffTests -- -z qq` in the sbt session.
85
49
86
50
To run the demo on your computer, compile the project with `sbt fastOptJS`, then open the `local_testing.html` file in your browser.
87
51
88
-
You can make changes to the type inference code
89
-
in `shared/src/main/scala/mlscript`,
90
-
have it compile to JavaScript on file change with command
91
-
`sbt ~fastOptJS`,
92
-
and immediately see the results in your browser by refreshing the page with `F5`.
0 commit comments