All Projects → ahrefs → hello-native-bucklescript

ahrefs / hello-native-bucklescript

Licence: other
Skeleton of a shared library for bucklescript and native OCaml/Reason

Programming Languages

ocaml
1615 projects
Makefile
30231 projects
shell
77523 projects

This repository contains an example of a library written in ocaml/reason for both javascript (through bucklescript) and native (through the ocaml compiler).

The shared directory contains the core of the library, available in both modes. js and native contain the part specific to one implementation of the library.

The library is composed of 3 modules:

  • Date, which has an implementation per platform and can have a different interface per platform.
  • Tomorrow, which has one implementation shared for both platforms.
  • Yesterday, which has a signature shared by both platforms, but an implementation per platform.

There is companion blog post giving more details on how to create this kind of library step by step.

Installation

For bucklescript:

yarn

For native:

  • install esy
  • then run esy install

It can work with opam, but we use esy in this example as it is easier to understand for people from the javascript world.

Compilation

For bucklescript:

yarn bsb -make-world

For native

esy dune build @all

The commands are wrapped in a Makefile and can be called with make js and make native.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].