What is ML? No, not machine learning ● “Meta Language” ● Originally designed as a language to build a theorem prover by Robin Milner ● Strong, static typing ● Enables powerful type inference via the Hindley-Milner algorithm ● We’ll focus on those last two pieces in modern implementations ● Code samples will be in OCaml
Type Inference ● Type inference refers to the methods that allow a machine to understand and enforce a type used in a function without the programmer actually declaring a type signature ● Allows the compiler to enforce types by checking all usages of functions and their type signatures before runtime
Parametric Polymorphism ● Similar to generics in other languages ● Given all the information at hand, the computer cannot tell exactly what type is required, therefore it must work for any type a’ and return any type b’
Currying and Partial Application ● A curried function is a function that takes multiple arguments before executing, but accepts one argument at a time.
Advanced Types: Type Aliases A type alias, or type synonym, is a new name for an existing type. This opens the door for more expressive domain modeling
Type Aliases - records Records are a data structure in many languages designed to hold multiple pieces of data (like tuples!) but with named fields and accessors
If you want to learn more Effective ML by Yaron Minsky ● https://blog.janestreet.com/effective-ml-revisited/ ● https://blog.janestreet.com/effective-ml-video/ Domain Modeling Made Functional ● https://fsharpforfunandprofit.com/ddd/ Why Type-First Development Matters ● http://tomasp.net/blog/type-first-development.aspx/