Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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