patrim
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published

Patrim Cauthon

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.

Example

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!

Installation

$ npm -g install patrim

Usage

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.

VS Code integration

See patrim-vscode for VS Code integration.

Package Sidebar

Install

npm i patrim

Weekly Downloads

7

Version

0.0.11

License

MIT

Unpacked Size

163 kB

Total Files

34

Last publish

Collaborators

  • zachsnow