Subtyping -- examples

  type any = { }
  type entity = { age : int }
  type vehicle = { age : int, speed : int }
  type machine = { age : int, fuel : string }
  type car = { age : int, speed : int, fuel : string }
  

Subtyping rules

  
  • record = finite association of values to labels

  
  • (a = 3, b = true ).a ≡ 3

  
  •   

slide: Examples of object subtyping