Created
August 16, 2012 20:47
-
-
Save osa1/3373536 to your computer and use it in GitHub Desktop.
wtf, ocaml record types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ ~ 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