Coder Social home page Coder Social logo

inline-js's Introduction

inline-js: Call JavaScript from Haskell, and vice versa!

GitHub Actions Gitter Netlify Status

Documentation

Haddock

Haddock documentation for HEAD is available.

Adding inline-js as a dependency

cabal

Add a source-repository-package in the cabal.project file, see documentation for details.

stack

Add an extra-deps entry in the stack.yaml file, see documentation for details.

nix

Here's an example overlay.

pkgsSelf: pkgsSuper:
let
  src = pkgsSelf.fetchFromGitHub {
    owner = "tweag";
    repo = "inline-js";
    rev = "<rev>";
    sha256 = pkgsSelf.lib.fakeSha256;
  };
in
{
  haskellPackages = pkgsSuper.haskellPackages.override {
    overrides = self: _: {
      inline-js-core = (self.callCabal2nixWithOptions "inline-js-core" src
        "--subpath inline-js-core"
        { }).overrideAttrs (_: {
        preBuild = ''
          substituteInPlace src/Language/JavaScript/Inline/Core/NodePath.hs --replace '"node"' '"${pkgsSelf.nodejs-16_x}/bin/node"'
        '';
      });
      inline-js =
        self.callCabal2nixWithOptions "inline-js" src "--subpath inline-js" { };
    };
  };
}

haskell.nix

See documentation for details.

Implemented features

  • Manage node sessions which run the eval server script for Haskell/JavaScript interop
  • Evaluate expressions with require()/import() support
  • Export Haskell functions to async/sync JavaScript functions
  • Load third party libraries in user-specified node_modules
  • Garbage-collected JSVal references in Haskell
  • Support Promise-based async evaluation
  • Type classes for Haskell/JavaScript data marshaling, with aeson support
  • Template Haskell QuasiQuoters for lifting Haskell variables into JavaScript code
  • Doesn't require node native addon or third party libraries

Planned features

  • Integrate with TypeScript compiler, generate Haskell code from TypeScript .d.ts code
  • Integrate with headless browser testing frameworks like playwright/puppeteer for running JavaScript in browsers

Supported versions

Supported GHC versions:

  • ghc-8.6, tested with ghc-8.6.5
  • ghc-8.8, tested with ghc-8.8.4
  • ghc-8.10, tested with ghc-8.10.5
  • ghc-9.0, tested with ghc-9.0.1

Supported platforms:

  • Windows 10 x64, tested with Windows Server 2019
  • Linux x64, tested with Ubuntu 20.04
  • macOS x64, tested with macOS 10.15

Supported node versions:

  • node-v10, minimum v10.20.0
  • node-v12 and later

See the CI config for details.

Contributors

inline-js is maintained by Tweag I/O.

Have questions? Need help? Tweet at @tweagio.

inline-js's People

Contributors

terrorjack avatar

Watchers

James Cloos avatar  avatar

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.