3 ms·
Or you can use polymorphic variants in OCaml: type color = `Red | `Green | `Blue | `Black | `Brown type hair_color = `Black | `Brown | `Blond
by mercurial 12y ago
Or you can use polymorphic variants in OCaml:
type color = `Red | `Green | `Blue | `Black | `Brown
type hair_color = `Black | `Brown | `Blond
- jallmann 12y agoIn OCaml 4.01, the compiler is smart enough to distinguish between constructors with the same name but a different type -- so those variants wouldn't even need to be polymorphic anymore. This also partially mitigates the need for 'namespacing' your variants.
- mercurial 12y agoOh, that's pretty nice. OCaml really gets namespacing problems out your way.