Skip to content

Instantly share code, notes, and snippets.

@osa1
Created August 16, 2012 20:47
Show Gist options
  • Save osa1/3373536 to your computer and use it in GitHub Desktop.
Save osa1/3373536 to your computer and use it in GitHub Desktop.
wtf, ocaml record types
➜ ~ ocaml
OCaml version 4.00.0
# type record1 = { x : int; y : int };;
type record1 = { x : int; y : int; }
# { x = 10; y = 20 };;
- : record1 = {x = 10; y = 20}
# type record2 = { x : int };;
type record2 = { x : int; }
# { x = 10; y = 20 };;
Error: The record field label y belongs to the type record1
but is mixed here with labels of type record2
# { x = 10 };;
- : record2 = {x = 10}
# let a r = r.x;;
val a : record2 -> int = <fun>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment