Your first useful FScript in five minutes
You will build a small pricing rule, run it, and see the language features that make FScript useful inside a host application.
Want to touch the language before installing anything? Open the browser playground, change a number in the first example, and press Run.
1. Install the CLI
Choose one route. The .NET tool works anywhere supported by the .NET SDK; Homebrew is the shortest path on macOS.
.NET tool
dotnet tool install --global MagnusOpera.FScript
Homebrew
brew install magnusopera/tap/fscript
Check the installation:
fscript version
Building from source instead
git clone https://github.com/MagnusOpera/FScript.git
cd FScript
make build
Run scripts with dotnet run --project src/FScript -- your-script.fss.
2. Create a rule
Create pricing.fss:
type Plan =
| Starter
| Team
| Scale
let pricePerSeat plan =
match plan with
| Starter -> 9
| Team -> 19
| Scale -> 29
let quote plan seats =
pricePerSeat plan * seats
let total = quote Scale 12
Console.writeLine $"12 Scale seats: ${total}/month"
Run it:
fscript pricing.fss
You should see:
12 Scale seats: $348/month
You have already used four important ideas:
type Plannames the only valid plan choices.matchhandles every choice explicitly.let quote plan seatsdeclares a function without type boilerplate.- the compiler infers the types and checks the program before it runs.
Try removing the Scale branch or calling quote "Scale" 12. The type checker will stop the mistake at the script boundary.
3. Make the rule host-callable
An embedded script exposes only the bindings you mark as part of its host contract. Add the export annotation:
[<export>] let quote plan seats =
pricePerSeat plan * seats
Your .NET or JavaScript host can now load the script and invoke quote by name. Everything else remains an implementation detail of the script.
- Follow the complete .NET host example.
- Use FScript from JavaScript or a browser host.
- Learn how typed externs let scripts call capabilities supplied by your application.
4. Pick your next move
| If you want to… | Go here |
|---|---|
| Learn the core syntax quickly | Language Tour |
| Change and run examples | Browser Playground |
| Build something recognizable | Guided Examples |
| Put FScript inside an application | Embedding Overview |
REPL and script arguments
Run fscript with no file to start an interactive session:
fscript
Pass script arguments after --:
fscript pricing.fss -- acme scale
The script receives them as the string list value Env.Arguments.
Editor setup
The official VS Code extension adds diagnostics, completion, hover, go-to-definition, references, rename, semantic tokens, and inlay hints.
See Editor Setup for the full walkthrough.