Skip to content

Commit

Permalink
Fix broken test, clean up repo a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
lazear committed Jul 26, 2020
1 parent 439fb96 commit 38fe0f8
Show file tree
Hide file tree
Showing 82 changed files with 7 additions and 43 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 0 additions & 28 deletions recon/src/disjoint.rs → 05_recon/src/disjoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,31 +294,3 @@ impl<T: std::fmt::Debug> std::fmt::Debug for DisjointSet<T> {
writeln!(f, "}}")
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let mut set = DisjointSet::new();

let a = set.singleton(10);
let b = set.singleton(12);
let c = set.singleton(14);
let d = set.singleton(29);
let e = set.singleton(1);

set.union(|a, b| a, a, d);
set.union(|a, b| a, d, c);
set.union(|a, b| a, a, e);

assert_eq!(set.find(a), &29);
assert_eq!(set.find(e), &29);
assert_eq!(set.find(c), &29);
assert_eq!(set.find(d), &29);
assert!(set.find(a) != set.find(b));

assert_eq!(set.components.get(), 2);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["arith", "bidir", "dependent", "lambda", "typedarith", "stlc", "system_f", "system_fw", "recon", "util"]
members = ["01_arith", "02_lambda", "03_typedarith", "04_stlc", "05_recon", "06_system_f", "07_system_fw", "x1_bidir", "x2_dependent", "util"]
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,21 @@

Several Rust implementations of exercises from Benjamin Pierce's "Types and Programming Languages" are organized into different folders, as described below:

- `lambda` is an implementation of the untyped lambda calculus as presented in chapter 5, 6, and 7.

- `arith` is an implementation of the untyped lambda calculus extended with simple numeric operations

- `lambda` is an implementation of the untyped lambda calculus as presented in chapter 5, 6, and 7.

- `typedarith` is the `arith` project extended with simple types: `Nat` and `Bool`

- `stlc` is an implementation of the simply typed lambda calculus, as discussed in chapters 9 and 10 of TAPL. This simply typed calculus has the types, `Unit`, `Nat`, `Bool`, `T -> T` (arrow), and `Record` types.

- `system_f` contains a parser, typechecker, and evaluator for the simply typed lambda calculus with parametric polymorphism (System F).
- `recon` contains several implementations of Hindley-Milner based type reconstruction from the untyped lambda calculus to System F, with let-polymorphism. Both Algorithm W (the more common) and Algorithm J (the more efficient) are presented. For Alg. W, both a naive equality constraint solver, and a faster union-find (with path compression) solver are provided. Algorithm J makes use shared mutable references to promote type sharing instead.

The implementation of System F is the most complete so far, and I've tried to write a parser, typechecker and diagnostic system that can given meaningful messages, such as:
- `system_f` contains a parser, typechecker, and evaluator for the simply typed lambda calculus with parametric polymorphism (System F). The implementation of System F is the most complete so far, and I've tried to write a parser, typechecker and diagnostic system that can given meaningful messages

```
type Var = { A | B Nat | C Nat }
let func = (\x: Var. case x of | A => 0 | B y => succ x | C y => pred x) in func C 2 of Var
^~~~^ --- abstraction requires type Nat
^^ --- but it is applied to type "A: Unit | B: Nat | C: Nat"
```
- `system_fw` contains a parser for a high-level, Standard ML like source language that is desugared into an HIR, and then System F-omega. This extends `system_f` with type operators and higher-kinded types. This is where most of the ongoing work is located, as I'd like to make this the basis of a toy (but powerful, and useable) programming language. Ideally we will have some form of bidirectional type inference. Work on this has accidentally turned into a full fledged [SML compiler](https://github.com/SomewhatML/sml-compiler), so it's likely that I will roll back the work on the system_fw project to just type checking

- `system_fw` contains a parser for a high-level, Standard ML like source language that is desugared into an HIR, and then System F-omega. This extends `system_f` with type operators and higher-kinded types. This is where most of the ongoing work is located, as I'd like to make this the basis of a toy (but powerful, and useable) programming language. Ideally we will have some form of bidirectional type inference
- `bidir` is is an implementation of the bidirectional typechecker from 'Complete and Easy Bidirectional Typechecking', extended with booleans, product, and sum types. I make no claims on the correctness of the implementation for the extended features not present in the paper.

- `dependent` is WIP, implementing a simple, dependently typed lambda calculus as discussed in ATAPL.

- `bidir` is is an implementation of the bidirectional typechecker from 'Complete and Easy Bidirectional Typechecking', extended with booleans, product, and sum types. I make no claims on the correctness of the implementation for the extended features not present in the paper.

- `recon` contains several implementations of Hindley-Milner based type reconstruction from the untyped lambda calculus to System F, with let-polymorphism. Both Algorithm W (the more common) and Algorithm J (the more efficient) are presented. For Alg. W, both a naive equality constraint solver, and a faster union-find (with path compression) solver are provided. Algorithm J makes use shared mutable references to promote type sharing instead.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 38fe0f8

Please sign in to comment.