Lens

public protocol Lens

Types that represent, in the type system, a specific key path value.

A given Lens-conforming type’s associated key path value is provided by its static var focus.

  • The specific subclass of KeyPath<Focus.Root,Value> whose value Self represents.

    For example, Focus might be WritableKeyPath<(Int, String), Int> in a Lens that supported writing.

    Declaration

    Swift

    associatedtype Focus : KeyPathProtocol
  • The Value type of the represented key path.

    Models of Lens should not define this type, but instead allow the default to take effect.

    Declaration

    Swift

    associatedtype Value = Self.Focus.Value
  • The key path value represented by Self.

    Declaration

    Swift

    static var focus: Focus { get }