refal
raw JSON → 1.0.0 verified Fri May 01 auth: no javascript
REFAL Transpiler to JavaScript is a tool that converts REFAL, a functional programming language with pattern matching, into JavaScript. Version 1.0.0 provides a command-line interface and programmatic API. Unlike general transpilers, it is specialized for REFAL and aims to make REFAL accessible in JavaScript environments. The project is minimal and early stage, with no regular release cadence.
Common errors
error Error: Cannot find module 'refal' ↓
cause Attempting to import from an npm registry that does not have the package.
fix
Use a local path require instead.
error TypeError: transpile is not a function ↓
cause Importing the whole module as a function instead of destructuring the named export.
fix
Use const { transpile } = require('./src/index.js');
Warnings
gotcha The package is not published on npm; usage requires local file path. ↓
fix Install from source or copy the src directory.
gotcha No CommonJS vs ESM distinction; all code is CommonJS. ↓
fix Use require() instead of import.
gotcha The CLI script requires local execution via node bin/refal.js. ↓
fix Run from project root or adjust path.
Install
npm install refal yarn add refal pnpm add refal Imports
- transpile wrong
import { transpile } from 'refal';correctconst { transpile } = require('./src/index.js'); - transpile wrong
const transpile = require('./src/index.js');correctconst { transpile } = require('./src/index.js'); - transpile (default) wrong
const transpile = require('./src/index.js'); transpile(refalCode);correctconst transpile = require('./src/index.js').transpile;
Quickstart
const { transpile } = require('./src/index.js');
const refalCode = `
$ENTRY Go {
= <Hello>;
}
Hello {
= 'Hello, World!';
}
`;
const jsCode = transpile(refalCode);
console.log(jsCode);