tablecloth

Tablecloth is an ergonomic, cross-platform, standard library for use with OCaml and ReasonML. It provides an easy-to-use, comprehensive and performant standard library, that has the same API on all OCaml/ReasonML/Bucklescript platforms.

Tablecloth is alpha-quality software, and is pre-1.0. The API will change over time as we get more users. Caveat emptor.

Installation

Bucklescript

Install via npm by:

npm install --save-dev tablecloth-bucklescript

Then add to your bsconfig.json file:

"bs-dependencies" : ["tablecloth-bucklescript"]

OCaml native

Install via opam:

opam install tablecloth-native

Then add to your dune file:

(libraries (tablecloth-native ...))

js_of_ocaml

We have not built a js_of_ocaml specific version yet. However, the native version should work perfectly with js_of_ocaml.

Usage

By design, the usage of the libraries is the same on all platforms:

Either open the module, and replace the builtin modules

open Tablecloth

let () =
  "somestring"
  |> String.toList
  |> List.map ~f:Char.toCode
  |> List.map ~f:(fun x -> x+1)
  |> List.map ~f:Char.fromCode
  |> String.fromList

Or use the fully qualified names:

let () =
  "somestring"
  |> Tablecloth.String.toList
  |> Tablecloth.List.map ~f:Char.toCode
  |> Tablecloth.List.map ~f:(fun x -> x+1)
  |> Tablecloth.List.map ~f:Char.fromCode
  |> Tablecloth.String.fromList

Design of Tablecloth

Dark uses multiple versions of OCaml on the frontend and backend:

We discovered that it was impossible to share code between the Bucklescript frontend and the OCaml backend, as the types and standard libraries were very different:

Tablecloth's solution

Tablecloth solves this by providing an identical API for Bucklescript and OCaml. It wraps existing standard libraries on those platforms, and so is fast and memory efficient. It is based off Elm standard library, which is extremely well designed and ergonomic.

Tablecloth provides separate libraries for OCaml native, js_of_ocaml, and Bucklescript. The libraries have the same API, but different implementations, and are installed as different packages.

The APIs:

We also have design goals that are not yet achieved in the current version. The APIs:

Contributing

Tablecloth is an ideal library to contribute to, even if you're new to OCaml or new to writing algorithms. The maintainers are warm and friendly, and the project abides by a Code of Conduct. There are many small tasks to be done - a small change to a single function can be extremely helpful.

Here are some ways to contribute:

If you'd like to contribute but don't know where to start, open an issue with your thoughts, or contact us on Twitter or by email.

License

Tablecloth uses the MIT license. Some functions are based on Elm/core (BSD), and from the *.Extra packages in elm-community, which use a BSD license.

Authors

Written by Dark. We may be hiring.