FScript is a lightweight, embeddable interpreter with an F#/ML-style language.
It is designed for host applications that need:
- a concise functional scripting language,
- strong static checks (Hindley-Milner type inference),
- controlled host extensibility,
- and a clear sandbox/security boundary.
- F#/ML lineage: immutable data, expressions-first style, pattern matching,
let/fun, algebraic modeling. - Interpreter pipeline: lexer -> parser -> type inference -> evaluator.
- Host-first extensibility: add external functions with explicit type schemes and runtime implementations.
- Security-aware embedding: script capabilities are defined by what the host exposes.
FScript currently includes:
- bindings and functions:
let,let rec,andmutual recursion, lambdas, - control flow:
if/elif/else,match,for ... in ... do, - data: list, option, tuple, map, record, discriminated unions,
- pattern matching: list, option, tuple, record, union cases,
- optional type annotations on parameters,
- type declarations: records and unions (including recursive forms),
- interpolation, pipeline operator,
typeoftype tokens, andnameofidentifier tokens for host workflows.
make buildmake testdotnet run --project src/FScript -- samples/types-showcase.fssOptional sandbox root override:
dotnet run --project src/FScript -- --root /tmp/sandbox samples/types-showcase.fssUseful samples:
samples/types-showcase.fsssamples/patterns-and-collections.fsssamples/tree.fsssamples/mutual-recursion.fss
brew install magnusopera/tap/fscriptMagnusOpera.FScript.LanguageMagnusOpera.FScript.Runtime
The core engine lives in src/FScript.Language and runs in four stages:
- Lexing: indentation-aware tokenization.
- Parsing: AST construction with expression/layout rules.
- Type inference: Hindley-Milner inference + unification + optional annotations.
- Evaluation: typed AST evaluation with immutable values and pattern matching.
Host integration lives in src/FScript.Runtime.
FScript is extended through host-provided externs.
Each extern declares:
- a public name (for script calls),
- a type scheme,
- arity,
- implementation.
Built-in extern families include List.*, Map.*, Option.*, Fs.*, Json.*, Xml.*, Regex.*, hashing, GUIDs, and print.
For details and extension workflow, see docs/external-functions.md.
FScript runs in-process. Security is capability-based:
- scripts can only do what exposed externs allow,
- core language evaluation is deterministic over in-memory values,
- side effects and external I/O are controlled at host extern boundaries.
Operational controls (timeouts, cancellation, resource limits, process/container isolation) are host responsibilities.
See docs/sandbox-and-security.md for the full model and checklist.
docs/syntax-and-indentation.mddocs/supported-types.mddocs/function-annotations.mddocs/external-functions.mddocs/embedding-fscript-language.mddocs/sandbox-and-security.mddocs/fsharp-ocaml-differences.mddocs/assemblies-and-roles.md
This project is licensed under the MIT License.
See LICENSE.