Header menu logo TDesu.FSharp

Operators Module

Functions and values

Function or value Description

field <-? a

Full Usage: field <-? a

Parameters:
    field : byref<'a voption> - Byref field to assign to.
    a : 'a - Value to wrap; if null, assigns ValueNone.

Modifiers: inline
Type parameters: 'a

Assigns ValueSome(a) to a byref field, or ValueNone if a is null.

field : byref<'a voption>

Byref field to assign to.

a : 'a

Value to wrap; if null, assigns ValueNone.

f ^ x

Full Usage: f ^ x

Parameters:
    f : 'a -> 'b - Function to apply.
    x : 'a - Argument to pass to the function.

Returns: 'b
Modifiers: inline
Type parameters: 'a, 'b

Reverse application operator: f ^ x is equivalent to f x. Avoids extra parentheses in nested calls. Unlike the backward pipe <|, ^ has higher precedence (binds tighter than comparisons and logical operators). Both are right-associative: f ^ g ^ x = f (g x).

f : 'a -> 'b

Function to apply.

x : 'a

Argument to pass to the function.

Returns: 'b
Example

 let result = string ^ 42 + 1            // string (42 + 1) = "43"
 raise ^ Exception ^ sprintf "err: %s" s  // raise (Exception (sprintf "err: %s" s))

 // <| conflicts with = (same precedence), requiring parentheses:
 if x = (f <| 42) then ...   // need parens — ambiguous without them
 if x = f ^ 42 then ...        // ^ binds tighter than = — just works
val result: string
Multiple items
val string: value: 'T -> string

--------------------
type string = System.String
val raise: exn: System.Exception -> 'T
val sprintf: format: Printf.StringFormat<'T> -> 'T

~%x

Full Usage: ~%x

Parameters:
    x : 'a - Value whose return is discarded.

Modifiers: inline
Type parameters: 'a

Ignores the return value of an expression. Useful for fluent/chain APIs that return this.

x : 'a

Value whose return is discarded.

Example

 %list.Add(42)  // Add returns void in C#, but this silences any return
type 'T list = List<'T>

aggregate errors

Full Usage: aggregate errors

Parameters:
    errors : exn seq - Inner exceptions to aggregate.

Returns: 'a
Modifiers: inline
Type parameters: 'a

Throws AggregateException wrapping multiple errors.

errors : exn seq

Inner exceptions to aggregate.

Returns: 'a
AggregateException Always thrown.

always x arg2

Full Usage: always x arg2

Parameters:
    x : 'a - Value to always return.
    arg1 : 'b

Returns: 'a
Modifiers: inline
Type parameters: 'a, 'b

Always returns the first argument, ignoring the second. always x _ = x.

x : 'a

Value to always return.

arg1 : 'b
Returns: 'a

argRange paramName msg

Full Usage: argRange paramName msg

Parameters:
    paramName : string - Name of the parameter.
    msg : string - Exception message.

Returns: 'a
Modifiers: inline
Type parameters: 'a
paramName : string

Name of the parameter.

msg : string

Exception message.

Returns: 'a
ArgumentOutOfRangeException Always thrown.

argRangeVal paramName actualValue msg

Full Usage: argRangeVal paramName actualValue msg

Parameters:
    paramName : string - Name of the parameter.
    actualValue : obj - The out-of-range value.
    msg : string - Exception message.

Returns: 'a
Modifiers: inline
Type parameters: 'a

Throws ArgumentOutOfRangeException including the actual value.

paramName : string

Name of the parameter.

actualValue : obj

The out-of-range value.

msg : string

Exception message.

Returns: 'a
ArgumentOutOfRangeException Always thrown.

camelCaseToSnakeCase str

Full Usage: camelCaseToSnakeCase str

Parameters:
    str : string - The CamelCase string to convert.

Returns: string

Converts a CamelCase string to snake_case.

str : string

The CamelCase string to convert.

Returns: string
Example

 camelCaseToSnakeCase "HelloWorld" // "hello_world"

disposed objectName

Full Usage: disposed objectName

Parameters:
    objectName : string - Name of the disposed object.

Returns: 'a
Modifiers: inline
Type parameters: 'a
objectName : string

Name of the disposed object.

Returns: 'a
ObjectDisposedException Always thrown.

ecast value

Full Usage: ecast value

Parameters:
    value : ^a - Value to convert.

Returns: ^b
Modifiers: inline
Type parameters: ^a, ^b

Explicit cast using op_Explicit. Equivalent to an explicit conversion in C#.

value : ^a

Value to convert.

Returns: ^b

icast value

Full Usage: icast value

Parameters:
    value : ^a - Value to convert.

Returns: ^b
Modifiers: inline
Type parameters: ^a, ^b

Implicit cast using op_Implicit. Equivalent to an implicit conversion in C#.

value : ^a

Value to convert.

Returns: ^b

inc a

Full Usage: inc a

Parameters:
    a : byref<^a> - Byref value to increment.

Modifiers: inline
Type parameters: ^a, ^a

Increments a byref numeric value in-place by one.

a : byref<^a>

Byref value to increment.

invalidCast msg

Full Usage: invalidCast msg

Parameters:
    msg : string - Exception message.

Returns: 'a
Modifiers: inline
Type parameters: 'a
msg : string

Exception message.

Returns: 'a
InvalidCastException Always thrown.

invalidCastf fmt

Full Usage: invalidCastf fmt

Parameters:
    fmt : StringFormat<'a, 'b> - Printf format string.

Returns: 'a
Modifiers: inline
Type parameters: 'a, 'b

Throws InvalidCastException with a formatted message.

fmt : StringFormat<'a, 'b>

Printf format string.

Returns: 'a

invalidOpf fmt

Full Usage: invalidOpf fmt

Parameters:
    fmt : StringFormat<'a, 'b> - Printf format string.

Returns: 'a
Modifiers: inline
Type parameters: 'a, 'b

Throws InvalidOperationException with a formatted message.

fmt : StringFormat<'a, 'b>

Printf format string.

Returns: 'a

isNotNull v

Full Usage: isNotNull v

Parameters:
    v : 'T - Reference-type value to check.

Returns: bool
Modifiers: inline
Type parameters: 'T

Returns true if the reference-type value is not null.

v : 'T

Reference-type value to check.

Returns: bool

isOptionType t

Full Usage: isOptionType t

Parameters:
    t : Type - Type to inspect.

Returns: bool

Returns true if the given Type is an F# Option type.

t : Type

Type to inspect.

Returns: bool

isValueOptionType t

Full Usage: isValueOptionType t

Parameters:
    t : Type - Type to inspect.

Returns: bool

Returns true if the given Type is an F# ValueOption type.

t : Type

Type to inspect.

Returns: bool

notImpl msg

Full Usage: notImpl msg

Parameters:
    msg : string - Exception message.

Returns: 'a
Modifiers: inline
Type parameters: 'a
msg : string

Exception message.

Returns: 'a
NotImplementedException Always thrown.

notImplf fmt

Full Usage: notImplf fmt

Parameters:
    fmt : StringFormat<'a, 'b> - Printf format string.

Returns: 'a
Modifiers: inline
Type parameters: 'a, 'b

Throws NotImplementedException with a formatted message.

fmt : StringFormat<'a, 'b>

Printf format string.

Returns: 'a

notSupported msg

Full Usage: notSupported msg

Parameters:
    msg : string - Exception message.

Returns: 'a
Modifiers: inline
Type parameters: 'a
msg : string

Exception message.

Returns: 'a
NotSupportedException Always thrown.

notSupportedf fmt

Full Usage: notSupportedf fmt

Parameters:
    fmt : StringFormat<'a, 'b> - Printf format string.

Returns: 'a
Modifiers: inline
Type parameters: 'a, 'b

Throws NotSupportedException with a formatted message.

fmt : StringFormat<'a, 'b>

Printf format string.

Returns: 'a

snakeCaseToCamelCase str

Full Usage: snakeCaseToCamelCase str

Parameters:
    str : string - The snake_case string to convert.

Returns: string

Converts a snake_case string to CamelCase.

str : string

The snake_case string to convert.

Returns: string
Example

 snakeCaseToCamelCase "hello_world" // "HelloWorld"

swap f a b

Full Usage: swap f a b

Parameters:
    f : 'T2 -> 'T1 -> 'a - Function whose arguments are swapped.
    a : 'T1 - Second argument passed to f.
    b : 'T2 - First argument passed to f.

Returns: 'a
Modifiers: inline
Type parameters: 'T2, 'T1, 'a

Swaps the two arguments of a function: swap f a b calls f b a.

f : 'T2 -> 'T1 -> 'a

Function whose arguments are swapped.

a : 'T1

Second argument passed to f.

b : 'T2

First argument passed to f.

Returns: 'a

tee f v

Full Usage: tee f v

Parameters:
    f : 'T -> unit - Side-effect action to apply.
    v : 'T - Value to pass through.

Returns: 'T
Modifiers: inline
Type parameters: 'T

Applies a side-effect action to a value, then returns the value unchanged. Useful for logging or debugging in a pipeline.

f : 'T -> unit

Side-effect action to apply.

v : 'T

Value to pass through.

Returns: 'T
Example

 let result = 42 |> tee (printfn "got %d") |> string
val result: string
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Multiple items
val string: value: 'T -> string

--------------------
type string = System.String

tee2 f g v

Full Usage: tee2 f g v

Parameters:
    f : 'T -> unit - First side-effect action.
    g : 'T -> unit - Second side-effect action.
    v : 'T - Value to pass through.

Returns: 'T
Modifiers: inline
Type parameters: 'T

Applies two side-effect actions to a value, then returns the value unchanged.

f : 'T -> unit

First side-effect action.

g : 'T -> unit

Second side-effect action.

v : 'T

Value to pass through.

Returns: 'T

timedOut msg

Full Usage: timedOut msg

Parameters:
    msg : string - Exception message.

Returns: 'a
Modifiers: inline
Type parameters: 'a
msg : string

Exception message.

Returns: 'a
TimeoutException Always thrown.

timedOutf fmt

Full Usage: timedOutf fmt

Parameters:
    fmt : StringFormat<'a, 'b> - Printf format string.

Returns: 'a
Modifiers: inline
Type parameters: 'a, 'b

Throws TimeoutException with a formatted message.

fmt : StringFormat<'a, 'b>

Printf format string.

Returns: 'a

toAction f

Full Usage: toAction f

Parameters:
    f : 'a -> unit

Returns: Action<'a>
Modifiers: inline
Type parameters: 'a

Wraps an F# function as a with 1 parameter. Function to wrap.

f : 'a -> unit
Returns: Action<'a>

toAction2 f

Full Usage: toAction2 f

Parameters:
    f : 'a -> 'b -> unit

Returns: Action<'a, 'b>
Modifiers: inline
Type parameters: 'a, 'b

Wraps an F# function as a with 2 parameters. Function to wrap.

f : 'a -> 'b -> unit
Returns: Action<'a, 'b>

toAction3 f

Full Usage: toAction3 f

Parameters:
    f : 'a -> 'b -> 'c -> unit

Returns: Action<'a, 'b, 'c>
Modifiers: inline
Type parameters: 'a, 'b, 'c

Wraps an F# function as a with 3 parameters. Function to wrap.

f : 'a -> 'b -> 'c -> unit
Returns: Action<'a, 'b, 'c>

ucast a

Full Usage: ucast a

Parameters:
    a : 'a - Value to cast.

Returns: 'b
Modifiers: inline
Type parameters: 'a, 'b

Unsafe cast like in C#.

a : 'a

Value to cast.

Returns: 'b

uncurry f (a, b)

Full Usage: uncurry f (a, b)

Parameters:
    f : 'a -> 'b -> 'c - Curried function to uncurry.
    a : 'a - First element of the tuple.
    b : 'b - Second element of the tuple.

Returns: 'c
Modifiers: inline
Type parameters: 'a, 'b, 'c

Uncurries a 2-arg function to accept a tuple.

f : 'a -> 'b -> 'c

Curried function to uncurry.

a : 'a

First element of the tuple.

b : 'b

Second element of the tuple.

Returns: 'c

uncurry3 f (a, b, c)

Full Usage: uncurry3 f (a, b, c)

Parameters:
    f : 'a -> 'b -> 'c -> 'd - Curried function to uncurry.
    a : 'a - First element of the triple.
    b : 'b - Second element of the triple.
    c : 'c - Third element of the triple.

Returns: 'd
Modifiers: inline
Type parameters: 'a, 'b, 'c, 'd

Uncurries a 3-arg function to accept a triple.

f : 'a -> 'b -> 'c -> 'd

Curried function to uncurry.

a : 'a

First element of the triple.

b : 'b

Second element of the triple.

c : 'c

Third element of the triple.

Returns: 'd

Type something to start searching.