diff --git a/docs/ml.md b/docs/ml.md index ffb9b26..7aa02d6 100644 --- a/docs/ml.md +++ b/docs/ml.md @@ -142,6 +142,40 @@ let rec length([]) = 0 --- +### Types (very simple example) + +``` +type car = { + Color: string; + Model: string; + Manufacturer: string; + Year: int; +} + +let toyota :car = {Color="silver"; Model="Corolla"; Manufacturer="Toyota"; Year=1986};; + +Printf.printf "%A" toyota +``` + +--- + +### Type inference again + +``` +type car = { + Color: string; + Model: string; + Manufacturer: string; + Year: int; +} + +let toyota = {Color="silver"; Model="Corolla"; Manufacturer="Toyota"; Year=1986};; + +Printf.printf "%A" toyota +``` + +--- + ## Is it worth it? * OCaml (Jane Stree + others)