funcity-cli
v0.8.0
Published
A functional language interpreter with text processing
Maintainers
Readme
funcity
A functional language interpreter with text processing, easy embeddable!

What is this?
This is a lightweight functional language processor implemented in TypeScript, featuring syntax extensions for text processing. It includes a CLI application and a library package containing only the core engine.
funcity can be considered a type of text template processor. For example, entering code like this:
Today is {{if weather.sunny}}nice{{else}}bad{{end}} weather.Evaluates the value of the weather variable manually bound to the core engine beforehand and generates different text outputs:
Today is bad weather.The if ... else ... end statements in the text indicate that the script is being executed.
So, you might ask, what makes this a "Functional language"?
Or how is it different from existing text processors?
Let me show you another equivalent example:
Today is {{cond weather.sunny 'nice' 'bad'}} weather.This is an example of function application,
inserting the result of applying three arguments to the cond function.
The first argument is a conditional expression.
The following code may further interest you:
{{
set printWeather (fun w (cond w.sunny 'nice' 'bad'))
}}
Today is {{printWeather weather}} weather.fundefines an anonymous lambda function.setperforms a mutable binding in the current scope.
Furthermore, you can easily integrate this interpreter into your application:
// Input script
const script = "Today is {{cond weather.sunny ‘nice’ 'bad'}} weather.";
// Run the interpreter
const variables = buildCandidateVariables();
const logs: FunCityLogEntry[] = [];
const text = await runScriptOnceToText(script, variables, logs);
// Display the result text
console.log(text);In other words, Funcity is a processing system that brings the power of functional programming to text template processors, enabling seamless integration into applications!
Features
- A lightweight functional language processor for handling untyped lambda calculus. Adopted the simplest possible syntax. Additionally, selected the syntax extensions that should be prioritized for text processing.
- All function objects are treated as asynchronous functions. You do not need to be aware that they are asynchronous functions when applying them.
- There is also a CLI using the core engine. The CLI has both REPL mode and text processing mode.
- The core engine includes a tokenizer, parser, and reducer (interpreter).
- The core engine library is highly independent, requiring no dependencies on other libraries or packages. It can be easily integrated into your application.
- Parsers and interpreters support both interpreting pure expressions and interpreting full text-processing syntax. This means that even when an interpreter for a purely functional language is required, it is possible to completely ignore the (somewhat incongruous) syntax of text processing.
- Allows pre-binding of useful standard function implementations.
Installation (CLI)
TODO:
npm install -D funcity-cliOr, global installation:
npm install -g funcity-cliInstallation (Library)
npm install funcityDocumentation
For detailed documentation and advanced features, please visit our GitHub repository.
Note
funcity was separated from the document site generator mark-the-ripper during its design phase, as it seemed better suited to function as an independent scripting engine.
Therefore, mark-the-ripper can leverage the power of funcity's functional language.
License
Under MIT.
