High-order Virtual Machine (HVM) wrapper on JavaScript, via WASM

Overview

HVM on JavaScript

HVM is now available as a JavaScript library!

Installing

npm i --save hvm-js

Examples

Evaluating a term to normal form

import hvm from "hvm-js";

// Instantiates an HVM runtime given a source code
var rt = await hvm(`
  (U60.sum 0) = 0
  (U60.sum n) = (+ n (U60.sum (- n 1)))
`);

console.log(rt.eval("(U60.sum 10000000)"));

Evaluating to weak head normal form

import hvm from "hvm-js";

// Instantiates an HVM runtime given a source code
var rt = await hvm.runtime(`
  (U60.sum 0) = 0
  (U60.sum n) = (+ n (U60.sum (- n 1)))
`);

// Allocates an expression without reducing it
let loc = rt.alloc_code("(U60.sum 10)");

// Reduces it to weak head normal form:
rt.reduce(loc);

// If the result is a number, print its value:
let term = rt.at(loc);
if (rt.get_tag(term) == rt.NUM) {
  console.log("Result is Num(" + rt.get_val(term) + ")");
}

Running an IO program

import hvm from "hvm-js";

var rt = await hvm(`
  Main =
    (IO.do_output "Name: " λ_
    (IO.do_input           λname
    (IO.do_output "Hi, "   λ_
    (IO.do_output name     λ_
    (IO.done 42)))))
`);

await rt.run_io_term({$: "Fun", name: "Main", args: []});
console.log("");
You might also like...

A Remix stack setup to run on Deno with support for Rust WASM modules!

Remix + Deno + Rust - Webassembly - The Air Metal Stack Welcome to the Air Metal Stack for Remix! 🦕 + 🦀 This stack is a good choice if you want to

Jan 5, 2023

Simple Jai to WASM Proof-of-Concept

Simple Jai to WASM Proof-of-Concept Jai does not officially support WebAssembly compilation target. BUT! It allows you to dump LLVM IR via the llvm_op

Dec 14, 2022

Building #dotnet code to target WASM in the browser

Building #dotnet code to target WASM in the browser

WASM Running .NET in a Browser This solution shows you can compile .NET to target a WASM app bundle that can be used independently of a dotnet applica

Oct 14, 2022

A lightweight extension to automatically detect and provide verbose warnings for embedded iframe elements in order to protect against Browser-In-The-Browser (BITB) attacks.

A lightweight extension to automatically detect and provide verbose warnings for embedded iframe elements in order to protect against Browser-In-The-Browser (BITB) attacks.

Enhanced iFrame Protection - Browser Extension Enhanced iFrame Protection (EIP) is a lightweight extension to automatically detect and provide verbose

Dec 24, 2022

🧩 TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types such as number or boolean (not Value Objects)

🧩 TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types such as number or boolean (not Value Objects)

🧩 TypeScript Primitives type TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types

Dec 7, 2022

This project is a To-do list app which users can store and edit their Todo Tasks. Users can also change the order of their todo

Project This project is about a todo app bundling using webpack Additional description about the project and its features. Built With HTML CSS Javascr

Jun 17, 2022

Digitally enabled cafe for students to order drinks, socialize, and study hard.

Coffee Shop Full Stack Full Stack Nano - IAM Final Project Udacity has decided to open a new digitally enabled cafe for students to order drinks, soci

Nov 20, 2022

A jQuery plugin that works in harmony with animate.css in order to enable animations only when content comes into view.

jQuery AniView A jQuery plugin that works in harmony with animate.css in order to enable animations only when content comes into view. Now supports v4

Sep 10, 2022

An embeddable, programmable order book framework

Verto Flex An embeddable, programmable order book framework Installation npm install @verto/flex or yarn add @verto/flex Prerequisites Your SmartWeave

Oct 23, 2022
Owner
null
A tiny JVM (Java Virtual Machine) program written in TypeScript.

jvm-on-typescript A tiny JVM (Java Virtual Machine) program written in TypeScript. This virtual machine specification compliants Java Virtual Machine

Itsu 27 Nov 24, 2022
basic dissembler for Kasada's virtual machine obfuscation

Kasada Dissembler A simple kasada dissembler which is capable of tracing through and executing every single opcode in kasada's bytecode and then loggi

Felix Zhao 14 Jul 8, 2022
Shizuku Launcher is a simple AWS Virtual Machine helper.

shizuku-launcher-web Shizuku Launcher is a simple AWS Virtual Machine helper. Shizuku Launcher offers multiple solutions to keep your credential secur

Seraphim Lou 16 Oct 11, 2022
Shizuku Launcher is a simple AWS Virtual Machine helper. Now in Next.js

Shizuku Launcher Shizuku Launcher is a simple AWS Virtual Machine helper. Shizuku Launcher offers multiple solutions to keep your credential security

Seraphim Lou 50 Jan 3, 2023
Solana blockchain candy machine app boilerplate on top of Metaplex Candy Machine. NextJS, Tailwind, Anchor, SolanaLabs.React, dev/mainnet automation scripts.

NFT Candy Factory NOTE: This repo will prob only work on unix-based environments. The NFT Candy Factory project is designed to let users fork, customi

Kevin Faveri 261 Dec 30, 2022
Complete Open Source Front End Candy Machine V2 Minter dAPP Built For The Frog Nation NFT Solana Project. Built With React, Candy Machine V2, Typescript

Complete Open Source Front End Candy Machine V2 Minter dAPP Built For The Frog Nation NFT Solana Project. Built With React, Candy Machine V2, Typescript

null 17 Sep 24, 2022
Drawing Newton's fractal using pure js, rust-wasm, SIMDs, threads and GPU

Newton's fractal Runtime Newton's fractal renderer. >>Click<< to open in your browser Inspired by 3blue1brown's video about Newton's fractal. Drawing

Aleksei 86 Nov 17, 2022
A WASM shell parser and formatter with bash support, based on mvdan/sh

sh-syntax A WASM shell parser and formatter with bash support, based on mvdan/sh TOC Usage Install API Changelog License Usage Install # yarn yarn add

RxTS 7 Jan 1, 2023
Remix sandbox repo for Rust compiled to WASM and to native N-API modules

Rust <-> Remix Sandbox Now with both native Rust and WASM versions! If you want to combine the Web Fundamentals & Modern UX of Remix together with the

Ben Wishovich 26 Dec 30, 2022