https://github.com/glennsl/bs-refmt
https://github.com/glennsl/bs-refmt
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/glennsl/bs-refmt
- Owner: glennsl
- License: mit
- Created: 2018-01-21T10:40:44.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-11T14:49:55.000Z (over 7 years ago)
- Last Synced: 2025-03-24T07:49:45.193Z (10 months ago)
- Language: OCaml
- Size: 15.6 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/facebook/reason/#javascript-api)
## Installation
Run `npm install --save glennsl/bs-refmt` and add `bs-refmt` to the `bs-dependencies` in `bsconfig.json`.
## Example
```reason
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`:
```javascript
node: {
fs: 'empty',
child_process: 'empty'
}
```