PSetter

public class PSetter<S, T, A, B>

A Setter is an optic that allows to see into a structure and set or modify its focus.

A (polymorphic) PSetter is useful when setting or modifying a value for a constructed type.

A PSetter is a generalization of a Functor.

Parameters: - S: Source of the PSetter. - T: Modified source of the PSetter. - A: Focus of the PSetter. - B: Modified focus of the PSetter.

  • Composes a PSetter with a PSetter.

    Declaration

    Swift

    public static func + <C, D>(lhs: PSetter<S, T, A, B>, rhs: PSetter<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    lhs

    Left side of the composition.

    rhs

    Right side of the composition.

    Return Value

    A PSetter resulting from the sequential application of the two provided optics.

  • Composes a PSetter with a PAffineTraversal.

    Declaration

    Swift

    public static func + <C, D>(lhs: PSetter<S, T, A, B>, rhs: PAffineTraversal<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    lhs

    Left side of the composition.

    rhs

    Right side of the composition.

    Return Value

    A PSetter resulting from the sequential application of the two provided optics.

  • Composes a PSetter with a PPrism.

    Declaration

    Swift

    public static func + <C, D>(lhs: PSetter<S, T, A, B>, rhs: PPrism<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    lhs

    Left side of the composition.

    rhs

    Right side of the composition.

    Return Value

    A PSetter resulting from the sequential application of the two provided optics.

  • Composes a PSetter with a PLens.

    Declaration

    Swift

    public static func + <C, D>(lhs: PSetter<S, T, A, B>, rhs: PLens<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    lhs

    Left side of the composition.

    rhs

    Right side of the composition.

    Return Value

    A PSetter resulting from the sequential application of the two provided optics.

  • Composes a PSetter with a PIso.

    Declaration

    Swift

    public static func + <C, D>(lhs: PSetter<S, T, A, B>, rhs: PIso<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    lhs

    Left side of the composition.

    rhs

    Right side of the composition.

    Return Value

    A PSetter resulting from the sequential application of the two provided optics.

  • Composes a PSetter with a PTraversal.

    Declaration

    Swift

    public static func + <C, D>(lhs: PSetter<S, T, A, B>, rhs: PTraversal<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    lhs

    Left side of the composition.

    rhs

    Right side of the composition.

    Return Value

    A PSetter resulting from the sequential application of the two provided optics.

  • Creates a PSetter based on the instance of Functor of the sources.

    Declaration

    Swift

    public static func fromFunctor<F>() -> PSetter<Kind<F, A>, Kind<F, B>, A, B> where S : Kind<F, A>, T : Kind<F, B>, F : Functor

    Return Value

    A PSetter based on the instance of Functor of the sources.

  • Initializes a PSetter.

    Declaration

    Swift

    public init(modify: @escaping (S, @escaping (A) -> B) -> T, set: @escaping (S, B) -> T)

    Parameters

    modify

    Modification function.

    set

    Setting function.

  • Initializes a PSetter.

    Declaration

    Swift

    public init(modify: @escaping (@escaping (A) -> B) -> (S) -> T)

    Parameters

    modify

    Modification function.

  • Modifies the source with a function to modify its focus.

    Declaration

    Swift

    public func modify(_ s: S, _ f: @escaping (A) -> B) -> T

    Parameters

    s

    Source.

    f

    Function to modify focus.

    Return Value

    Modified source.

  • Sets a new focus.

    Declaration

    Swift

    public func set(_ s: S, _ b: B) -> T

    Parameters

    s

    Source.

    b

    Modified focus.

    Return Value

    Modified source.

  • Joins two PSetter with the same target.

    Declaration

    Swift

    public func choice<S1, T1>(_ other: PSetter<S1, T1, A, B>) -> PSetter<Either<S, S1>, Either<T, T1>, A, B>

    Parameters

    other

    Value to join with.

    Return Value

    A PSetter that operates on either of the sources of the original PSetters.

  • Lifts a function transforming the focs into a function transforming the source.

    Declaration

    Swift

    public func lift(_ f: @escaping (A) -> B) -> (S) -> T

    Parameters

    f

    Function transforming the focus.

    Return Value

    Function transforming the source.

  • Composes this PSetter with a PSetter.

    Declaration

    Swift

    public func compose<C, D>(_ other: PSetter<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    other

    Value to compose with.

    Return Value

    A PSetter resulting from the sequential application of the two optics.

  • Composes this PSetter with a PAffineTraversal.

    Declaration

    Swift

    public func compose<C, D>(_ other: PAffineTraversal<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    other

    Value to compose with.

    Return Value

    A PSetter resulting from the sequential application of the two optics.

  • Composes this PSetter with a PPrism.

    Declaration

    Swift

    public func compose<C, D>(_ other: PPrism<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    other

    Value to compose with.

    Return Value

    A PSetter resulting from the sequential application of the two optics.

  • Composes this PSetter with a PLens.

    Declaration

    Swift

    public func compose<C, D>(_ other: PLens<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    other

    Value to compose with.

    Return Value

    A PSetter resulting from the sequential application of the two optics.

  • Composes this PSetter with a PIso.

    Declaration

    Swift

    public func compose<C, D>(_ other: PIso<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    other

    Value to compose with.

    Return Value

    A PSetter resulting from the sequential application of the two optics.

  • Composes this PSetter with a PTraversal.

    Declaration

    Swift

    public func compose<C, D>(_ other: PTraversal<A, B, C, D>) -> PSetter<S, T, C, D>

    Parameters

    other

    Value to compose with.

    Return Value

    A PSetter resulting from the sequential application of the two optics.