Hacker News new | past | comments | ask | show | jobs | submit login

Interestingly enough, OCaml has a great polymorphism story in its OO system. Because it is structurally typed with nearly automatic inference, you can in fact write completely generic code like `x#y(z)`, which magically "just works" for any x that has a method y that accepts z - all inferred and statically type-checked.



> Because it is structurally typed with nearly automatic inference, you can in fact write completely generic code like `x#y(z)`, which magically "just works"

aka let's mix two jars of jam and shit via this funnel and see what happens.


On the contrary, static and structural typing are a match made in heaven.


Interesting. Why doesn't the standard lib use that for the examples I listed?


Because those types are not object types, so they don't have methods associated with them at all. This is unlike, say, CLR languages in which all types are object types.

There's been research on modular implicits for OCaml to solve this more generally, but that's not landing upstream anytime soon.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: