:-) • Set of rules about type • Decides which type an expression will have • Decides which types are compa>ble • eg. Inheritance • Every language has its own type system RubyKaigi 2015 18
= HM + type class + ... • OCaml = HM + variant + ... • OreScript = HM (slightly modified) • Has an algorithm to reconstruct types • without any type annotaCon(!) RubyKaigi 2015 19
... • Bool • Number • <type> → <type> • eg. is_odd :: Number → Bool • Checks • Type of a and x must be the same f = fn(a){ ... } f(x) RubyKaigi 2015 22
program • If program has an error: • Bool == Number (unsa0sfiable) • Otherwise: • The program has consistent types (No contradic0on detected) RubyKaigi 2015 38
known (Number, Bool, etc.) • 99 :: #<TyRaw "Number"> • Type::TyFun • Func>on type • f :: #<TyFun #<TyRaw "Number"> -> #<TyRaw "Bool">> • Type::TyVar • A type not yet known • x :: #<TyVar (1)> • f :: #<TyVar (2)> RubyKaigi 2015 41
Type check without type annota8on • Type inference (= type check) • Build type equea8ons • Resolve type equea8ons • hBps:/ /github.com/yhara/rk2015orescript RubyKaigi 2015 53