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
PSetterwith aPSetter.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
lhsLeft side of the composition.
rhsRight side of the composition.
Return Value
A
PSetterresulting from the sequential application of the two provided optics. -
Composes a
PSetterwith aPAffineTraversal.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
lhsLeft side of the composition.
rhsRight side of the composition.
Return Value
A
PSetterresulting from the sequential application of the two provided optics. -
Composes a
PSetterwith aPPrism.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
lhsLeft side of the composition.
rhsRight side of the composition.
Return Value
A
PSetterresulting from the sequential application of the two provided optics. -
Composes a
PSetterwith aPLens.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
lhsLeft side of the composition.
rhsRight side of the composition.
Return Value
A
PSetterresulting from the sequential application of the two provided optics. -
Composes a
PSetterwith aPIso.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
lhsLeft side of the composition.
rhsRight side of the composition.
Return Value
A
PSetterresulting from the sequential application of the two provided optics. -
Composes a
PSetterwith aPTraversal.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
lhsLeft side of the composition.
rhsRight side of the composition.
Return Value
A
PSetterresulting from the sequential application of the two provided optics. -
Initializes a
PSetter.Declaration
Swift
public init(modify: @escaping (S, @escaping (A) -> B) -> T, set: @escaping (S, B) -> T)Parameters
modifyModification function.
setSetting function.
-
Initializes a
PSetter.Declaration
Swift
public init(modify: @escaping (@escaping (A) -> B) -> (S) -> T)Parameters
modifyModification function.
-
Modifies the source with a function to modify its focus.
Declaration
Swift
public func modify(_ s: S, _ f: @escaping (A) -> B) -> TParameters
sSource.
fFunction to modify focus.
Return Value
Modified source.
-
Sets a new focus.
Declaration
Swift
public func set(_ s: S, _ b: B) -> TParameters
sSource.
bModified focus.
Return Value
Modified source.
-
Lifts a function transforming the focs into a function transforming the source.
Declaration
Swift
public func lift(_ f: @escaping (A) -> B) -> (S) -> TParameters
fFunction transforming the focus.
Return Value
Function transforming the source.
-
Composes this
PSetterwith aPSetter.Declaration
Swift
public func compose<C, D>(_ other: PSetter<A, B, C, D>) -> PSetter<S, T, C, D>Parameters
otherValue to compose with.
Return Value
A
PSetterresulting from the sequential application of the two optics. -
Composes this
PSetterwith aPAffineTraversal.Declaration
Swift
public func compose<C, D>(_ other: PAffineTraversal<A, B, C, D>) -> PSetter<S, T, C, D>Parameters
otherValue to compose with.
Return Value
A
PSetterresulting from the sequential application of the two optics. -
Composes this
PSetterwith aPTraversal.Declaration
Swift
public func compose<C, D>(_ other: PTraversal<A, B, C, D>) -> PSetter<S, T, C, D>Parameters
otherValue to compose with.
Return Value
A
PSetterresulting from the sequential application of the two optics.
Install in Dash
PSetter Class Reference