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

I don't think so really. It might help lure people over from haskell or rust or whatever but ocaml has its own solutions to the problems solved by ad hoc polymorphism. Usually in the module system, sometimes a ppx.

There's nothing comparable to ocaml's module system that I know of in any other mature language so no one really arrives in ocaml with well developed intuition for what sorts of things are possible and worth doing with it. But once you've put the time in it's usually the correct answer to "how to do I do <haskell type system thing> in ocaml."

I'm not a type systems expert though and it's likely there are some novel & unique situations where it's the best or only solution. Just maybe not as much as people assume from outside. Anyway I think there is a proposal for it so it'll probably work its way in eventually.



Haskell's "mixin modules" AKA backpack are I think the closest thing you're going to get outside of SML (they are a different trade off in the design space, it's not 1-to-1), but they have languished in the broader community due to a couple social factors. They are excellent for many of the same things you use modules for, though, and work just fine in my experience.

On the same note, the lack of some kind of module system along these lines (broadly all defined in terms of "holes" in a compilation unit which are "plugged up" later on at instantiation time), is one of my biggest complaints about Rust. The extensive usage of traits in the broader ecosystem results in this phenomenon (identical to Haskell) where global coherence requires your dependency tree gets tied up in the location of types and their trait impls. In other words, you cannot abstract over your dependencies in a truly modular way.

Global coherence requirements are fine (preferable even!) for many things but if it's the only hammer you have, well, you know the rest of the metaphor.

> Anyway I think there is a proposal for it so it'll probably work its way in eventually.

Modular implicits have been shelved indefinitely from what I understand, if that's what you're referring to.


> Modular implicits have been shelved indefinitely from what I understand, if that's what you're referring to.

They have not — people are still working on it. There's been a paper at the OCaml Workshop at ICFP this year, and a PR on the OCaml repo. The student who worked on this is now starting a PhD on modular implicits in the lab that created OCaml.


Isn't Ocaml's module system based on StandardML? SML predates Ocaml by a few years and non-standardized ML by a couple decades.


Oh actually I'm not sure. I was thinking it was one of the things ocaml added but now I think you're right.




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

Search: