Home

Awesome

bs-refmt

Proof that Reason can consume OCaml by way of compiling to JavaScript. As a side-effect it also reformats things, without any need for IO monads™, which shows conclusively that OCaml and Reason are superior to Haskell in every way. Q.E.D. ∎

Or just BuckleScript bindings to refmt.js

Installation

Run npm install --save glennsl/bs-refmt and add bs-refmt to the bs-dependencies in bsconfig.json.

Example

let ocamlCode  = {|
  let hello thing =
    Js.log {j|Hello $thing!|j}

  let () =
    hello "world"
|};

let reasonCode =
  ocamlCode |> Refmt.parseML
            |> fun | Ok(ast)  =>
                     ast |> Refmt.printRE |> Js.log

                   | Error(`RefmtParseError({ message })) =>
                     Js.log2("Error: ", message)

Usage

Bundling

The package has been tested to work with webpack, but requires a tiny bit of configuration because it depends on a few ndoe modules in code paths that aren't actually used in practice. To stub these out, just put the following in your webpack.config.js:

  node: {
    fs: 'empty',
    child_process: 'empty'
  }