Drup sent a pull request to OCaml on April fools: Make OCaml case-insensitive. I don’t know if the solution was meant as a joke, but the problem itself is real. I will quote Drup for the problem description:
With ReasonML and Bucklescript, the OCaml community has received an influx of programmers coming from web programming languages, notably Javascript. While OCaml programmers traditionally follow the snake_case convention, these new programmers usually follow the camlCase convention. The camlCase convention also has the advantage of mapping very well to Javascript APIs, and has thus been adopted by new libraries, notably Bucklescript’s alternative standard library, Belt.
This has led to some remarks and quite a bit of churn, which led to the creation of libraries such as Tablecloth which offers wrappers over both Core and Belt to provide both camlCase and snake_case.
Clearly, OCaml users will continue to use snake case and Reason users will continue to use camel case. But, it would be a shame to see the communities split over something as inconsequential as casing. Making the compiler case insensitive is perhaps a little bit heavy handed, but there must be another way of bridging the gap.
After all, there is an obvious mapping between snake case and camel case, and my guess is that in very few cases will a library export symbols that cannot be mapped bijectively between the two. This is my proposed solution: what if the casing of a library you are using could be toggled freely in your dune file? Something along the lines of:
(executable
(name Foo)
(libraries mylibrary)
(transform-case snake-case mylibrary))
I am not well versed in the internals of OCaml or Dune, so I don’t know how hard this is to do or if there are any serious issues with it. A simple PPX wouldn’t be enough since you would also need a way to transform the casing of exported symbols in object files, and I don’t know how you would go about this.
Any library would be able to be used freely in either OCaml or Reason, without compromising on casing preference. There would be no breaking changes, since you could simply pretend that the transform-case
option doesn’t exist. Libraries like Tablecloth could provide one casing, and not have to pollute their code and documentation with duplicate functions. Cross-pollination between the OCaml and Reason ecosystems would ensue!
Happy to hear a discussion about this. Alternative solutions are also welcome, especially if this does not work.