Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrewhickman/small-lang
Minimal compiler using the mlsub type system
https://github.com/andrewhickman/small-lang
toy-compiler
Last synced: 22 days ago
JSON representation
Minimal compiler using the mlsub type system
- Host: GitHub
- URL: https://github.com/andrewhickman/small-lang
- Owner: andrewhickman
- License: mit
- Created: 2019-02-04T21:09:17.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-20T22:38:38.000Z (almost 2 years ago)
- Last Synced: 2023-03-03T21:56:10.949Z (almost 2 years ago)
- Topics: toy-compiler
- Language: Rust
- Homepage: https://andrewhickman.dev/
- Size: 440 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Small-lang
A minimal compiler using the mlsub type system
* [Online Demo](https://andrewhickman.dev/)
* [Mlsub paper](https://www.cl.cam.ac.uk/~sd601/thesis.pdf)
* [Reference implementation in OCaml](https://github.com/stedolan/mlsub)
* [Mlsub online demo](https://www.cl.cam.ac.uk/~sd601/mlsub/)## Features
### Record types
```
let record = { field: 1 }
in record.field
```### Enum types
```
let enum = [some: 1]
in match enum with [
some: val => val,
none => 0,
]
```### Recursive functions
```
let cmp = import "cmp" in
let math = import "math" inlet rec fibonacci = func n =>
if cmp.eq n 0 then 0
else if cmp.eq n 1 then 1
else math.add
(fibonacci (math.sub n 1))
(fibonacci (math.sub n 2))
in fibonacci 14
```