Skip to content

Latest commit

 

History

History
173 lines (134 loc) · 7.22 KB

stdlib-reference.md

File metadata and controls

173 lines (134 loc) · 7.22 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.await 'a task -> 'a
Task.spawn (unit -> 'a) -> 'a task

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.