Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mununki/spice-compiler
A compiler implementing the type inference of Hindley–Milner type system
https://github.com/mununki/spice-compiler
Last synced: 10 days ago
JSON representation
A compiler implementing the type inference of Hindley–Milner type system
- Host: GitHub
- URL: https://github.com/mununki/spice-compiler
- Owner: mununki
- Created: 2022-05-11T16:24:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-04T02:04:53.000Z (over 2 years ago)
- Last Synced: 2024-04-24T03:22:05.928Z (8 months ago)
- Language: OCaml
- Homepage:
- Size: 13.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spice compiler
Tiny compiler consists of Lexer, Parser, Type checker written in OCaml.
The type inference implemetation is mostly from the sound_lazy in https://okmij.org/ftp/ML/generalization.html and modified for the purpose of typing the parsetree (AST) from the parser.
## Example
Source
```ocaml
let x = fun y -> y + 1 in
(x 1)
```The typed tree
```
Program
└──Expr: Let var: x: Tconstr_integer
└──Expr: Lambda: y: TArrow: Tconstr_integer -> Tconstr_integer
└──Expr: Bin Op: +: Tconstr_integer
└──Expr: Var: y: Tconstr_integer
└──Expr: Int:1
└──Expr: App: Tconstr_integer
└──Expr: Var: x: TArrow: Tconstr_integer -> Tconstr_integer
└──Expr: Int:1
```