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 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
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 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
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 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
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 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
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 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
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 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
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. -
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.
-
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 aPSetter
.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 aPAffineTraversal
.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 aPTraversal
.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.