npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tablecloth

v0.0.8-alpha.1

Published

A portable standard library enhancement for Reason and OCaml.

Downloads

6

Readme

Tablecloth

CircleCI Npm Opam

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.

Check out the website for our interactive API documentation.

Installation

Bucklescript

Install via npm by:

npm install 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 ...))

Usage

The recommended way to use Tablecloth is with a top-level open at the beginning of a file.

This will ensure that all the built-in modules are replaced.

open Tablecloth

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

Design of Tablecloth

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

  • Our backend is written in OCaml native, using Jane Street Core as a standard library
  • Our frontend is written in Bucklescript (dba ReasonML)
  • Parts of our backend are shared with the frontend by compiling them using js_of_ocaml, and running them in a web worker.

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

  • Bucklescript uses camelCase by default, while most native libraries, including Core and the OCaml standard library, use snake_case.
  • The libraries in Belt have different names and function signatures than native OCaml and Base/Core.
  • Many OCaml libraries have APIs optimized for pipelast (|>), while Belt aims for pipefirst (|.).
  • Core does not work with Bucklescript, while Belt is optimized for the JS platform.
  • Belt does not work in native OCaml, while Core is optimized for the native OCaml runtime.
  • Belt is incomplete relative to Core, or to other languages' standard libraries

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 draws inspiration from Elm's 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:

  • have both snake_case and camelCase versions of all functions and types
  • are backed by Jane Street Base for native OCaml
  • are backed by Belt and the Js library for Bucklescript/ReasonML
  • use labelled arguments so that can be used with both pipefirst (->) and pipelast (|>)
  • are well documented, and reasonably-well tested

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

  • Many of the functions could be much more efficient
  • Tablecloth functions should not throw any exceptions
  • All functions should have well-known and consistent edge-case behaviour

Contributing

Tablecloth is an ideal library to contribute to, even if you're new to OCaml or Reason.

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.

Check out the dedicated guide on contributing for more.

Developing

If you are new to OCaml there are a few prerequisites you will need to get started:

  • Install OCaml and OPAM based on your OS
  • You may need to run opam init
  • For Bucklescript install a current version of Node

Please refer to the Makefile for a complete list of supported actions. Here is a handful of useful, supported commands:

  • make deps-native: Install native dependencies.
  • make deps-bs: Install bs dependencies.
  • make build: Build the project.
  • make test: Run the test suite. You may need to make build first.
  • make documentation: Build the documentation to browse offline.

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 with the help of Dark. We may be hiring.