3 ms·
I once wondered about subtyping[1] too. Looks like there's a possible solution - MLsub[2][3]. But it will require significant amount of work to modify OCaml inf
by xvilka 6y ago
I once wondered about subtyping[1] too. Looks like there's a possible solution - MLsub[2][3]. But it will require significant amount of work to modify OCaml inference engine to work that way. For now I just use functors for types with the shared fields. It doesn't add too much lines of code either.
[1] https://discuss.ocaml.org/t/function-argument-polymorphism/3224/2 https://discuss.ocaml.org/t/function-argument-polymorphism/3...
[2] https://www.cl.cam.ac.uk/~sd601/papers/mlsub-preprint.pdf https://www.cl.cam.ac.uk/~sd601/papers/mlsub-preprint.pdf
[3] https://github.com/stedolan/mlsub https://github.com/stedolan/mlsub