Page
Library
Module
Module type
Parameter
Class
Class type
Source
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.
Install via npm by:
npm install --save-dev tablecloth-bucklescript
Then add to your bsconfig.json file:
"bs-dependencies" : ["tablecloth-bucklescript"]
Install via opam:
opam install tablecloth-native
Then add to your dune file:
(libraries (tablecloth-native ...))
We have not built a js_of_ocaml specific version yet. However, the native version should work perfectly with js_of_ocaml.
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
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:
|>
), while Belt aims for pipefirst (|.
).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:
Js
library for Bucklescript/ReasonML,We also have design goals that are not yet achieved in the current version. The APIs:
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:
t
into a platform-specific type, to allow them create functions we do not currently support,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.
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.