Syntax Overview
FScript uses a small, expression-oriented syntax with arrows, immutable bindings, records, arrays, pattern matching, and explicit imports.
A compact tour
import Array from 'std:array'import Logger from 'std:logger'
type User = { id: String, name: String, active: Boolean,}
formatNames = (users: User[]): String[] => users |> Array.filter((user) => user.active) |> Array.map((user) => user.name)
main = (): Undefined => { names = formatNames([ { id: '1', name: 'Ada', active: true }, { id: '2', name: 'Grace', active: false }, ])
Logger.info(names)}
main()Forms you will use most
importandexportfor modulesname = expressionfor immutable bindingstype Name = ...for type aliases(args): Return => exprfor functions{ ... }for records and block expressions[ ... ]for arraysif (...) { ... } else { ... }for conditional expressionsmatch (value) { ... }for pattern-based branching|>for pipe-based composition
Major differences from JavaScript or TypeScript
- no
functionkeyword - no
return - no
let,const, orvar - no class syntax
- no array or object prototype methods
- no
async/await
Reading the rest of the guide
If you are new to FScript, a useful order is: