Skip to content

Latest commit

 

History

History
341 lines (277 loc) · 16.9 KB

stdlib-reference.md

File metadata and controls

341 lines (277 loc) · 16.9 KB
id stdlib-reference
title Standard Library Signature Index
slug /reference/stdlib

This is the complete catalog of core functions/values and default .NET runtime externs. Each name links to argument order, examples, and failure behavior. Type variables are local to each signature; repeated variables in a row must agree.

Core functions are always available. Runtime functions require host registration, are enabled by default in the CLI, and are disabled by --no-default-externs or runtime.default-externs = false. JavaScript hosts provide their own externs. Registered custom providers add functions beyond this standard catalog.

Top-level surface

Name Type Availability
ignore 'a -> unit Core function; evaluates and discards its argument
Env Environment Value injected by CLI/REPL, optional in embedding hosts
Environment { ScriptName: string option; Arguments: string list } Built-in record type
FsKind File of string / Directory of string / Missing Built-in union type

Core library

Bool

Name Signature
Bool.toString bool -> string
Bool.tryParse string -> bool option

Float

Name Signature
Float.toString float -> string
Float.tryParse string -> float option

Int

Name Signature
Int.toString int -> string
Int.tryParse string -> int option

List

Name Signature
List.append 'a list -> 'a list -> 'a list
List.choose ('a -> 'b option) -> 'a list -> 'b list
List.collect ('a -> 'b list) -> 'a list -> 'b list
List.contains 'a -> 'a list -> bool
List.distinct 'a list -> 'a list
List.empty 'a list
List.exists ('a -> bool) -> 'a list -> bool
List.filter ('a -> bool) -> 'a list -> 'a list
List.fold ('b -> 'a -> 'b) -> 'b -> 'a list -> 'b
List.iter ('a -> unit) -> 'a list -> unit
List.length 'a list -> int
List.map ('a -> 'b) -> 'a list -> 'b list
List.rev 'a list -> 'a list
List.tail 'a list -> 'a list
List.tryFind ('a -> bool) -> 'a list -> 'a option
List.tryGet ('a -> bool) -> 'a list -> int option
List.tryHead 'a list -> 'a option
List.tryItem int -> 'a list -> 'a option

Map

Name Signature
Map.add 'b -> 'a -> 'a map['b] -> 'a map['b]
Map.choose ('b -> 'a -> 'c option) -> 'a map['b] -> 'c map['b]
Map.containsKey 'b -> 'a map['b] -> bool
Map.count 'a map['b] -> int
Map.empty 'a map['b]
Map.filter ('b -> 'a -> bool) -> 'a map['b] -> 'a map['b]
Map.fold ('c -> 'b -> 'a -> 'c) -> 'c -> 'a map['b] -> 'c
Map.iter ('b -> 'a -> unit) -> 'a map['b] -> unit
Map.map ('a -> 'c) -> 'a map['b] -> 'c map['b]
Map.ofList ('b * 'a) list -> 'a map['b]
Map.remove 'b -> 'a map['b] -> 'a map['b]
Map.tryGet 'b -> 'a map['b] -> 'a option

Option

Name Signature
Option.defaultValue 'a -> 'a option -> 'a
Option.defaultWith (unit -> 'a) -> 'a option -> 'a
Option.isNone 'a option -> bool
Option.isSome 'a option -> bool
Option.map ('a -> 'b) -> 'a option -> 'b option

String

Name Signature
String.concat string -> string list -> string
String.endsWith string -> string -> bool
String.indexOf string -> string -> int option
String.replace string -> string -> string -> string
String.split string -> string -> string list
String.substring int -> int -> string -> string option
String.toLower string -> string
String.toUpper string -> string

Default .NET runtime

Console

Name Signature
Console.readLine unit -> string option
Console.writeLine string -> unit

Fs

Name Signature
Fs.combinePath string -> string -> string
Fs.createDirectory string -> bool
Fs.enumerateFiles string -> string -> string list option
Fs.exists string -> bool
Fs.extension string -> string option
Fs.fileNameWithoutExtension string -> string
Fs.glob string -> string list option
Fs.kind string -> FsKind
Fs.parentDirectory string -> string option
Fs.readText string -> string option
Fs.writeText string -> string -> bool

Guid

Name Signature
Guid.new 'a -> string option

Hash

Name Signature
Hash.md5 string -> string option

Json

Name Signature
Json.deserialize type -> string -> 'a option
Json.serialize 'a -> string option

Regex

Name Signature
Regex.matchGroups string -> string -> string list option

Task

Name Signature
Task.spawn (unit -> 'a) -> 'a task
Task.delay int -> unit task
Task.fromResult 'a -> 'a task
Task.continueWith ('a -> 'b) -> 'a task -> 'b task
Task.whenAll ('a list -> 'b) -> 'a task list -> 'b task
Task.whenAny ('a -> 'b) -> 'a task list -> 'b task
Task.await 'a task -> 'a
Task.awaitAll 'a task list -> 'a list

Xml

Name Signature
Xml.queryValues string -> string -> string list option

Syntax and data forms

Constructors and syntax are separate from function registration: Some/None, union cases, literals, ranges, field access, list/map indexers, typeof, and nameof are covered in Native Types and Syntax and Operators. Host-provided type descriptors are covered in Host-Provided Types.

Json.deserialize uses a runtime type token; its generic result scheme does not statically encode the relationship between that token and the result. Guid.new accepts an ignored argument; use Guid.new (). List.contains compares scalars only; use List.exists with = for composite data.

Env.setExitCode : int -> unit selects the eventual shell status without stopping evaluation; see core builtins. It is effectful and accepts codes 0..255.

Expanded pure support library

Path, Glob, SemVer, scalar, and collection additions are core builtins. Encoding and SHA-256 are pure .NET runtime externs and need host registration. See each module for ordering, errors, and platform rules.

Int additions

Name Signature
Int.abs int -> int
Int.sign int -> int
Int.min int -> int -> int
Int.max int -> int -> int
Int.clamp int -> int -> int -> int
Int.toFloat int -> float

Float additions

Name Signature
Float.abs float -> float
Float.sign float -> int
Float.min float -> float -> float
Float.max float -> float -> float
Float.clamp float -> float -> float -> float
Float.floor float -> float
Float.ceil float -> float
Float.round float -> float
Float.truncate float -> float
Float.sqrt float -> float
Float.log float -> float
Float.log10 float -> float
Float.exp float -> float
Float.sin float -> float
Float.cos float -> float
Float.tan float -> float
Float.asin float -> float
Float.acos float -> float
Float.atan float -> float
Float.pow float -> float -> float
Float.atan2 float -> float -> float
Float.isNaN float -> bool
Float.isInfinity float -> bool
Float.isFinite float -> bool
Float.pi float
Float.tryToInt float -> int option

String additions

Name Signature
String.compare string -> string -> int
String.length string -> int
String.isEmpty string -> bool
String.isWhiteSpace string -> bool
String.trim string -> string
String.trimStart string -> string
String.trimEnd string -> string
String.splitLines string -> string list
String.startsWith string -> string -> bool
String.contains string -> string -> bool
String.padLeft int -> string -> string
String.padRight int -> string -> string
String.repeat int -> string -> string

List additions

Name Signature
List.isEmpty 'a list -> bool
List.forall ('a -> bool) -> 'a list -> bool
List.mapi (int -> 'a -> 'b) -> 'a list -> 'b list
List.indexed 'a list -> ((int * 'a)) list
List.init int -> (int -> 'a) -> 'a list
List.take int -> 'a list -> 'a list
List.skip int -> 'a list -> 'a list
List.takeWhile ('a -> bool) -> 'a list -> 'a list
List.skipWhile ('a -> bool) -> 'a list -> 'a list
List.partition ('a -> bool) -> 'a list -> ('a list * 'a list)
List.zip 'a list -> 'b list -> (('a * 'b)) list
List.unzip (('a * 'b)) list -> ('a list * 'b list)
List.chunkBySize int -> 'a list -> 'a list list
List.scan ('d -> 'a -> 'd) -> 'd -> 'a list -> 'd list
List.sortWith ('a -> 'a -> int) -> 'a list -> 'a list
List.sortBy ('a -> 'c) -> 'a list -> 'a list
List.distinctBy ('a -> 'c) -> 'a list -> 'a list
List.groupBy ('a -> 'c) -> 'a list -> (('c * 'a list)) list
List.countBy ('a -> 'c) -> 'a list -> (('c * int)) list

Map additions

Name Signature
Map.keys 'a map['c] -> 'c list
Map.values 'a map['c] -> 'a list
Map.toList 'a map['c] -> (('c * 'a)) list
Map.exists ('c -> 'a -> bool) -> 'a map['c] -> bool
Map.forall ('c -> 'a -> bool) -> 'a map['c] -> bool
Map.update 'c -> ('a option -> 'a option) -> 'a map['c] -> 'a map['c]
Map.mergeWith ('c -> 'a -> 'a -> 'a) -> 'a map['c] -> 'a map['c] -> 'a map['c]

Option additions

Name Signature
Option.bind ('a -> 'b option) -> 'a option -> 'b option
Option.flatten 'a option option -> 'a option
Option.filter ('a -> bool) -> 'a option -> 'a option
Option.orElse 'a option -> 'a option -> 'a option
Option.orElseWith (unit -> 'a option) -> 'a option -> 'a option
Option.map2 ('a -> 'b -> 'd) -> 'a option -> 'b option -> 'd option
Option.toList 'a option -> 'a list

Path additions

Name Signature
Path.normalize string -> string
Path.isAbsolute string -> bool
Path.combine string -> string -> string
Path.fileName string -> string
Path.extension string -> string option
Path.fileNameWithoutExtension string -> string
Path.parent string -> string option
Path.relative string -> string -> string option

Glob additions

Name Signature
Glob.isMatch string -> string -> bool
Glob.filter string -> string list -> string list

SemVer additions

Name Signature
SemVer.tryParse string -> ({ Build: string; Major: string; Minor: string; Patch: string; PreRelease: string }) option
SemVer.format { Build: string; Major: string; Minor: string; Patch: string; PreRelease: string } -> string
SemVer.compare string -> string -> int option

Encoding additions

Name Signature
Encoding.utf8Encode string -> int list option
Encoding.utf8Decode int list -> string option
Encoding.base64Encode int list -> string option
Encoding.base64Decode string -> int list option
Encoding.hexEncode int list -> string option
Encoding.hexDecode string -> int list option
Encoding.uriEncode string -> string option
Encoding.uriDecode string -> string option

Hash additions

Name Signature
Hash.sha256 string -> string option
Hash.sha256Bytes int list -> string option