js-of-reason

1.0.3 • Public • Published

Basic Reason Template

This module converts a snippet of reasonML to javascript.

Example

const jsOfReason = require("js-of-reason")
const reasonCode = `let add = (a,b) => {
  a + b;
}`

jsOfReason(reasonCode, (error, jsCode) => {
  if(error){
    console.log(error)
  } else {
    console.log(jsCode)         // function add(a, b) {
                                //   return a + b | 0;
                                // }
  }
})

const codeWithError = `let add = (a,b) => {
  a + b + "2";
}`

jsOfReason(codeWithError, (error, jsCode) => {
  if(error){
    console.log(error)          // <type error>
                                //   1 │ let add = (a,b) => {
                                //   2 │   a + b + "2";
                                //   3 │ }
                                //   This has type:
                                //     string
                                //   But somewhere wanted:
                                //     int
  } else {
    console.log(jsCode)
  }
})

Package Sidebar

Install

npm i js-of-reason

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

4.35 kB

Total Files

7

Last publish

Collaborators

  • leoancap