Getter
public class Getter<S, A>
A Getter is an optic that allows to see into a structure and getting a focus.
It can be seen as a function (S) -> A meaning that we can look into an S and get an A.
Parameters:
- S: source of the Getter.
- A: focus of the Getter.
-
Composes a
Getterwith anotherGetter.Declaration
Swift
public static func + <C>(lhs: Getter<S, A>, rhs: Getter<A, C>) -> Getter<S, C>Parameters
lhsLeft side of the composition.
rhsRight side of the composition.
Return Value
A
Getterresulting from the sequential application of the two provided optics. -
Composes a
Getterwith aLens.Declaration
Swift
public static func + <C>(lhs: Getter<S, A>, rhs: Lens<A, C>) -> Getter<S, C>Parameters
lhsLeft side of the composition.
rhsRight side of the composition.
Return Value
A
Getterresulting from the sequential application of the two provided optics. -
Composes a
Getterwith anIso.Declaration
Swift
public static func + <C>(lhs: Getter<S, A>, rhs: Iso<A, C>) -> Getter<S, C>Parameters
lhsLeft side of the composition.
rhsRight side of the composition.
Return Value
A
Getterresulting from the sequential application of the two provided optics. -
Initializes a Getter.
Declaration
Swift
public init(get: @escaping (S) -> A)Parameters
getFunction to focus into a structure.
-
Obtains the focus for a given source.
Declaration
Swift
public func get(_ s: S) -> AParameters
sSource.
Return Value
Focus.
-
Joins two Getters with the same focus.
Declaration
Swift
public func choice<C>(_ other: Getter<C, A>) -> Getter<Either<S, C>, A>Parameters
otherGetterto join with.Return Value
A
Getterthat operates on either of the sources and extracts their focus. -
Pairs two disjoint Getters.
Declaration
Swift
public func split<C, D>(_ other: Getter<C, D>) -> Getter<(S, C), (A, D)>Parameters
otherGetterto pair with.Return Value
A
Getterthat operates in both sources at the same time, extracting both foci. -
Zips two Getters with the same source.
Declaration
Swift
public func zip<C>(_ other: Getter<S, C>) -> Getter<S, (A, C)>Parameters
otherGetterto zip with.Return Value
A
Getterthat extracts both foci for a given source. -
Pairs this
Getterwith another type, placing this as the first element.Declaration
Swift
public func first<C>() -> Getter<(S, C), (A, C)>Return Value
A
Getterthat operates on tuples where the second argument remains unchanged. -
Pairs this
Getterwith another type, placing this as the second element.Declaration
Swift
public func second<C>() -> Getter<(C, S), (C, A)>Return Value
A
Getterthat operates on tuples where the first argument remains unchanged. -
Composes this
Getterwith aGetter.Declaration
Swift
public func compose<C>(_ other: Getter<A, C>) -> Getter<S, C>Parameters
otherValue to compose with.
Return Value
A
Getterresulting from the sequential application of both optics. -
Composes this
Getterwith aLens.Declaration
Swift
public func compose<C>(_ other: Lens<A, C>) -> Getter<S, C>Parameters
otherValue to compose with.
Return Value
A
Getterresulting from the sequential application of both optics. -
Composes this
Getterwith anIso.Declaration
Swift
public func compose<C>(_ other: Iso<A, C>) -> Getter<S, C>Parameters
otherValue to compose with.
Return Value
A
Getterresulting from the sequential application of both optics. -
Obtains the focus if it matches a predicate.
Declaration
Swift
public func find(_ s: S, _ predicate: (A) -> Bool) -> Option<A>Parameters
sSource.
predicateTesting predicate.
Return Value
An optional value that is present if the focus matches the predicate, or empty otherwise.
-
Checks if the focus matches a predicate.
Declaration
Swift
public func exists(_ s: S, _ predicate: (A) -> Bool) -> BoolParameters
sSource.
predicateTesting predicate.
Return Value
A boolean value indicating if the focus matches the predicate.
-
Focuses on a specific index of this getter.
Declaration
Swift
func at(_ i: A.AtIndex) -> Getter<S, A.AtFoci>Parameters
iIndex to focus.
Return Value
A getter from this structure to the focused index.
-
Provides an identity
Getter.Declaration
Swift
static var identity: Getter<S, S> { get } -
Provides a
Getterthat takes eitherSorSand strips the choice ofS.Declaration
Swift
static var codiagonal: Getter<Either<S, S>, S> { get }
Install in Dash
Getter Class Reference