Logo FSharp.Core

Unchecked Module

This module contains basic operations which do not apply runtime and/or static checks

Functions and values

Function or value Description

compare arg1 arg2

Full Usage: compare arg1 arg2

Parameters:
    arg0 : 'T
    arg1 : 'T

Returns: int The result of the comparison.
Modifiers: inline
Type parameters: 'T

Perform generic comparison on two values where the type of the values is not statically required to have the 'comparison' constraint.

arg0 : 'T
arg1 : 'T
Returns: int

The result of the comparison.

defaultof

Full Usage: defaultof

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

Generate a default value for any type. This is null for reference types, For structs, this is struct value where all fields have the default value. This function is unsafe in the sense that some F# values do not have proper null values.

Returns: 'T

equals arg1 arg2

Full Usage: equals arg1 arg2

Parameters:
    arg0 : 'T
    arg1 : 'T

Returns: bool The result of the comparison.
Modifiers: inline
Type parameters: 'T

Perform generic equality on two values where the type of the values is not statically required to satisfy the 'equality' constraint.

arg0 : 'T
arg1 : 'T
Returns: bool

The result of the comparison.

hash arg1

Full Usage: hash arg1

Parameters:
    arg0 : 'T

Returns: int The computed hash value.
Modifiers: inline
Type parameters: 'T

Perform generic hashing on a value where the type of the value is not statically required to satisfy the 'equality' constraint.

arg0 : 'T
Returns: int

The computed hash value.

nonNull value

Full Usage: nonNull value

Parameters:
    value : 'T - The possibly nullable value.

Returns: 'T The same value as in the input.
Modifiers: inline
Type parameters: 'T (requires not struct)

Unsafely retypes the value from ('T | null) to 'T without doing any null check at runtime. This is an unsafe operation.

value : 'T

The possibly nullable value.

Returns: 'T

The same value as in the input.

unbox value

Full Usage: unbox value

Parameters:
    value : objnull - The boxed value.

Returns: 'T The unboxed result.
Modifiers: inline
Type parameters: 'T

Unboxes a strongly typed value. This is the inverse of box, unbox<t>(box<t> a) equals a.

value : objnull

The boxed value.

Returns: 'T

The unboxed result.

withNull value

Full Usage: withNull value

Parameters:
    value : 'T - The value.

Returns: 'T The same value, retyped as ('T | null).
Modifiers: inline
Type parameters: 'T

Unsafely retypes the value from 'T to ('T | null), bypassing the 'not null' and 'not struct' constraints that F# otherwise requires in order to write ('T | null). This is an unsafe operation.

This exists purely for interoperability with C# APIs that expose an unconstrained nullable generic, such as a method T? M<T>() or an interface member T? GetValue<T>(int index) where T has no class constraint and can therefore also be a struct. Without it such a signature cannot be implemented or consumed from F# without spurious FS3261 nullness warnings. It is unsafe precisely because it sidesteps those constraints. Unlike Operators.withNull it adds no not null or not struct constraint, so the resulting ('T | null) can be formed even when 'T is a struct, where null is not a representable value: there the annotation carries no runtime meaning and is erased, and assigning null to such a location yields Unchecked.defaultof<'T> rather than a true null. Use it only to satisfy an interop signature.

value : 'T

The value.

Returns: 'T

The same value, retyped as ('T | null).

Active patterns

Active pattern Description

(|NonNullQuick|) value

Full Usage: (|NonNullQuick|) value

Parameters:
    value : 'T - The value to retype from ('T | null) to 'T .

Returns: 'T The non-null value.
Modifiers: inline
Type parameters: 'T (requires not struct)

When used in a pattern forgets 'nullness' of the value without any runtime check. This is an unsafe operation, as null check is being skipped and null value can be returned.

value : 'T

The value to retype from ('T | null) to 'T .

Returns: 'T

The non-null value.

Type something to start searching.