Skip to content

A compiler implementing the type inference of Hindley–Milner type system

Notifications You must be signed in to change notification settings

mununki/spice-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

About

A compiler implementing the type inference of Hindley–Milner type system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published