Giter Club home page Giter Club logo

bs-refmt's Introduction

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'
  }

bs-refmt's People

Contributors

glennsl avatar jchavarri avatar jdeisenberg avatar

Stargazers

savi2w avatar Heechul Ryu avatar Medson Oliveira avatar George Lima avatar  avatar Andrejs Agejevs avatar Shinichi Kogai avatar Kennet Postigo avatar

Watchers

James Cloos avatar  avatar

Forkers

idkjs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.