Skip to content

✅A small Scheme like language that's type checked with the Hindley-Milner type system

License

Notifications You must be signed in to change notification settings

seanwestfall/hm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Robin Milner and J. Roger Hindley

hm

An implementation of the Hindley-Milner type system (wikipedia) in a simple Scheme/Lisp like language.

theory

https://youtu.be/x3evzO8O9e8 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

Scheme Type Rules Operational Semantics

Type System

  • An Atom, which stores a String naming the atom
  • A List, which stores a list of other LispVals (Haskell lists are denoted by brackets); also called a proper list
  • A DottedList, representing the Scheme form (a b . c); also called an improper 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 operator
  • mod modulus operator
  • quotient quotient operator
  • remainder 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

imgs

About

✅A small Scheme like language that's type checked with the Hindley-Milner type system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published