Request for compiled sources for native Reason development


#1

Hi community,

Is there a willing individual or group that can help compile a useful list of resources for native Reason development, i.e. relevant docs for build tooling (Esy & Dune), your favorite Reason/Ocaml docs, useful libraries for http, filesystem work, etc.

This might as well be a request for improvements in the native section in the Reason docs. There are quite a few open source Reason projects that I’ve looked into but a proper workflow still escapes me.

Additiona questions:

  • How does Dune work with Esy?
  • Can I just use Ocaml libraries in Reason?
  • What are common libraries to build CLIs?
  • Is there a resource to find useful Reason and Ocaml libaries on npm & opam?

#2

Sorry for the delay. I don’t have a comprehensive tutorial/compilation of docs for you right now, but here’s some general pointers:

  • Native package management with esy: Use this Getting Started guide at esy.sh.
  • Dune: See the dune official docs which are pretty comprehensive as a reference style guide.
  • @reason-native: I’m focusing on a lot of native tooling for Reason lately, and we’re sharing a lot of that work that we’ve done as reason-native which is a collection of packages that can be installed with esy, and each package is hosted on npm. This includes some basic utilities for native command line apps like Console, Pastel (terminal highlighting), and of course Rely.
  • For native testing, you might like Rely from reason-native, if you are familiar with Jest. There are also many great test frameworks on opam.
  • By using esy you can consume any opam package, or any npm package (keep in mind npm doesn’t know if your package is native or JS - it’s just raw text to npm). We happen to host reason-native packages on npm under the @reason-native scope.
  • To depend on any new native package in an esy project, just add it to your dependencies, then rerun esy from the project directory. To depend on opam packages, just use the npm scope @opam like "@opam/pkg-name": "*" .
  • When you’ve added the dependency and rerun esy, you still need to tell the build system that your libraries depend on libraries contained inside of those newly added dependencies. Dune’s (libraries ) field is where you specify that.
  • To automate new projects and automate keeping your dune config up to date, you can try out the toy utility pesy which makes new reason native projects for you configured with Dune, CI, Rely etc.

Some of the common libraries to build CLIs are @reason-native/rely, @reason-native/console, @opam/bos (general OS operations), @opam/lwt, @opam/cmdliner. The http server story is still being refined with @opam/httpaf (we are working on making sure httpaf works well on windows currently before creating example projects).


#3

Thank you so much for this. It’s so helpful to have someone connect the dots and lay out a map of the common util libraries.

I’m sure others will find your response useful. Discord’s too ephemeral for this type of question imo.