Lens

public typealias Lens<S, A> = PLens<S, S, A, A>
  • Focuses on a specific index of this lens focus.

    Declaration

    Swift

    func at(_ i: A.AtIndex) -> Lens<S, A.AtFoci>

    Parameters

    i

    Index to focus.

    Return Value

    A composed lens from this structure to the focused index.

  • Provides a traversal over all elements of the focus of this lens.

    Declaration

    Swift

    var every: Traversal<S, A.EachFoci> { get }
  • Provides an optional focused on an index of the focus of this lens.

    Declaration

    Swift

    func index(_ i: A.IndexType) -> Optional<S, A.IndexFoci>

    Parameters

    i

    Index to focus.

    Return Value

    An optional focused on an index of the focus of this lens.

  • Provides an optional focused on an index of the focus of this lens.

    Declaration

    Swift

    subscript(i: A.IndexType) -> Optional<S, A.IndexFoci> { get }

    Parameters

    i

    Index to focus.

    Return Value

    An optional focused on an index of the focus of this lens.

  • Updates the focus viewed through the Lens and returns its new value.

    Declaration

    Swift

    func update(_ f: @escaping (A) -> A) -> State<S, A>

    Parameters

    f

    Updating function.

    Return Value

    A State with the new value.

  • Updates the focus viewed through the Lens and returns its old value.

    Declaration

    Swift

    func updateOld(_ f: @escaping (A) -> A) -> State<S, A>

    Parameters

    f

    Updating function.

    Return Value

    A State with the old value.

  • Updates the focus viewed through the Lens, ignoring the result.

    Declaration

    Swift

    func update_(_ f: @escaping (A) -> A) -> State<S, ()>

    Parameters

    f

    Updating function.

    Return Value

    A State ignoring the result.

  • Assigns the focus viewed through the Lens and returns its new value.

    Declaration

    Swift

    func assign(_ a: A) -> State<S, A>

    Parameters

    a

    Value to assign the focus.

    Return Value

    A State with the new value.

  • Assigns the focus viewed through the Lens and returns its old value.

    Declaration

    Swift

    func assignOld(_ a: A) -> State<S, A>

    Parameters

    a

    Value to assign the focus.

    Return Value

    A State with the old value.

  • Assigns the focus viewed through the Lens, ignoring the result.

    Declaration

    Swift

    func assign_(_ a: A) -> State<S, ()>

    Parameters

    a

    Value to assign the focus.

    Return Value

    A State ignoring the result.

  • Obtains an identity lens; i.e. a no-op lens.

    Declaration

    Swift

    static var identity: Lens<S, S> { get }
  • Obtains a lens that receives either values of S and strips the choice of S.

    Declaration

    Swift

    static var codiagonal: Lens<Either<S, S>, S> { get }