Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilKleistGao committed Sep 3, 2024
1 parent 5bbf47d commit cd31033
Showing 1 changed file with 20 additions and 61 deletions.
81 changes: 20 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,33 @@
# MLscript
# Implementation for Seamless Scope-Safe Metaprogramming through Polymorphic Subtype Inference (Short Paper)

What would TypeScript look like if it had been designed with type inference and soundness in mind?
Our artifact implements the quasiquote syntax, type inference algorithm, and code generation on the MLscript compiler.
The artifact consists of two parts:

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.
These features can be used to implement expressive class hierarchies as well as extensible sums and products.
- The main project is written in Scala and powered by sbt,
which includes the original MLscript compiler, our implementation, and corresponding test cases for quasiquote;
- The web demo allows users to compile and run general MLscript with our quasiquote system programs directly in browsers
and check type inference and execution results.

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.
Our quasiquote system is implemented in the main project, on which the web demo is based.

## Getting Started

### Project Structure

#### Sub-Projects

- 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.

#### Directories

- The `shared/src/main/scala/mlscript` directory contains the sources of the MLscript compiler.

- The `shared/src/test/scala/mlscript` directory contains the sources of the testing infrastructure.

- The `shared/src/test/diff` directory contains the actual tests.

- The `ts2mls/js/src/main/scala/ts2mls` directory contains the sources of the ts2mls module.

- The `ts2mls/js/src/test/scala/ts2mls` directory contains the sources of the ts2mls declaration generation test code.

- The `ts2mls/jvm/src/test/scala/ts2mls` directory contains the sources of the ts2mls diff test code.
We implement our system as a part of [MLscript](https://github.com/hkust-taco/mlscript) with first-class support.
Both the parser and type checker of code quotation are integrated with the MLscript compiler,
which is written in Scala.

- The `ts2mls/js/src/test/typescript` directory contains the TypeScript test code.

- The `ts2mls/js/src/test/diff` directory contains the declarations generated by ts2mls.

### Prerequisites
## Getting Started

### Software Dependencies
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.

### Installation
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.

[supported-jdk-versions]: https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html
[sbt]: https://www.scala-sbt.org/
[node.js]: https://nodejs.org/
[coursier]: https://get-coursier.io/

### Running the tests

### Other Instructions
Running the main MLscript tests only requires the Scala Build Tool installed.
In the terminal, run `sbt mlscriptJVM/test`.

Expand All @@ -55,38 +37,15 @@ In the terminal, run `sbt ts2mlsTest/test`.
You can also run all tests simultaneously.
In the terminal, run `sbt test`.

### Running tests individually

Individual tests can be run with `-z`.
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).

You can also indicate the test you want in `shared/src/test/scala/mlscript/DiffTests.scala`:

```scala
// Allow overriding which specific tests to run, sometimes easier for development:
private val focused = Set[Str](
// Add the test file path here like this:
"shared/src/test/diff/mlscript/Methods.mls"
).map(os.RelPath(_))
```

To run the tests in ts2mls sub-project individually,
you can indicate the test you want in `ts2mls/js/src/test/scala/ts2mls/TSTypeGenerationTests.scala`:

```scala
private val testsData = List(
// Put all input files in the `Seq`
// Then indicate the output file's name
(Seq("Array.ts"), "Array.d.mls")
)
```
### Evaluation
Running the main MLscript tests only requires the Scala Build Tool installed.
In the terminal, run `sbt mlscriptJVM/test`.

### Running the web demo locally
To watch for file changes and continuously run the quasiquote tests,
execute `~mlscriptJVM/testOnly mlscript.DiffTests -- -z qq` in the sbt session.

To run the demo on your computer, compile the project with `sbt fastOptJS`, then open the `local_testing.html` file in your browser.

You can make changes to the type inference code
in `shared/src/main/scala/mlscript`,
have it compile to JavaScript on file change with command
`sbt ~fastOptJS`,
and immediately see the results in your browser by refreshing the page with `F5`.

0 comments on commit cd31033

Please sign in to comment.