Skip to content

XanthamFableCore

module XanthamFableCore
AssemblyXantham.Fable.Core
Attributes[<AutoOpen>]

Declared inside

BrandCrossing the brand boundary
IntersectConstructing an intersection with an operand F# cannot inherit (Intersect<'A, 'B>)
KeyOf
PropTypeBuilder
TypeKeyOf

Functions and values

keyof<'T, 'ReturnType> (fn: 'T -> 'ReturnType) : keyof<'T>

Get a property key from a mapping function for the given type.

type Book<'T> = { Title: keyof<'T> }
type LibraryHires = {
Witcher: int
Dune: int
}
let makeBook (key: keyof<LibraryHires>): Book<LibraryHires> = {
Title = key
}
let dune = makeBook (keyof<_, _> _.Dune)
dune.Title.Value // "Dune"
typekeyof<'T, 'ReturnType> (fn: 'T -> 'ReturnType) : typekeyof<'T,'ReturnType>

Equivalent to keyof but keeps the return type.

Properties

member inline Left: 'A

The value read as its first operand. Erased: no copy, no conversion.

member inline Right: 'B

The value read as its second operand. Erased: no copy, no conversion.

Methods

static member inline Access<'T> (accessedObject: 'T, key: keyof<'T>) : obj option
member inline Invoke<'T> (obj: 'T) : obj option

Active patterns

((|KeyIs|_|)) (value: string) (comp: keyof<'T>) : bool

Pattern matching against a property key using strings.

type TestObject = {
Field1: int
Field2: string
}
let fieldAccessor = keyof _.Field1
match fieldAccessor with
| KeyIs "Field1" -> true
| KeyIs "Field2" -> false
((|TypeKeyIs|_|)) (value: string) (comp: typekeyof<'T,'U>) : bool

Pattern matching against a type property key using strings.

Extension members

static member inline UnsafeAccess<'T, 'a> (accessedObject: obj, key: keyof<'a>) : obj option