Skip to content

Commit 1070b77

Browse files
committed
Update documentation based on review comments
1 parent 14c2688 commit 1070b77

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

hmloc-codebase-doc.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The typer accepts the abstract syntax tree of a program
4444
and performs type inference. It tracks source locations of the program terms.
4545
It wraps the inferred type with the provenance that contains the source location
4646
of the corresponding terms.
47-
For more information about the type system, see the paper.
47+
For more information about the type system, see section 3 of the paper.
4848

4949
The corresponding files are:
5050
- `Typer.scala` contains the main typer class.
@@ -98,7 +98,7 @@ adds them to the `Ctx`.
9898

9999
`UnificationSolver.scala` defines the `UnificationSolver` class which unifies types.
100100
Unification is particularly interesting because it tracks the data flow through
101-
source code locations. As described in the corresponding paper, it uses
101+
source code locations. As described in section 4 of the corresponding paper, it uses
102102
the provenance of types, which contains the source code locations,
103103
to track the data flow.
104104

oopsla23-artifact-overview.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ HMloc. Type errors for programs show detailed data flow information. The artifac
3939
includes a test suite and many example programs and their reported errors.
4040

4141
The `shared/src/test/diff/ocaml` directory contains tests. Some notable ones are:
42-
- `Survey*.mls` are the example programs used in user survey described in the paper
42+
- `OriginalDraftIntro.mls` has the introductory examples covered in the paper in section 1 and 2
43+
- `Survey*.mls` are the example programs used in user survey described in the paper. The exact user survey program and errors are in the appendix and the results are discussed in section 5 of the paper. Note: that the extra wordings/format might have changed since the user survey however the core data flow information and visualization is retained.
4344
- `OcamlPresentation.mls` - demonstrates a variety of errors
4445
- `LetPoly.mls` - shows errors in code that uses let polymorphism
4546
- `Realistic.mls` - shows examples that might occur in an actual codebase
@@ -86,8 +87,7 @@ docker build --tag 'hmloc-oopsla23' .
8687
docker run -it --rm 'hmloc-oopsla23'
8788
```
8889

89-
The user will be attached to the shell of the container after the image gets pulled and the container is launched.
90-
Please `cd` to `hmloc/` and launch the SBT shell by typing `sbt`.
90+
The user will be attached to the shell of the container after the image gets pulled and the container is launched. Launch the SBT shell by typing `sbt`.
9191

9292
### Setting up from Scratch
9393

@@ -98,7 +98,7 @@ Please `cd` to `hmloc/` and launch the SBT shell by typing `sbt`.
9898

9999
## Experimenting with HMloc
100100

101-
We provide two ways of experimenting with HMloc. A test suite that runs example files and a web demo where the user can type their programs and see the results live.
101+
We provide two ways of experimenting with HMloc. A test suite that runs example files and a web demo where the user can type their programs and see the results live. The error messages can sometimes can get quite verbose. This is currently a limitation of this approach as is discussed in section 5.4 of the paper.
102102

103103
We recommend using the the test suite.
104104

@@ -135,3 +135,5 @@ then open the `local_testing.html` file in a browser.
135135
| **Top level declarations** | | |
136136
| definition | val foo: T | def foo x = t |
137137
| algebraic data type | `type 'a list = Cons of ('a, 'a list) \| Nil` | Cons(1, Nil) |
138+
139+
The syntax for HMloc is a derived from a reduced subset of OCaml. The parser implementation is custom and does not handle all the corner cases expected of a full parser implementation. We encourage users to reference existing examples for specific nuances concerning the syntax.

shared/src/main/scala/hmloc/Typer.scala

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import scala.collection.mutable.{Map => MutMap}
1010
/** A class encapsulating type inference state.
1111
* It uses its own internal representation of types and type variables, using mutable data structures.
1212
* Inferred SimpleType values are then turned into CompactType values for simplification.
13+
*
14+
* The typing logic and state closely corresponds to the typing rule and explanations given in section 3 of the paper.
1315
*/
1416
class Typer(var dbg: Boolean, var verbose: Bool, var explainErrors: Bool)
1517
extends TypeDefs with TypeSimplifier {
@@ -301,7 +303,11 @@ class Typer(var dbg: Boolean, var verbose: Bool, var explainErrors: Bool)
301303
*/
302304
def hintProv(p: TP): TP = noProv
303305

304-
/** Infer the type of a term. */
306+
/** Infer the type of a term.
307+
*
308+
* This implementation is closely related to the typing rules described in
309+
* section 3 of the paper.
310+
*/
305311
def typeTerm(term: Term, desc: String = "")(implicit ctx: Ctx, raise: Raise, vars: Map[Str, SimpleType] = Map.empty): SimpleType
306312
= trace(s"$lvl. Typing ${if (ctx.inPattern) "pattern" else "term"} $term ${term.getClass.getSimpleName}") {
307313
// implicit val prov: TypeProvenance = ttp(term)

shared/src/main/scala/hmloc/UnificationSolver.scala

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import scala.collection.immutable.Queue
88
import scala.collection.mutable
99
import scala.collection.mutable.{Queue => MutQueue, Set => MutSet, Map => MutMap}
1010

11+
/* Unification solver creates data flows from sub-typing constraints. It also formats
12+
* reports for incorrect data flows.
13+
*
14+
* The unification algorithm is formally described in the section 4 of the paper.
15+
*/
1116
trait UnificationSolver extends TyperDatatypes {
1217
self: Typer =>
1318

0 commit comments

Comments
 (0)