Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahrefs/hello-native-melange
Skeleton of a shared library for melange and native OCaml/Reason
https://github.com/ahrefs/hello-native-melange
Last synced: about 1 month ago
JSON representation
Skeleton of a shared library for melange and native OCaml/Reason
- Host: GitHub
- URL: https://github.com/ahrefs/hello-native-melange
- Owner: ahrefs
- Created: 2019-10-11T11:01:41.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-05T08:21:39.000Z (over 1 year ago)
- Last Synced: 2024-12-16T19:17:40.280Z (about 1 month ago)
- Language: OCaml
- Homepage:
- Size: 38.1 KB
- Stars: 29
- Watchers: 6
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-list - hello-native-bucklescript
README
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](https://tech.ahrefs.com/how-to-write-a-library-for-bucklescript-and-native-22f45e5e946d)
giving more details on how to create this kind of library step by
step.## Installation
For bucklescript:
```bash
yarn
```For native:
- install [esy](https://esy.sh/)
- 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:
```bash
yarn bsb -make-world
```For native
```bash
esy dune build @all
```The commands are wrapped in a Makefile and can be called with `make
js` and `make native`.