Common effects

Operations that belong to no host in particular: they are declared once here, and each host implements the ones it can. That does not make every program built from them portable, so the table says which runner answers which: the Node runner, a demo on a site page (website/demo-runtime.mjs), and the SpiderMonkey shell (spidermonkey). A program that writes to stdout does not run in a page. module.f.mjs declares them, types.ts says which hosts implement which, and module.mjs holds the handlers the hosts share.

OperationDoesAnswered by
write(stream, bytes)writes bytes to stdout or stderrNode, SpiderMonkey
log(s), error(s)writes a line of text to stdout or stderrNode, SpiderMonkey
errorExit(s)writes a line to stderr and ends the program with exit code 1Node, SpiderMonkey
read(stream), readLinereads from stdinNode
sandbox(f)runs f, reporting what it answered or threw and how long it tookNode, page, SpiderMonkey
catch_(f)runs f, answering what it threw as a Result errorNode, page, SpiderMonkey
import_(path)imports a moduleNode, SpiderMonkey
randomInt()a random integerNode, page
all(...effects), allOk, bothruns effects side by side, answering every resultNode, SpiderMonkey

sandbox and catch_ are the only way a FunctionalScript program meets code that may throw, such as a test body or a benchmark. A demo uses sandbox to time a function in the reader's browser (fjs/types/bigint).

Emergent Testing

Idle. Press Run to start the suite.

  • ./proof.f.mjs