std-mumu
Standard input/output & a deep pretty-printer for the Lava/MuMu runtime.
Crate: std-mumu
Repository: https://gitlab.com/tofo/std-mumu
License: MIT OR Apache-2.0 (dual)
Engine compatibility: core-mumu = 0.9.0-rc.4 (host and wasm builds)
What this plugin provides
std-mumu exposes a compact “std” surface for Lava/MuMu scripts:
std:put(x)– print without a trailing newline (drains iterators).std:log(x)– print with a trailing newline (drains iterators).std:deep(x)– emit a deep, single-line, MuMu-ish representation and returnx.std:input([prompt])– optional prompt, then read a single line fromstdin(host only).std:input_iter()– a line iterator overstdin(host only).format(options, data)– minimal formatter; prints and returnsdataunchanged. Supports partial application and_placeholders.
Works when dynamically loaded at runtime (extend("std")) and when statically registered in a host.
Quick taste (minimal examples)
extend("std")
std:log("Hello, Lava!") // prints with newline
std:put("no newline"); std:put("\n")
// Deep printer – compact, escaped, single line
std:deep([a: 1, b: ["x", "y"], c: [1.0, 2.5]])
// Read a line (host/native builds)
std:put("Your name: ")
name = std:input()
std:log("Hi " + name + "!")
Iterator draining (blocking):
extend("std")
// 'step' is provided by the core host; this prints 1, 2, 3 each on its own line.
std:log(step(1,4))
Minimal formatter:
extend("std")
// Deep vs shallow
format([deep:true], [a:[1,2], b:"x"])
format([deep:false], [a:[1,2], b:"x"])
// Quote strings in shallow mode (to see spaces/tabs/newlines)
format([deep:false, quote_strings:true], " hi\t")
// Prefix / suffix / newline control
format([prefix:"=> "], 42) // "=> 42\n"
format([suffix:" ;"], 42) // "42 ;\n"
format([newline:false], 42) // "42"
std:put/std:logdrain iterators synchronously. Use the coreslog/sputnon‑blocking pollers when you need background progress in a REPL/UI loop.
Minimal format API
format(options, data) -> data
A very small option set — no trees, no frames, no colors, no wrapping:
deep(bool, default true) — deep, single‑line representation (quotes + escapes for strings).
Iffalse, use a shallow form similar tostd:put.newline(bool, default true) — print with newline;falseprints without\n.prefix(string, default"") — prepend once to the first line.suffix(string, default"") — append once at the end.quote_strings(bool, default false) — whendeep:false, quote/escape string leaves so spaces/tabs/newlines are visible. (Deep mode already quotes.)
Partial application & _ placeholders are supported:
format(_)→ returns a function expecting(options, data)format(opts)→ returns a function expectingdataformat(_, data)→ returns a function expectingoptionsformat(opts, data)→ formats immediately
All legacy options (tree view, colors, numbering, frame, wrapping, timestamps, help, etc.) were removed for simplicity.
Host vs Web (wasm) behavior
std-mumu builds for both native hosts and wasm targets. Input is intentionally stubbed on the web:
| Function | Native (host) | Web/wasm (browser) |
|---|---|---|
std:input |
✅ reads from stdin |
❌ error: std:input is unavailable in this build |
std:input_iter |
✅ line iterator over stdin |
❌ error: std:input_iter is unavailable |
std:put |
✅ print + push to print buffer | ✅ print buffer updated |
std:log |
✅ print newline + push buffer | ✅ print buffer updated |
std:deep |
✅ deep printer | ✅ deep printer |
format |
✅ minimal formatter | ✅ formatter |
Dynamic & static integration
-
Dynamic (preferred): the shared library exports
Cargo_lock. Hosts that supportextend("…")can load the plugin at runtime:extend("std") std:log("OK") format([deep:false], [a:1, b:[2,3]]) -
Static: hosts can call
register_all(interp)to make the functions available without dynamic loading.
License
Dual-licensed under either of:
- MIT License — see
LICENSE - Apache License, Version 2.0 — see
LICENSE
You may choose either license.