Robin Milner and J. Roger Hindley
hm
An implementation of the Hindley-Milner type system (wikipedia) in a simple Scheme/Lisp like language.
theory
Simon Peyton Jones how GHC type inference engine actually works Watch Here
A Practical Type Checker for Scheme by Christian Lindig Read Here
The Design and Implementation of Typed Scheme by Sam Tobin-Hochstadt and Mathhias Felleisen Read Here
The Hindley-Milner Type System Watch Here
build
# ghc -o dist/hm --make src/hs.hs
# ./dist/hm ...
Cabal
# cabal build
# ./dist-newstyle/build/x86_64-osx/ghc-8.6.5/hm-0.1.0.0/x/hm/build/hm/hm
Language Features (Types & Operators)
Most Features of the Type System and Operators come from R5RS (https://schemers.org/Documents/Standards/R5RS/HTML/) of Scheme, the standard for Scheme like Languages.
Type rules of R5RS Scheme
Type System
- An
Atom
, which stores a String naming the atom - A
List
, which stores a list of otherLispVals
(Haskell lists are denoted by brackets); also called aproper
list - A
DottedList
, representing theScheme
form(a b . c)
; also called animproper
list. This stores a list of all elements but the last, and then stores the last element as another field - A
Number
, containing a Haskell Integer - A
String
, containing a Haskell String - A
Bool
, containing a Haskell boolean value
Primitive Operations
+
plus/addition operator-
minus/subtraction operator*
times/multiplication operator/
divide operatormod
modulus operatorquotient
quotient operatorremainder
remainder operator / returns the remainder
Conditionals
List Operations
Functions
./hm
hm>>> (define (f x y) (+ x y))
(lambda ("x" "y") ...)
hm>>> (f 1 2)
3