Skip to content

Instantly share code, notes, and snippets.

@zehnpaard
zehnpaard / hm7.ml
Last active November 10, 2022 11:20
Hindley Milner Type Inference with Unit, Bool, Int, Tuple, Record, Variant, Fix
type ty =
| TVar of tvar ref
| TArrow of ty * ty
| TUnit
| TBool
| TInt
| TTuple of ty list
| TRecord of (string * ty) list
| TVariant of (string * ty) list
and tvar =
@zehnpaard
zehnpaard / hm6.ml
Last active November 8, 2022 08:32
Hindley Milner Type Inference with Unit, Bool, Int, Tuple, Record, Variant
type ty =
| TVar of tvar ref
| TArrow of ty * ty
| TUnit
| TBool
| TInt
| TTuple of ty list
| TRecord of (string * ty) list
| TVariant of (string * ty) list
and tvar =
@zehnpaard
zehnpaard / hm5.ml
Last active November 7, 2022 10:20
Hindley Milner Type Inference with Unit, Bool, Int, Tuple, Record
type ty =
| TVar of tvar ref
| TArrow of ty * ty
| TUnit
| TBool
| TInt
| TTuple of ty list
| TRecord of (string * ty) list
and tvar =
| Unbound of int * int
@zehnpaard
zehnpaard / hm4.ml
Last active November 3, 2022 08:04
Hindley Milner Type Inference with Unit, Bool, Int, Tuple
type ty =
| TVar of tvar ref
| TArrow of ty * ty
| TUnit
| TBool
| TInt
| TTuple of ty list
and tvar =
| Unbound of int * int
| Link of ty
@zehnpaard
zehnpaard / hm3.ml
Created October 31, 2022 03:19
Hindley Milner Type Inference with Unit, Bool, Int
type ty =
| TVar of tvar ref
| TArrow of ty * ty
| TUnit
| TBool
| TInt
and tvar =
| Unbound of int * int
| Link of ty
| Generic of int
@zehnpaard
zehnpaard / hm2.ml
Created October 31, 2022 03:18
Hindley Milner Type Inference with Unit, Bool
type ty =
| TVar of tvar ref
| TArrow of ty * ty
| TUnit
| TBool
and tvar =
| Unbound of int * int
| Link of ty
| Generic of int
@zehnpaard
zehnpaard / hm1.ml
Created October 31, 2022 03:17
Hindley Milner Type Inference with Unit
type ty =
| TVar of tvar ref
| TArrow of ty * ty
| TUnit
and tvar =
| Unbound of int * int
| Link of ty
| Generic of int
type exp =
@zehnpaard
zehnpaard / inf2_5.ml
Created October 30, 2022 13:51
Type Inference with Built-in Polymorphic Functions, Mutable Type Variable Generation and Unification from TaPL, https://github.com/hsk/simpletapl and https://github.com/tomprimozic/type-systems
type ty =
| TVar of tvar ref
| TArrow of ty * ty
and tvar =
| Unbound of int
| Link of ty
| Generic of int
type exp =
| EVar of string
@zehnpaard
zehnpaard / inf4.ml
Last active October 30, 2022 13:46
Let-bound Polymorphic Type Inference with Mutable Type Variable Generation and Unification, Level-Based Generalization from TaPL, https://github.com/hsk/simpletapl and https://github.com/tomprimozic/type-systems
type ty =
| TVar of tvar ref
| TArrow of ty * ty
and tvar =
| Unbound of int * int
| Link of ty
| Generic of int
type exp =
| EVar of string
@zehnpaard
zehnpaard / inf3.ml
Last active October 29, 2022 06:48
Let-bound Polymorphic Type Inference with Mutable Type Variable Generation and Unification from TaPL, https://github.com/hsk/simpletapl and https://github.com/tomprimozic/type-systems
type ty =
| TVar of tvar ref
| TArrow of ty * ty
and tvar =
| Unbound of int
| Link of ty
| Generic of int
type exp =
| EVar of string