Stdlib Overview
FScript ships with a built-in standard library.
It is loaded automatically and available in every script.
Modules
ListOptionMapStringIntFloatBool
Core rules
- Functions are curried.
- Pipe-friendly usage is preferred.
- Map keys are always
string(map indexer type is fixed to string). - Many parsing/indexing operations return
optioninstead of throwing.
Built-in types and values
FScript also provides a small set of always-available built-in types and values alongside the module functions.
type Environment
type Environment =
{ ScriptName: string option
Arguments: string list }
This is the shape of the CLI/REPL environment value exposed as Env.
let Env : Environment
Env is injected by the CLI host and REPL:
Env.ScriptNameisSome "..."when running a script file.Env.ScriptNameisNonein stdin mode and the REPL.Env.Argumentscontains the script arguments passed after--.
match Env.Arguments with
| name :: _ -> print $"hello {name}"
| [] -> print "hello"
type FsKind
type FsKind =
| File of string
| Directory of string
| Missing
Fs.kind returns this union so scripts can pattern match on filesystem lookups without separate boolean probes.
Continue with the module pages for full reference and examples.