Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Or you can use polymorphic variants in OCaml:

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


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: