Header menu logo FSharp.Core

ExtraTopLevelOperators Module

A set of extra operators and functions. This module is automatically opened in all F# code.

Nested modules

Modules Description

Checked

Functions and values

Function or value Description

(~%%) expression

Full Usage: (~%%) expression

Parameters:
Returns: 'T

Special prefix operator for splicing untyped expressions into quotation holes.

expression : Expr
Returns: 'T
Example

 let f v = <@@ (%%v: int) + (%%v: int) @@>

 f <@@ 5 + 5 @@>;;
val f: v: Quotations.Expr -> Quotations.Expr
val v: Quotations.Expr
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
Evaluates to an untyped quotation equivalent to <@@ (5 + 5) + (5 + 5) @@>

(~%) expression

Full Usage: (~%) expression

Parameters:
    expression : Expr<'T>

Returns: 'T

Special prefix operator for splicing typed expressions into quotation holes.

expression : Expr<'T>
Returns: 'T
Example

 let f v = <@ %v + %v @>

 f <@ 5 + 5 @>;;
val f: v: Quotations.Expr<int> -> Quotations.Expr<int>
val v: Quotations.Expr<int>
Evaluates to a quotation equivalent to <@ (5 + 5) + (5 + 5) @>

array2D rows

Full Usage: array2D rows

Parameters:
    rows : 'a seq

Returns: 'T[,]

Builds a 2D array from a sequence of sequences of elements.

rows : 'a seq
Returns: 'T[,]
Example

 array2D [ [ 1.0; 2.0 ]; [ 3.0; 4.0 ] ]
val array2D: rows: #('T seq) seq -> 'T array2d
Evaluates to a 2x2 zero-based array with contents [[1.0; 2.0]; [3.0; 4.0]]

async

Full Usage: async

Returns: AsyncBuilder

Builds an asynchronous workflow using computation expression syntax.

Returns: AsyncBuilder
Example

 let sleepExample() =
     async {
         printfn "sleeping"
         do! Async.Sleep 10
         printfn "waking up"
         return 6
      }

 sleepExample() |> Async.RunSynchronously
val sleepExample: unit -> Async<int>
val async: AsyncBuilder
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...

--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
static member Async.RunSynchronously: computation: Async<'T> * ?timeout: int * ?cancellationToken: System.Threading.CancellationToken -> 'T

dict keyValuePairs

Full Usage: dict keyValuePairs

Parameters:
    keyValuePairs : ('Key * 'Value) seq

Returns: IDictionary<'Key, 'Value>

Builds a read-only lookup table from a sequence of key/value pairs. The key objects are indexed using generic hashing and equality.

keyValuePairs : ('Key * 'Value) seq
Returns: IDictionary<'Key, 'Value>
Example

 let table = dict [ (1, 100); (2, 200) ]

 table[1]
val table: System.Collections.Generic.IDictionary<int,int>
val dict: keyValuePairs: ('Key * 'Value) seq -> System.Collections.Generic.IDictionary<'Key,'Value> (requires equality)
Evaluates to 100.

Example

 let table = dict [ (1, 100); (2, 200) ]

 table[3]
val table: System.Collections.Generic.IDictionary<int,int>
val dict: keyValuePairs: ('Key * 'Value) seq -> System.Collections.Generic.IDictionary<'Key,'Value> (requires equality)
Throws System.Collections.Generic.KeyNotFoundException.

double value

Full Usage: double value

Parameters:
    value : ^T

Returns: double
Modifiers: inline
Type parameters: ^T

Converts the argument to 64-bit float.

This is a direct conversion for all primitive numeric types. For strings, the input is converted using Double.Parse() with InvariantCulture settings. Otherwise the operation requires and invokes a ToDouble method on the input type.

value : ^T
Returns: double
Example

 double 45
Multiple items
val double: value: 'T -> double (requires member op_Explicit)

--------------------
type double = System.Double

--------------------
type double<'Measure> = float<'Measure>
Evaluates to 45.0.

Example

 double 12.3f
Multiple items
val double: value: 'T -> double (requires member op_Explicit)

--------------------
type double = System.Double

--------------------
type double<'Measure> = float<'Measure>
Evaluates to 12.30000019.

eprintf format

Full Usage: eprintf format

Parameters:
Returns: 'T The formatted result.

Print to stderr using the given format.

format : TextWriterFormat<'T>

The formatter.

Returns: 'T

The formatted result.

Example

See Printf.eprintf (link: Printf.PrintFormatToError) for examples.

eprintfn format

Full Usage: eprintfn format

Parameters:
Returns: 'T The formatted result.

Print to stderr using the given format, and add a newline.

format : TextWriterFormat<'T>

The formatter.

Returns: 'T

The formatted result.

Example

See Printf.eprintfn (link: Printf.PrintFormatLineToError) for examples.

failwithf format

Full Usage: failwithf format

Parameters:
Returns: 'T The formatted result.

Print to a string buffer and raise an exception with the given result. Helper printers must return strings.

format : StringFormat<'T, 'Result>

The formatter.

Returns: 'T

The formatted result.

Example

See Printf.failwithf (link: Printf.PrintFormatToStringThenFail) for examples.

fprintf textWriter format

Full Usage: fprintf textWriter format

Parameters:
Returns: 'T The formatted result.

Print to a file using the given format.

textWriter : TextWriter

The file TextWriter.

format : TextWriterFormat<'T>

The formatter.

Returns: 'T

The formatted result.

Example

See Printf.fprintf (link: Printf.PrintFormatToTextWriter) for examples.

fprintfn textWriter format

Full Usage: fprintfn textWriter format

Parameters:
Returns: 'T The formatted result.

Print to a file using the given format, and add a newline.

textWriter : TextWriter

The file TextWriter.

format : TextWriterFormat<'T>

The formatter.

Returns: 'T

The formatted result.

Example

See Printf.fprintfn (link: Printf.PrintFormatLineToTextWriter) for examples.

int8 value

Full Usage: int8 value

Parameters:
    value : ^T

Returns: int8
Modifiers: inline
Type parameters: ^T

Converts the argument to signed byte.

This is a direct conversion for all primitive numeric types. For strings, the input is converted using SByte.Parse() with InvariantCulture settings. Otherwise the operation requires and invokes a ToSByte method on the input type.

value : ^T
Returns: int8
Example

 int8 -12
Multiple items
val int8: value: 'T -> int8 (requires member op_Explicit)

--------------------
type int8 = System.SByte

--------------------
type int8<'Measure> = sbyte<'Measure>
Evaluates to -12y.

Example

 int8 "3"
Multiple items
val int8: value: 'T -> int8 (requires member op_Explicit)

--------------------
type int8 = System.SByte

--------------------
type int8<'Measure> = sbyte<'Measure>
Evaluates to 3y.

printf format

Full Usage: printf format

Parameters:
Returns: 'T The formatted result.

Print to stdout using the given format.

format : TextWriterFormat<'T>

The formatter.

Returns: 'T

The formatted result.

Example

See Printf.printf (link: Printf.PrintFormat) for examples.

printfn format

Full Usage: printfn format

Parameters:
Returns: 'T The formatted result.

Print to stdout using the given format, and add a newline.

format : TextWriterFormat<'T>

The formatter.

Returns: 'T

The formatted result.

Example

See Printf.printfn (link: Printf.PrintFormatLine) for examples.

query

Full Usage: query

Returns: QueryBuilder

Builds a query using query syntax and operators.

Returns: QueryBuilder
Example

 let findEvensAndSortAndDouble(xs: System.Linq.IQueryable<int>) =
     query {
         for x in xs do
         where (x % 2 = 0)
         sortBy x
         select (x+x)
      }

 let data = [1; 2; 6; 7; 3; 6; 2; 1]

 findEvensAndSortAndDouble (data.AsQueryable()) |> Seq.toList
val findEvensAndSortAndDouble: xs: System.Linq.IQueryable<int> -> System.Linq.IQueryable<int>
val xs: System.Linq.IQueryable<int>
namespace System
namespace System.Linq
Multiple items
type IQueryable = inherit IEnumerable member ElementType: Type member Expression: Expression member Provider: IQueryProvider
<summary>Provides functionality to evaluate queries against a specific data source wherein the type of the data is not specified.</summary>

--------------------
type IQueryable<'T> = inherit IEnumerable<'T> inherit IEnumerable inherit IQueryable
<summary>Provides functionality to evaluate queries against a specific data source wherein the type of the data is known.</summary>
<typeparam name="T">The type of the data in the data source.</typeparam>
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
val query: Linq.QueryBuilder
val x: int
custom operation: where (bool) Calls Linq.QueryBuilder.Where
custom operation: sortBy ('Key) Calls Linq.QueryBuilder.SortBy
custom operation: select ('Result) Calls Linq.QueryBuilder.Select
val data: int list
module Seq from Microsoft.FSharp.Collections
val toList: source: 'T seq -> 'T list
Evaluates to [4; 4; 12; 12].

readOnlyDict keyValuePairs

Full Usage: readOnlyDict keyValuePairs

Parameters:
    keyValuePairs : ('Key * 'Value) seq

Returns: IReadOnlyDictionary<'Key, 'Value>

Builds a read-only lookup table from a sequence of key/value pairs. The key objects are indexed using generic hashing and equality.

keyValuePairs : ('Key * 'Value) seq
Returns: IReadOnlyDictionary<'Key, 'Value>
Example

 let table = readOnlyDict [ (1, 100); (2, 200) ]

 table[1]
val table: System.Collections.Generic.IReadOnlyDictionary<int,int>
val readOnlyDict: keyValuePairs: ('Key * 'Value) seq -> System.Collections.Generic.IReadOnlyDictionary<'Key,'Value> (requires equality)
Evaluates to 100.

Example

 let table = readOnlyDict [ (1, 100); (2, 200) ]

 table[3]
val table: System.Collections.Generic.IReadOnlyDictionary<int,int>
val readOnlyDict: keyValuePairs: ('Key * 'Value) seq -> System.Collections.Generic.IReadOnlyDictionary<'Key,'Value> (requires equality)
Throws System.Collections.Generic.KeyNotFoundException.

set elements

Full Usage: set elements

Parameters:
    elements : 'T seq - The input sequence of elements.

Returns: Set<'T> The created set.

Builds a set from a sequence of objects. The objects are indexed using generic comparison.

elements : 'T seq

The input sequence of elements.

Returns: Set<'T>

The created set.

Example

 let values = set [ 1; 2; 3; 5; 7; 11 ]
val values: Set<int>
val set: elements: 'T seq -> Set<'T> (requires comparison)
Evaluates to a set containing the given numbers.

single value

Full Usage: single value

Parameters:
    value : ^T

Returns: single
Modifiers: inline
Type parameters: ^T

Converts the argument to 32-bit float.

This is a direct conversion for all primitive numeric types. For strings, the input is converted using Single.Parse() with InvariantCulture settings. Otherwise the operation requires and invokes a ToSingle method on the input type.

value : ^T
Returns: single
Example

 single 45
Multiple items
val single: value: 'T -> single (requires member op_Explicit)

--------------------
type single = System.Single

--------------------
type single<'Measure> = float32<'Measure>
Evaluates to 45.0f.

sprintf format

Full Usage: sprintf format

Parameters:
Returns: 'T The formatted result.

Print to a string using the given format.

format : StringFormat<'T>

The formatter.

Returns: 'T

The formatted result.

Example

See Printf.sprintf (link: Printf.PrintFormatToStringThen) for examples.

uint8 value

Full Usage: uint8 value

Parameters:
    value : ^T

Returns: uint8
Modifiers: inline
Type parameters: ^T

Converts the argument to byte.

This is a direct conversion for all primitive numeric types. For strings, the input is converted using Byte.Parse() on strings and otherwise requires a ToByte method on the input type.

value : ^T
Returns: uint8
Example

 uint8 12
Multiple items
val uint8: value: 'T -> uint8 (requires member op_Explicit)

--------------------
type uint8 = System.Byte

--------------------
type uint8<'Measure> = byte<'Measure>
Evaluates to 12uy.

Active patterns

Active pattern Description

(|Lazy|) input

Full Usage: (|Lazy|) input

Parameters:
Returns: 'T

An active pattern to force the execution of values of type Lazy<_>.

input : Lazy<'T>
Returns: 'T
Example

 let f (Lazy v) = v + v

 let v = lazy (printf "eval!"; 5+5)

 f v
 f v
val f: Lazy<int> -> int
Multiple items
active recognizer Lazy: Lazy<'T> -> 'T

--------------------
type Lazy<'T> = System.Lazy<'T>
val v: int
val v: Lazy<int>
val printf: format: Printf.TextWriterFormat<'T> -> 'T
Evaluates to 10. The text eval! is printed once on the first invocation of f.

Type something to start searching.