Sa souvraya niende misain ye.
Patrim is a goofy little term rewriting language, implemented in Typescript. Incomplete documentation is available at the Patrim website.
Patrim was inspired by Modal.
A simple program that prints "Hello, world!" 3 times:
// Define a symbol for the string "Hello, world!"
:: hello "Hello, world!"
// Repeat something `n` times.
:: (repeat 0 ?s) undefined
:: (repeat ?n:number ?s) (
?s ;
repeat (?n - 1) ?s
)
// Define a shorthand for calling `console.info`. Note that `print` matches
// its argument eagerly.
:: (print !s) (((#global . console) . info) (?s))
repeat 3 (print hello)
Evaluating the program:
$ pc hello.pat
Hello, world!
Hello, world!
Hello, world!
$ npm -g install patrim
To evaluate the contents of a file or files, use pc
:
$ pc [options] <file>...
The resulting rewritten term will be printed to stdout
. Pass --interactive
to open
an interactive session after evaluating the given files, if any:
$ pc --interactive
? :: hello "Hello, world!"
rule-36: hello => Hello, world!
? hello
'Hello, world!'
? #exit 0
$
For complete usage information, see pc --help
.
See patrim-vscode for VS Code integration.