FSharpPlus


Lens Module

Lens functions and operators

Nested modules

Modules Description

Array

IReadOnlyDictionary

List

Map

Set

Functions and values

Function or value Description

lens %-> updater

Full Usage: lens %-> updater

Parameters:
    lens : ('a -> Identity<'b>) -> 's -> Identity<'t> - The lens.
    updater : 'a -> 'b - A function that converts the value we want to write in the part targeted by the lens.

Returns: 's -> 't The new object with the value modified.

Update a value in a lens. Same as ``over``.

lens : ('a -> Identity<'b>) -> 's -> Identity<'t>

The lens.

updater : 'a -> 'b

A function that converts the value we want to write in the part targeted by the lens.

Returns: 's -> 't

The new object with the value modified.

lens .-> value

Full Usage: lens .-> value

Parameters:
    lens : ('a -> Identity<'b>) -> 's -> Identity<'t> - The lens.
    value : 'b - The value we want to write in the part targeted by the lens.

Returns: 's -> 't The new object with the value modified.

Write to a lens. Same as ``setl``.

lens : ('a -> Identity<'b>) -> 's -> Identity<'t>

The lens.

value : 'b

The value we want to write in the part targeted by the lens.

Returns: 's -> 't

The new object with the value modified.

x <&> f

Full Usage: x <&> f

Parameters:
    x : ^F<'t> - The functor.
    f : 't -> 'u - The mapper function.

Returns: 'F<'u> The mapped Functor.
Modifiers: inline
Type parameters: ^F<'t>, 't, 'u, 'F<'u>

An infix flipped map, restricted to non-primitive types.

x : ^F<'t>

The functor.

f : 't -> 'u

The mapper function.

Returns: 'F<'u>

The mapped Functor.

source ^. lens

Full Usage: source ^. lens

Parameters:
    source : 's - The object.
    lens : ('a -> Const<'a, 'b>) -> 's -> Const<'a, 't> - The lens.

Returns: 'a The part the lens is targeting.

Read from a lens. Same as ``view`` but with the arguments flipped.

source : 's

The object.

lens : ('a -> Const<'a, 'b>) -> 's -> Const<'a, 't>

The lens.

Returns: 'a

The part the lens is targeting.

s ^.. l

Full Usage: s ^.. l

Parameters:
Returns: 'd list

Extract a list of the targets of a Fold. Same as ``toListOf`` but with the arguments flipped.

s : 'a
l : ('b -> Const<Endo<'b list>, 'c>) -> 'a -> Const<Endo<'d list>, 'e>
Returns: 'd list

source ^? prism

Full Usage: source ^? prism

Parameters:
    source : 's - The object.
    prism : ('a -> Const<First<'a>, 'b>) -> 's -> Const<First<'a>, 't> - The prism.

Returns: 'a option The value (if any) the prism is targeting.

Retrieve the first value targeted by a Prism, Fold or Traversal (or Some result from a Getter or Lens). Same as ``preview`` but with the arguments flipped.

source : 's

The object.

prism : ('a -> Const<First<'a>, 'b>) -> 's -> Const<First<'a>, 't>

The prism.

Returns: 'a option

The value (if any) the prism is targeting.

_1 f t

Full Usage: _1 f t

Parameters:
    f : 'a -> ^b
    t : ^f

Returns: 'e
Modifiers: inline

Lens for the first element of a tuple

f : 'a -> ^b
t : ^f
Returns: 'e

_2 f t

Full Usage: _2 f t

Parameters:
    f : 'a -> ^b
    t : ^f

Returns: 'e
Modifiers: inline

Lens for the second element of a tuple

f : 'a -> ^b
t : ^f
Returns: 'e

_3 f t

Full Usage: _3 f t

Parameters:
    f : 'a -> ^b
    t : ^f

Returns: 'e
Modifiers: inline

Lens for the third element of a tuple

f : 'a -> ^b
t : ^f
Returns: 'e

_4 f t

Full Usage: _4 f t

Parameters:
    f : 'a -> ^b
    t : ^f

Returns: 'e
Modifiers: inline

Lens for the fourth element of a tuple

f : 'a -> ^b
t : ^f
Returns: 'e

_5 f t

Full Usage: _5 f t

Parameters:
    f : 'a -> ^b
    t : ^f

Returns: 'e
Modifiers: inline

Lens for the fifth element of a tuple

f : 'a -> ^b
t : ^f
Returns: 'e

_Error x

Full Usage: _Error x

Parameters:
    x : 'a -> ^b

Returns: Result<'d, 'a> -> ^e
Modifiers: inline

Prism providing a Traversal for targeting the 'Error' part of a Result<'T,'Error>

x : 'a -> ^b
Returns: Result<'d, 'a> -> ^e

_None x

Full Usage: _None x

Parameters:
    x : unit -> ^a

Returns: 'c option -> ^d
Modifiers: inline

Prism providing a Traversal for targeting the 'None' part of an Option<'T>

x : unit -> ^a
Returns: 'c option -> ^d

_Ok x

Full Usage: _Ok x

Parameters:
    x : 'a -> ^b

Returns: Result<'a, 'd> -> ^e
Modifiers: inline

Prism providing a Traversal for targeting the 'Ok' part of a Result<'T,'Error>

x : 'a -> ^b
Returns: Result<'a, 'd> -> ^e

_Some x

Full Usage: _Some x

Parameters:
    x : 'a -> ^b

Returns: 'a option -> ^d
Modifiers: inline

Prism providing a Traversal for targeting the 'Some' part of an Option<'T>

x : 'a -> ^b
Returns: 'a option -> ^d

_all ref f s

Full Usage: _all ref f s

Parameters:
    ref : 'a
    f : 'a -> ^b
    s : ^c

Returns: ^d
Modifiers: inline
ref : 'a
f : 'a -> ^b
s : ^c
Returns: ^d

allOf l f

Full Usage: allOf l f

Parameters:
Returns: 'c -> bool
l : ('a -> Const<All, 'b>) -> 'c -> Const<All, 'd>
f : 'a -> bool
Returns: 'c -> bool

anyOf l f

Full Usage: anyOf l f

Parameters:
Returns: 'c -> bool
l : ('a -> Const<Any, 'b>) -> 'c -> Const<Any, 'd>
f : 'a -> bool
Returns: 'c -> bool

both f (a, b)

Full Usage: both f (a, b)

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

Returns: ^f
Modifiers: inline
f : 'a -> ^b
a : 'a
b : 'a
Returns: ^f

choosed p f s

Full Usage: choosed p f s

Parameters:
    p : 'a -> 'b option
    f : 'b -> ^c
    s : 'a

Returns: ^c
Modifiers: inline
p : 'a -> 'b option
f : 'b -> ^c
s : 'a
Returns: ^c

choosing optic1 optic2 f _arg1

Full Usage: choosing optic1 optic2 f _arg1

Parameters:
    optic1 : ('a -> 'F<'b>) -> 's1 -> ^F<'t1>
    optic2 : ('a -> 'F<'b>) -> 's2 -> ^F<'t2>
    f : 'a -> 'F<'b>
    _arg1 : Result<'s2, 's1>

Returns: 'F>
Modifiers: inline
Type parameters: 's1, 't1, 's2, 't2, 'a, 'b, ^F<'t1>, ^F<'t2>, 'F<'b>, 'F<Result<'t2,'t1>>

Merge two lenses, getters, setters, folds or traversals. The first optic. The second optic. The free parameter. An optic for a Result which uses the first optic for the Ok and the second for the Error.

optic1 : ('a -> 'F<'b>) -> 's1 -> ^F<'t1>
optic2 : ('a -> 'F<'b>) -> 's2 -> ^F<'t2>
f : 'a -> 'F<'b>
_arg1 : Result<'s2, 's1>
Returns: 'F>

elemOf l

Full Usage: elemOf l

Parameters:
Returns: 'a -> 'c -> bool
l : ('a -> Const<Any, 'b>) -> 'c -> Const<Any, 'd>
Returns: 'a -> 'c -> bool

filtered p f s

Full Usage: filtered p f s

Parameters:
    p : 'a -> bool
    f : 'a -> ^b
    s : 'a

Returns: ^b
Modifiers: inline
p : 'a -> bool
f : 'a -> ^b
s : 'a
Returns: ^b

foldMapOf l f

Full Usage: foldMapOf l f

Parameters:
    l : ('a -> Const<'b, 'c>) -> 'd -> Const<'e, 'f>
    f : 'a -> 'b

Returns: 'd -> 'e
l : ('a -> Const<'b, 'c>) -> 'd -> Const<'e, 'f>
f : 'a -> 'b
Returns: 'd -> 'e

foldOf l

Full Usage: foldOf l

Parameters:
    l : ('a -> Const<'a, 'b>) -> 'c -> Const<'d, 'e>

Returns: 'c -> 'd
l : ('a -> Const<'a, 'b>) -> 'c -> Const<'d, 'e>
Returns: 'c -> 'd

foldlOf l f z

Full Usage: foldlOf l f z

Parameters:
Returns: 'd -> 'e
l : ('a -> Const<Dual<Endo<'b>>, 'c>) -> 'd -> Const<Dual<Endo<'e>>, 'f>
f : 'b -> 'a -> 'b
z : 'e
Returns: 'd -> 'e

foldrOf l f z

Full Usage: foldrOf l f z

Parameters:
Returns: 'd -> 'e
l : ('a -> Const<Endo<'b>, 'c>) -> 'd -> Const<Endo<'e>, 'f>
f : 'a -> 'b -> 'b
z : 'e
Returns: 'd -> 'e

from' l

Full Usage: from' l

Parameters:
Returns: ^g -> ^h
Modifiers: inline
l : Exchange<'a, 'b, 'a, Identity<'b>> -> Exchange<'c, 'd, 'e, Identity<'f>>
Returns: ^g -> ^h

iso func inv

Full Usage: iso func inv

Parameters:
    func : 's -> 'a - The transform function.
    inv : 'b -> 't - The inverse of the transform function.

Returns: ^i -> ^j The iso.
Modifiers: inline
Type parameters: 's, 'a, 'b, 't, ^i, ^j, ^k, 'l

Build an 'Iso' from a pair of inverse functions.

func : 's -> 'a

The transform function.

inv : 'b -> 't

The inverse of the transform function.

Returns: ^i -> ^j

The iso.

items x

Full Usage: items x

Parameters:
    x : 'a -> 'b

Returns: ^c -> ^d
Modifiers: inline
x : 'a -> 'b
Returns: ^c -> ^d

lens getter setter f s

Full Usage: lens getter setter f s

Parameters:
    getter : 's -> 'a - The getter function.
    setter : 's -> 'b -> 't - The setter function, having as first parameter the object and second the value to set.
    f : 'a -> ^F<'b> - The free parameter.
    s : 's -

Returns: 'F<'t> The lens.
Modifiers: inline
Type parameters: 's, 'a, 'b, 't, ^F<'b>, 'F<'t>

Build a 'Lens' from a getter and a setter.

The lens should be assigned as an inline function of the free parameter, not a value, otherwise compiler will fail with a type constraint mismatch.

getter : 's -> 'a

The getter function.

setter : 's -> 'b -> 't

The setter function, having as first parameter the object and second the value to set.

f : 'a -> ^F<'b>

The free parameter.

s : 's

Returns: 'F<'t>

The lens.

mapping k

Full Usage: mapping k

Parameters:
Returns: ^g -> ^h
Modifiers: inline
k : Exchange<'a, 'b, 'a, Identity<'b>> -> Exchange<'c, 'd, 'e, Identity<'f>>
Returns: ^g -> ^h

maximumOf l

Full Usage: maximumOf l

Parameters:
Returns: 'c -> 'd option

Get the largest target of a Fold.

l : ('a -> Const<Dual<Endo<'a option>>, 'b>) -> 'c -> Const<Dual<Endo<'d option>>, 'e>
Returns: 'c -> 'd option

minimumOf l

Full Usage: minimumOf l

Parameters:
Returns: 'c -> 'd option

Get the smallest target of a Fold.

l : ('a -> Const<Dual<Endo<'a option>>, 'b>) -> 'c -> Const<Dual<Endo<'d option>>, 'e>
Returns: 'c -> 'd option

non def f ma

Full Usage: non def f ma

Parameters:
    def : 'a
    f : 'a -> ^b
    ma : 'a option

Returns: 'c
Modifiers: inline

Lens for the value inside an Option or the given default value if the Option is None. Works well when combined with Map._item

def : 'a
f : 'a -> ^b
ma : 'a option
Returns: 'c

over optic updater source

Full Usage: over optic updater source

Parameters:
    optic : ('a -> Identity<'b>) -> 's -> Identity<'t> - The lens.
    updater : 'a -> 'b - A function that converts the value we want to write in the part targeted by the lens.
    source : 's - The original object.

Returns: 't The new object with the value modified.

Update a value in a lens.

optic : ('a -> Identity<'b>) -> 's -> Identity<'t>

The lens.

updater : 'a -> 'b

A function that converts the value we want to write in the part targeted by the lens.

source : 's

The original object.

Returns: 't

The new object with the value modified.

preview optic source

Full Usage: preview optic source

Parameters:
    optic : ('a -> Const<First<'a>, 'b>) -> 's -> Const<First<'a>, 't> - The prism.
    source : 's - The object.

Returns: 'a option The value (if any) the prism is targeting.

Retrieve the first value targeted by a Prism, Fold or Traversal (or Some result from a Getter or Lens). See also (^?).

optic : ('a -> Const<First<'a>, 'b>) -> 's -> Const<First<'a>, 't>

The prism.

source : 's

The object.

Returns: 'a option

The value (if any) the prism is targeting.

prism constructor getter f

Full Usage: prism constructor getter f

Parameters:
    constructor : 'b -> 't - The constructor function.
    getter : 's -> Result<'a, 't> - The getter function, having as first parameter the object and second the value to set.
    f : 'a -> ^F<'b> - The free parameter.

Returns: 's -> ^F<'t> The prism.
Modifiers: inline
Type parameters: 'b, 't, 's, 'a, ^F<'b>, ^F<'t>

Build a 'Prism' from a constructor and a getter.

The prism should be assigned as an inline function of the free parameter, not a value, otherwise compiler will fail with a type constraint mismatch.Using Result instead of Option to permit the types of 's and 't to differ.

constructor : 'b -> 't

The constructor function.

getter : 's -> Result<'a, 't>

The getter function, having as first parameter the object and second the value to set.

f : 'a -> ^F<'b>

The free parameter.

Returns: 's -> ^F<'t>

The prism.

prism' constructor getter f

Full Usage: prism' constructor getter f

Parameters:
    constructor : 'b -> 's - The constructor function.
    getter : 's -> Option<'a> - The getter function, having as first parameter the object and second the value to set.
    f : 'a -> ^F<'b> - The free parameter.

Returns: 's -> ^F<'t> The prism.
Modifiers: inline
Type parameters: 'b, 's, 'a, ^F<'b>, ^F<'t>

Build a 'Prism' from a constructor and a getter.

The prism should be assigned as an inline function of the free parameter, not a value, otherwise compiler will fail with a type constraint mismatch.Using Option which makes 's and 't the same type.

constructor : 'b -> 's

The constructor function.

getter : 's -> Option<'a>

The getter function, having as first parameter the object and second the value to set.

f : 'a -> ^F<'b>

The free parameter.

Returns: 's -> ^F<'t>

The prism.

setl optic value source

Full Usage: setl optic value source

Parameters:
    optic : ('a -> Identity<'b>) -> 's -> Identity<'t> - The lens.
    value : 'b - The value we want to write in the part targeted by the lens.
    source : 's - The original object.

Returns: 't The new object with the value modified.

Write to a lens.

optic : ('a -> Identity<'b>) -> 's -> Identity<'t>

The lens.

value : 'b

The value we want to write in the part targeted by the lens.

source : 's

The original object.

Returns: 't

The new object with the value modified.

to' k

Full Usage: to' k

Parameters:
    k : 'a -> 'b

Returns: ^c -> ^d
Modifiers: inline
k : 'a -> 'b
Returns: ^c -> ^d

toListOf l

Full Usage: toListOf l

Parameters:
Returns: 'c -> 'd list

Extract a list of the targets of a Fold. See also (^..).

l : ('a -> Const<Endo<'a list>, 'b>) -> 'c -> Const<Endo<'d list>, 'e>
Returns: 'c -> 'd list

view optic source

Full Usage: view optic source

Parameters:
    optic : ('a -> Const<'a, 'b>) -> 's -> Const<'a, 't> - The lens.
    source : 's - The object.

Returns: 'a The part the lens is targeting.

Read from a lens.

optic : ('a -> Const<'a, 'b>) -> 's -> Const<'a, 't>

The lens.

source : 's

The object.

Returns: 'a

The part the lens is targeting.

withIso ai k

Full Usage: withIso ai k

Parameters:
Returns: 'g
Modifiers: inline
ai : Exchange<'a, 'b, 'a, Identity<'b>> -> Exchange<'c, 'd, 'e, Identity<'f>>
k : ('e -> 'c) -> ('d -> 'f) -> 'g
Returns: 'g