mirandaort
v0.83.0
Published
Miranda lazy functional programming interpreter (native C, npm CLI wrapper)
Maintainers
Readme
Miranda
Mira is the Miranda lazy functional programming system (interpreter).
Prerequisites
You need typical Unix build tools:
| Tool | Purpose |
|------|---------|
| GCC or Clang | C compiler (macOS Xcode Command Line Tools provide gcc/clang) |
| GNU Make | Build driver (make) |
| strip | Optional size reduction step (usual on Unix) |
| Node.js 18+ | Optional — runs npm scripts at the repo root (npm run compile, npm start) |
Optional, only if you regenerate the parser from rules.y:
- Berkeley Yacc (
byacc) — GNU Bison/yaccis not interoperable here. Install with Homebrew (brew install byacc), then align the Makefile’sYACCline withbyaccif needed.
Fresh checkouts normally build using the bundled y.tab.c / y.tab.h, so byacc is not required until you edit rules.y.
Install from npm
Requires Node.js 18+, gcc/clang, and GNU make (same as building from source). The package compiles the native mira binary on install.
npm install -g mirandaort
mira -version
mira # interactive session
mira -exec script.m # run script (must define main)Local project install:
npm install mirandaort
npx mira -versionPublished package: mirandaort on npm. Miranda Studio (studio/) is not included in the npm package.
Installation (step by step)
1. Get the sources
Clone or unpack the archive, then enter the project directory:
cd /path/to/miranda2. (Recommended) Refresh build state on this machine
This removes old objects, removes generated Miranda bytecode cached under miralib/ and miralib/ex/, and refreshes .host:
make cleanup3. Build
makeThis produces:
mira— the interpretermiralib/menudriver— helper used by the standard library layout- Precompiled library pieces (e.g.
miralib/prelude,miralib/stdenv) and examples undermiralib/ex/via./mira -make …
Inspect the top of the Makefile if you must change compiler or flags (CC, CFLAGS).
npm workflow (alternative to make / ./mira)
From the repository root you can build and run the interpreter with npm scripts. This does not start Miranda Studio (studio/ is optional and separate).
npm run compile # bootstrap + build ./mira (same result as step 3 above)
npm start # interactive Miranda session
npm run version # print interpreter version
npm run exec -- miralib/ex/fib.m # run a script (requires main = …)npm run compile creates missing bootstrap files (miralib/.version, fdate, .host) before calling make. If make warns about miralib/prelude not found, the C interpreter may still build; you need the full standard library tree for example bytecode and %include modules.
Reset build state with npm run clean (same as make cleanup).
4. Run
From the repository root:
./miraThat starts interactive Miranda (see the original README for /e, /man, etc.). Example scripts:
./mira miralib/ex/fib.mPrint version:
./mira -versionRun a one-shot script via stdin (-exec):
echo 'main = "hello"' | ./mira -exec /dev/stdinBy default mira looks for the library beside the current layout (miralib under this tree). Override with MIRALIB only if your layout differs:
MIRALIB=/path/to/miralib ./mira …5. (Optional) System-wide install — root only
Adjust BIN, LIB, and MAN at the top of the Makefile, then as root:
sudo make installThis copies mira, miralib, and mira.1 into /usr/bin, /usr/lib, and /usr/share/man/man1 or the paths you configured.
6. (Optional) Release tarball — root only
sudo make releaseCreates a ./usr/ tree under the repo and a .tgz suitable for unpacking at / on a machine of the same architecture (details in README).
Troubleshooting
make cleanupchmod errors — run from a writable clone; scripts callchmod/unprotectagainstmiralib/.- Optimisation / GC instability — the garbage collector can break under aggressive optimisation; edit
CFLAGS(try no-Oor a different compiler), as explained in README. byacc: command not found — only affects rebuilding fromrules.y; install Berkeley yacc or rely on shippedy.tab.c/y.tab.h.
For platform-specific tweaks and #ifdef-style patching, keep using the authoritative plain-text README (maintainer instructions).
Miranda Studio (Node UI)
A small React + Vite + Monaco Editor IDE in studio/ shells out to the compiled mira binary (no JavaScript interpreter):
- Build the core system first:
makein the repository root. - Install and run the web app:
cd studio
npm install
npm run devOpen the URL Vite prints (default http://127.0.0.1:5173). Use Run or ⌘↵ / Ctrl+Enter to evaluate the script; main must be defined (same as mira -exec). Use Add library to insert %include <studio/…> lines; add-on modules live under miralib/studio/ (same resolution rules as %include <ex/…>).
Production:
cd studio
npm install
npm run build
NODE_ENV=production npm startThe API listens on 127.0.0.1:4987 by default. Override with MIRANDA_STUDIO_PORT. Long runs are stopped after MIRA_TIMEOUT_MS (default 30000).
