Hacker News new | ask | show | jobs
by mercurial 4080 days ago
Or you can use polymorphic variants in OCaml:

   type color = `Red | `Green | `Blue | `Black | `Brown
   type hair_color = `Black | `Brown | `Blond
1 comments

In 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.
Oh, that's pretty nice. OCaml really gets namespacing problems out your way.