After a few years experience with this library, and given the changes in the ecosystem over that time, I think it would be wise to change the purpose of Tablecloth somewhat.
Problem
I think the original goal - to be able to reuse code between bucklescript and OCaml - is not as good a goal as I initially thought.
My experience with trying to share code between the platforms has not been great - we only share some very basic types and very little logic. We tried to share some less basic types, but we needed to use ppxes that were only available on one or another, and used different annotations in each.
Moreover, the goal of sharing types on server and client is less useful than originally imagined. Client and server move at different paces, with for example the server able to change fairly instantly while clients take longer, while also the server has serialization concerns that cause types to sometimes persist much longer than on the client.
To add to this, ReScript and OCaml are diverging more and more. ReScript is very much focussing on its mission of supporting JS, and over time has focused much less on any connection to OCaml, including - significantly - sticking with an older version of the OCaml compiler. The focus on t-first also means that trying to overlay a t-agnostic library doesn't hold up as well.
ReScript also has a formidable standard library in Belt - I notice that Tablecloth's Map does not have a compatible type with the Rescript Map.
At the same time, OCaml is moving forward at a good pace too. It has moved forward many versions, as has Base/Core. I haven't perceived any changes that would affect us, but I'm sure they will come.
Solution
As I look to how we actually use Tablecloth at Dark, the most valuable thing has not been reusing code (as stated above, this has been quite a bad experience really), but rather having the same APIs available on all platforms. It is annoying when using multiple MLs to have to look up what the function is called in F# vs OCaml vs ReScript.
So I'd like to switch Tablecloth to a somewhat purer form of its original goal: to be an overlay that provides the same API on many ML platforms: OCaml, ReScript, and F# (and in the future other MLs too).
This would mean:
- the primary function of the library is to have functions of the same name on each platform (for example, all platforms would have a
Map.values or String.join function), with the signature being close but also closely tied to the platform (t-first in ReScript and t-last in F#, for instance)
- code reuse is not a goal, just API similarity
- functions should only be named in the style of what is idiomatic on that platform (camelCase on Rescript and F#, snake_case in OCaml) - this is a problem as having two names in each cloggs up the autocomplete which annoys people
- Set and Map types would be aliases for the idiomatic Set/Map used on each platform, not our own type
Comments?
I'd love some comments on this proposal. It is a move away from how we designed tablecloth, but I think it is more appropriate given how the ecosystem has been moving.
After a few years experience with this library, and given the changes in the ecosystem over that time, I think it would be wise to change the purpose of Tablecloth somewhat.
Problem
I think the original goal - to be able to reuse code between bucklescript and OCaml - is not as good a goal as I initially thought.
My experience with trying to share code between the platforms has not been great - we only share some very basic types and very little logic. We tried to share some less basic types, but we needed to use ppxes that were only available on one or another, and used different annotations in each.
Moreover, the goal of sharing types on server and client is less useful than originally imagined. Client and server move at different paces, with for example the server able to change fairly instantly while clients take longer, while also the server has serialization concerns that cause types to sometimes persist much longer than on the client.
To add to this, ReScript and OCaml are diverging more and more. ReScript is very much focussing on its mission of supporting JS, and over time has focused much less on any connection to OCaml, including - significantly - sticking with an older version of the OCaml compiler. The focus on
t-firstalso means that trying to overlay at-agnosticlibrary doesn't hold up as well.ReScript also has a formidable standard library in Belt - I notice that Tablecloth's Map does not have a compatible type with the Rescript Map.
At the same time, OCaml is moving forward at a good pace too. It has moved forward many versions, as has Base/Core. I haven't perceived any changes that would affect us, but I'm sure they will come.
Solution
As I look to how we actually use Tablecloth at Dark, the most valuable thing has not been reusing code (as stated above, this has been quite a bad experience really), but rather having the same APIs available on all platforms. It is annoying when using multiple MLs to have to look up what the function is called in F# vs OCaml vs ReScript.
So I'd like to switch Tablecloth to a somewhat purer form of its original goal: to be an overlay that provides the same API on many ML platforms: OCaml, ReScript, and F# (and in the future other MLs too).
This would mean:
Map.valuesorString.joinfunction), with the signature being close but also closely tied to the platform (t-first in ReScript and t-last in F#, for instance)Comments?
I'd love some comments on this proposal. It is a move away from how we designed tablecloth, but I think it is more appropriate given how the ecosystem has been moving.