reasonml-q-a
reasonml-q-a copied to clipboard
Belt, Reason standard library or third party library?
Question
When looking for a standard library in Reason you can get lost quickly. There are a few options. Reason Pervasives which works on native and when using BuckleScript - pipe-last (|>
) optimized and not so feature complete. There is Belt which is shipped with BuckleScript. Pipe-first (->
) and JS runtime optimized with better set of features especially a lot of cool stuff around different datatypes like Belt.Map
, Belt.HashMap
, Belt.Set
, etc. But it's shipped with BuckleScript and not available in native. It also have supper weird naming for pretty well-established names of function (keep
, keepMap
) and some inconsistency with arguments order (mapWithIndex
vs keepWithIndex
). There are third party community libraries like darklang/tablecloth (targeting both JS and native) or reazen/relude (targeting JS runtime).
What is the recommended way, where people can read more about different options out there and their props and cons?
Answer
This question hasn't been answered yet.
Further reading
In my view:
- If adopting BuckleScript coming from JavaScript, use the
Js
modules as they are straight, zero-cost bindings to the JavaScript runtime libraries - If looking for more powerful data structures, like immutable lists, trees, etc., use
Belt
- If you need maximum portability with native OCaml, try to stick to the modules in the OCaml standard library.