Built-ins
This page covers the top-level built-ins that are always in scope even though they are not module members.
Values and functions
| Name | Signature | Description |
|---|---|---|
Env | Environment | Host-injected execution metadata for CLI file runs, stdin runs, and the REPL. |
print | string -> unit | Writes a line of text to standard output. |
ignore | 'a -> unit | Discards a value when only the side effect of an expression matters. |
type Environment
type Environment =
{ ScriptName: string option
Arguments: string list }
The host exposes Env with this shape:
Env.ScriptNameisSome "path/to/script.fss"for file execution.Env.ScriptNameisNonefor stdin execution and the REPL.Env.Argumentscontains 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 FsKind, which lets scripts branch on filesystem state with pattern matching:
match Fs.kind "samples" with
| Directory path -> print $"dir: {path}"
| File path -> print $"file: {path}"
| Missing -> print "missing"
print : string -> unit
Use print for script output and quick debugging.
print "hello"
ignore : 'a -> unit
Use ignore when an expression returns a value you intentionally do not need.
String.indexOf "x" "text" |> ignore