FSharp.Core


Var Type

Information at the binding site of a variable

Constructors

Constructor Description

Var(name, typ, ?isMutable)

Full Usage: Var(name, typ, ?isMutable)

Parameters:
    name : string - The declared name of the variable.
    typ : Type - The type associated with the variable.
    ?isMutable : bool - Indicates if the variable represents a mutable storage location. Default is false.

Returns: Var The created variable.

Creates a new variable with the given name, type and mutability

name : string

The declared name of the variable.

typ : Type

The type associated with the variable.

?isMutable : bool

Indicates if the variable represents a mutable storage location. Default is false.

Returns: Var

The created variable.

Example

 open FSharp.Quotations
 open FSharp.Quotations.Patterns

 let valueVar = Var("value"), typeof<int>)
Evaluates to a new quotation variable with the given name and type.

Instance members

Instance member Description

this.IsMutable

Full Usage: this.IsMutable

Returns: bool

Indicates if the variable represents a mutable storage location

Returns: bool
Example

 open FSharp.Quotations
 open FSharp.Quotations.Patterns

 match <@ fun v -> v @> with
 | Lambda(v, body) -> v.IsMutable
 | _ -> failwith "unreachable"
Evaluates to false.

this.Name

Full Usage: this.Name

Returns: string

The declared name of the variable

Returns: string
Example

 open FSharp.Quotations
 open FSharp.Quotations.Patterns

 match <@ fun v -> v @> with
 | Lambda(v, body) -> v.Name
 | _ -> failwith "unreachable"
Evaluates to "v"

this.Type

Full Usage: this.Type

Returns: Type

The type associated with the variable

Returns: Type
Example

 open FSharp.Quotations
 open FSharp.Quotations.Patterns

 match <@ fun v -> v @> with
 | Lambda(v, body) -> v.Type
 | _ -> failwith "unreachable"
Evaluates to typeof<int>

Static members

Static member Description

Var.Global(name, typ)

Full Usage: Var.Global(name, typ)

Parameters:
    name : string - The name of the variable.
    typ : Type - The type associated with the variable.

Returns: Var The retrieved or created variable.

Fetches or create a new variable with the given name and type from a global pool of shared variables indexed by name and type

name : string

The name of the variable.

typ : Type

The type associated with the variable.

Returns: Var

The retrieved or created variable.

Example

 open FSharp.Quotations
 open FSharp.Quotations.Patterns

 let valueVar1 = Var.Global("value", typeof<int>)
 let valueVar2 = Var.Global("value", typeof<int>)
Evaluates both to valueVar1 and valueVar2 to the same variable from a global pool of shared variables.