he definido algunos tipos:sobrecarga de funciones en OCaml
type box = Box of int
type table = Table of int
type compare_result = Lt | Eq | Gt
parece que en OCaml, no podemos definir 2 funciones con el mismo nombre pero con diferentes tipos de argumentos:
let compare (a: box) (b: box): compare_result = (...)
let compare (a: table) (b: table): compare_result = (...)
let res_box = compare (Box 1) (Box 2) in (* which is supposed to call the first funciton *)
let res_table = compare (Table 1) (Table 2) in (* which is supposed to call the second function *)
Así ¿alguien podría decirme cuál es la alternativa en OCaml para hacer esto? ¿Tenemos que nombrar estas 2 funciones de manera diferente?
Tenga en cuenta que su segunda declaración de 'compare' ocultará la anterior (no hay sobrecarga de funciones en Ocaml). – akoprowski