Kind
open class Kind<F, A>
Simulates a Higher-Kinded Type in Swift with 1 type argument.
This class simulates Higher-Kinded Type support in Swift. Kind<F, A> is an alias for F<A>, which is not syntactically valid in Swift.
Classes that want to have HKT support must extend this class. Type parameter F is reserved for a witness to prevent circular references in the inheritance relationship. By convention, witnesses are named like the class they represent, with the prefix For. As an example:
class ForOption {}
class Option<A>: Kind<ForOption, A> {}
-
Default initializer
Declaration
Swift
public init()
-
Provides a traversal based on the instance of
Traversefor this type.Declaration
Swift
static var traversalK: Traversal<Kind<F, A>, A> { get }
-
Undocumented
Declaration
Swift
static func ana<B>(_ a: B, _ coalgebra: @escaping Coalgebra<A, B>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
func projectT() -> Kind<A, Kind<F, A>> -
Undocumented
Declaration
Swift
static func project() -> Coalgebra<A, Kind<F, A>>
-
Converts this computation into a Resource.
Declaration
Swift
var asResource: Resource<F, A> { get }
-
Suspends side effects in the provided registration function. The parameter function is injected with a side-effectful callback for signaling the result of an asynchronous process.
Declaration
Swift
static func asyncF(_ procf: @escaping ProcF<F, F.E, A>) -> Kind<F, A>Parameters
procfAsynchronous operation.
Return Value
A computation describing the asynchronous operation.
-
Switches the evaluation of a computation to a different
DispatchQueue.Declaration
Swift
func continueOn(_ queue: DispatchQueue) -> Kind<F, A>Parameters
queueA Dispatch Queue.
Return Value
A computation that will run on the provided queue.
-
Suspends side effects in the provided registration function. The parameter function is injected with a side-effectful callback for signaling the result of an asynchronous process.
Declaration
Swift
static func async(_ fa: @escaping Proc<F.E, A>) -> Kind<F, A>Parameters
procAsynchronous operation.
Return Value
A computation describing the asynchronous operation.
-
Provides a computation that evaluates the provided function on every run.
Declaration
Swift
static func `defer`( _ queue: DispatchQueue, _ f: @escaping () -> Kind<F, A>) -> Kind<F, A>Parameters
queueDispatch queue which the computation must be sent to.
fFunction returning a value.
Return Value
A computation that defers the execution of the provided function.
-
Provides a computation that evaluates the provided function on every run.
Declaration
Swift
static func later( _ queue: DispatchQueue, _ f: @escaping () throws -> A) -> Kind<F, A>Parameters
queueDispatch queue which the computation must be sent to.
fFunction returning a value.
Return Value
A computation that defers the execution of the provided function.
-
Provides a computation that evaluates the provided function on every run.
Declaration
Swift
static func delayOrRaise<A>( _ queue: DispatchQueue, _ f: @escaping () -> Either<F.E, A>) -> Kind<F, A>Parameters
queueDispatch queue which the computation must be sent to.
fA function that provides a value or an error.
Return Value
A computation that defers the execution of the provided value.
-
Provides an asynchronous computation that never finishes.
Declaration
Swift
static func never() -> Kind<F, A>Return Value
An asynchronous computation that never finishes.
-
A way to safely acquire a resource and release in the face of errors and cancellations. It uses
ExitCaseto distinguish between different exit cases when releasing the acquired resource.Declaration
Swift
func bracketCase<B>( release: @escaping (A, ExitCase<F.E>) -> Kind<F, Void>, use: @escaping (A) throws -> Kind<F, B>) -> Kind<F, B>Parameters
releaseFunction to release the acquired resource.
useFunction to use the acquired resource.
Return Value
Computation describing the result of using the resource.
-
A way to safely acquire a resource and release in the face of errors and cancellations. It uses
ExitCaseto distinguish between different exit cases when releasing the acquired resource.Declaration
Swift
func bracket<B>( release: @escaping (A) -> Kind<F, Void>, use: @escaping (A) throws -> Kind<F, B>) -> Kind<F, B>Parameters
releaseFunction to release the acquired resource, ignoring the outcome of the release of the resource.
useFunction to use the acquired resource.
Return Value
Computation describing the result of using the resource.
-
Forces this resource to be uncancelable even when an interruption happens.
Declaration
Swift
func uncancelable() -> Kind<F, A>Return Value
An uncancelable computation.
-
Executes the given finalizer when the source is finished, either in success, error or cancelation.
Declaration
Swift
func guarantee(_ finalizer: Kind<F, Void>) -> Kind<F, A>Parameters
finalizerFinalizer function to be invoked when the resource is released.
Return Value
A computation describing the resouce that will invoke the finalizer when it is released.
-
Executes the given finalizer when the source is finished, either in success, error or cancelation, alowing to differentiate between exit conditions.
Declaration
Swift
func guaranteeCase(_ finalizer: @escaping (ExitCase<F.E>) -> Kind<F, Void>) -> Kind<F, A>Parameters
finalizerFinalizer function to be invoked when the resource is released, distinguishing the exit case.
Return Value
A computation describing the resource that will invoke the finalizer when it is released.
-
Runs 2 computations in parallel and tuples their results.
Declaration
Swift
static func parZip<Z, B>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>) -> Kind<F, (Z, B)> where A == (Z, B)Parameters
fa1st computation.
fb2nd computation.
Return Value
A computation that describes the parallel execution.
-
Runs 3 computations in parallel and tuples their results.
Declaration
Swift
static func parZip<Z, B, C>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>) -> Kind<F, (Z, B, C)> where A == (Z, B, C)Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
Return Value
A computation that describes the parallel execution.
-
Runs 4 computations in parallel and tuples their results.
Declaration
Swift
static func parZip<Z, B, C, D>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>) -> Kind<F, (Z, B, C, D)> where A == (Z, B, C, D)Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
Return Value
A computation that describes the parallel execution.
-
Runs 5 computations in parallel and tuples their results.
Declaration
Swift
static func parZip<Z, B, C, D, E>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>) -> Kind<F, (Z, B, C, D, E)> where A == (Z, B, C, D, E)Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
fe5th computation.
Return Value
A computation that describes the parallel execution.
-
Runs 6 computations in parallel and tuples their results.
Declaration
Swift
static func parZip<Z, B, C, D, E, G>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ fg: Kind<F, G>) -> Kind<F, (Z, B, C, D, E, G)> where A == (Z, B, C, D, E, G)Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
fe5th computation.
fg6th computation.
Return Value
A computation that describes the parallel execution.
-
Runs 7 computations in parallel and tuples their results.
Declaration
Swift
static func parZip<Z, B, C, D, E, G, H>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ fg: Kind<F, G>, _ fh: Kind<F, H>) -> Kind<F, (Z, B, C, D, E, G, H)> where A == (Z, B, C, D, E, G, H)Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
fe5th computation.
fg6th computation.
fh7th computation.
Return Value
A computation that describes the parallel execution.
-
Runs 8 computations in parallel and tuples their results.
Declaration
Swift
static func parZip<Z, B, C, D, E, G, H, I>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ fg: Kind<F, G>, _ fh: Kind<F, H>, _ fi: Kind<F, I>) -> Kind<F, (Z, B, C, D, E, G, H, I)> where A == (Z, B, C, D, E, G, H, I)Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
fe5th computation.
fg6th computation.
fh7th computation.
fi8th computation.
Return Value
A computation that describes the parallel execution.
-
Runs 9 computations in parallel and tuples their results.
Declaration
Swift
static func parZip<Z, B, C, D, E, G, H, I, J>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ fg: Kind<F, G>, _ fh: Kind<F, H>, _ fi: Kind<F, I>, _ fj: Kind<F, J>) -> Kind<F, (Z, B, C, D, E, G, H, I, J)> where A == (Z, B, C, D, E, G, H, I, J)Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
fe5th computation.
fg6th computation.
fh7th computation.
fi8th computation.
fj9th computation.
Return Value
A computation that describes the parallel execution.
-
Runs 2 computations in parallel and returns the result of the first one finishing.
Declaration
Swift
static func race<B, C>( _ fb: Kind<F, B>, _ fc: Kind<F, C>) -> Kind<F, A> where A == Either<B, C>Parameters
fb1st computation
fc2nd computation
Return Value
A computation with the result of the first computation that finished.
-
Runs 2 computations in parallel and combines their results using the provided function.
Declaration
Swift
static func parMap<B, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ f: @escaping (Z, B) -> A) -> Kind<F, A>Parameters
fa1st computation.
fb2nd computation.
fCombination function.
Return Value
A computation that describes the parallel execution.
-
Runs 3 computations in parallel and combines their results using the provided function.
Declaration
Swift
static func parMap<B, C, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ f: @escaping (Z, B, C) -> A) -> Kind<F, A>Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fCombination function.
Return Value
A computation that describes the parallel execution.
-
Runs 4 computations in parallel and combines their results using the provided function.
Declaration
Swift
static func parMap<B, C, D, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ f: @escaping (Z, B, C, D) -> A) -> Kind<F, A>Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
fCombination function.
Return Value
A computation that describes the parallel execution.
-
Runs 5 computations in parallel and combines their results using the provided function.
Declaration
Swift
static func parMap<B, C, D, E, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ f: @escaping (Z, B, C, D, E) -> A) -> Kind<F, A>Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
fe5th computation.
fCombination function.
Return Value
A computation that describes the parallel execution.
-
Runs 6 computations in parallel and combines their results using the provided function.
Declaration
Swift
static func parMap<B, C, D, E, G, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ fg: Kind<F, G>, _ f: @escaping (Z, B, C, D, E, G) -> A) -> Kind<F, A>Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
fe5th computation.
fg6th computation.
fCombination function.
Return Value
A computation that describes the parallel execution.
-
Runs 7 computations in parallel and combines their results using the provided function.
Declaration
Swift
static func parMap<B, C, D, E, G, H, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ fg: Kind<F, G>, _ fh: Kind<F, H>, _ f: @escaping (Z, B, C, D, E, G, H) -> A) -> Kind<F, A>Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
fe5th computation.
fg6th computation.
fh7th computation.
fCombination function.
Return Value
A computation that describes the parallel execution.
-
Runs 8 computations in parallel and combines their results using the provided function.
Declaration
Swift
static func parMap<B, C, D, E, G, H, I, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ fg: Kind<F, G>, _ fh: Kind<F, H>, _ fi: Kind<F, I>, _ f: @escaping (Z, B, C, D, E, G, H, I) -> A) -> Kind<F, A>Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
fe5th computation.
fg6th computation.
fh7th computation.
fi8th computation.
fCombination function.
Return Value
A computation that describes the parallel execution.
-
Runs 9 computations in parallel and combines their results using the provided function.
Declaration
Swift
static func parMap<B, C, D, E, G, H, I, J, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ fg: Kind<F, G>, _ fh: Kind<F, H>, _ fi: Kind<F, I>, _ fj: Kind<F, J>, _ f: @escaping (Z, B, C, D, E, G, H, I, J) -> A) -> Kind<F, A>Parameters
fa1st computation.
fb2nd computation.
fc3rd computation.
fd4th computation.
fe5th computation.
fg6th computation.
fh7th computation.
fi8th computation.
fj9th computation.
fCombination function.
Return Value
A computation that describes the parallel execution.
-
Evaluates a side-effectful computation, allowing its cancellation.
Declaration
Swift
func runAsyncCancellable(_ callback: @escaping (Either<F.E, A>) -> Kind<F, Void>) -> Kind<F, Disposable>Parameters
callbackCallback to process the result of the evaluation.
Return Value
A computation describing the evaluation, providing a means to cancel it.
-
Maps each element of this structure to an effect, evaluates them in parallel and collects the results.
Declaration
Swift
func parTraverse<G: Concurrent, B>(_ f: @escaping (A) -> Kind<G, B>) -> Kind<G, Kind<F, B>>Parameters
fA function producing an effect.
Return Value
Results collected under the context of the effect provided by the function.
-
Evaluate each effect in this structure of values in parallel and collects the results.
Declaration
Swift
func parSequence<G: Concurrent, AA>() -> Kind<G, Kind<F, AA>> where A == Kind<G, AA>Return Value
Results collected under the context of the effects.
-
A parallel traverse followed by flattening the inner result.
Declaration
Swift
func parFlatTraverse<G: Concurrent, B>(_ f: @escaping (A) -> Kind<G, Kind<F, B>>) -> Kind<G, Kind<F, B>>Parameters
fA transforming function yielding nested effects.
Return Value
Results collected and flattened under the context of the effects.
-
Evaluates a side-effectful computation.
Declaration
Swift
func runAsync(_ callback: @escaping (Either<F.E, A>) -> Kind<F, ()>) -> Kind<F, Void>Parameters
callbackCallback to process the result of the computation.
Return Value
A computation describing the evaluation.
-
Provides a computation that evaluates the provided function on every run.
Declaration
Swift
static func `defer`(_ fa: @escaping () -> Kind<F, A>) -> Kind<F, A>Parameters
faFunction returning a computation to be deferred.
Return Value
A computation that defers the execution of the provided function.
-
Provides a computation that evaluates the provided function on every run.
Declaration
Swift
static func later(_ f: @escaping () throws -> A) -> Kind<F, A>Return Value
A computation that defers the execution of the provided function.
-
Provides a computation that evaluates this computation on every run.
Declaration
Swift
func later() -> Kind<F, A>Return Value
A computation that defers the execution of the provided value.
-
Provides a computation that evaluates the provided function on every run.
Declaration
Swift
static func laterOrRaise(_ f: @escaping () -> Either<F.E, A>) -> Kind<F, A>Parameters
fA function that provides a value or an error.
Return Value
A computation that defers the execution of the provided value.
-
Provides a lazy computation that returns void.
Declaration
Swift
static func lazy() -> Kind<F, Void>Return Value
A deferred computation of the void value.
-
Unsafely runs a computation in a synchronous manner.
Throws
Error happened during the execution of the computation, of the error type of the underlyingMonadError.Declaration
Swift
func runBlocking(on queue: DispatchQueue = .main) throws -> AParameters
queueDispatch queue used to run the computation. Defaults to the main queue.
Return Value
Result of running the computation.
-
Unsafely runs a computation in an asynchronous manner.
Declaration
Swift
func runNonBlocking( on queue: DispatchQueue = .main, _ callback: @escaping Callback<F.E, A> = { _ in })Parameters
queueDispatch queue used to run the computation. Defaults to the main queue.
callbackCallback to report the result of the evaluation.
-
Lifts a value to the context type implementing this instance of
Applicative.This is a convenience method to call
Applicative.pureas a static method of this type.Declaration
Swift
static func pure(_ a: A) -> Kind<F, A>Parameters
aValue to be lifted.
Return Value
Provided value in the context type implementing this instance.
-
Sequential application.
This is a convenience method to call
Applicative.apas an instance method of this type.Declaration
Swift
func ap<AA, B>(_ fa: Kind<F, AA>) -> Kind<F, B> where A == (AA) -> BParameters
faA value in the context implementing this instance.
Return Value
A value in the context implementing this instance, resulting of the transformation of the contained original value with the contained function.
-
Sequentially compose with another computation, discarding the value produced by this computation.
Declaration
Swift
func zipRight<B>(_ fb: Kind<F, B>) -> Kind<F, B>Parameters
fbAnother computation.
Return Value
Result of running the second computation after the first one.
-
Sequentially compose with another computation, discarding the value produced by the provided computation.
Declaration
Swift
func zipLeft<B>(_ fb: Kind<F, B>) -> Kind<F, A>Parameters
fb2nd computation.
Return Value
Result produced from this computation after both are computed.
-
Creates a tuple in the context implementing this instance from two values in the same context.
This is a convenience method to call
Applicative.productas a static method of this type.Declaration
Swift
static func product<AA, B>( _ fa: Kind<F, AA>, _ fb: Kind<F, B>) -> Kind<F, (AA, B)> where A == (AA, B)Parameters
fa1st value for the tuple.
fb2nd value for the tuple.
Return Value
A tuple of the provided values in the context implementing this instance.
-
Adds an element to the right of a tuple in the context implementing this instance.
This is a convenience method to call
Applicative.productas a static method of this type.Declaration
Swift
static func product<AA, B, Z>( _ fa: Kind<F, (AA, B)>, _ fz: Kind<F, Z>) -> Kind<F, (AA, B, Z)> where A == (AA, B, Z)Parameters
faA tuple of two elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
Adds an element to the right of a tuple in the context implementing this instance.
This is a convenience method to call
Applicative.productas a static method of this type.Declaration
Swift
static func product<AA, B, C, Z>( _ fa: Kind<F, (AA, B, C)>, _ fz: Kind<F, Z>) -> Kind<F, (AA, B, C, Z)> where A == (AA, B, C, Z)Parameters
faA tuple of three elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
Adds an element to the right of a tuple in the context implementing this instance.
This is a convenience method to call
Applicative.productas a static method of this type.Declaration
Swift
static func product<AA, B, C, D, Z>( _ fa: Kind<F, (AA, B, C, D)>, _ fz: Kind<F, Z>) -> Kind<F, (AA, B, C, D, Z)> where A == (AA, B, C, D, Z)Parameters
faA tuple of four elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
Adds an element to the right of a tuple in the context implementing this instance.
This is a convenience method to call
Applicative.productas a static method of this type.Declaration
Swift
static func product<AA, B, C, D, E, Z>( _ fa: Kind<F, (AA, B, C, D, E)>, _ fz: Kind<F, Z>) -> Kind<F, (AA, B, C, D, E, Z)> where A == (AA, B, C, D, E, Z)Parameters
faA tuple of five elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
Adds an element to the right of a tuple in the context implementing this instance.
This is a convenience method to call
Applicative.productas a static method of this type.Declaration
Swift
static func product<AA, B, C, D, E, G, Z>( _ fa: Kind<F, (AA, B, C, D, E, G)>, _ fz: Kind<F, Z>) -> Kind<F, (AA, B, C, D, E, G, Z)> where A == (AA, B, C, D, E, G, Z)Parameters
faA tuple of six elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
Adds an element to the right of a tuple in the context implementing this instance.
This is a convenience method to call
Applicative.productas a static method of this type.Declaration
Swift
static func product<AA, B, C, D, E, G, H, Z>( _ fa: Kind<F, (AA, B, C, D, E, G, H)>, _ fz: Kind<F, Z>) -> Kind<F, (AA, B, C, D, E, G, H, Z)> where A == (AA, B, C, D, E, G, H, Z)Parameters
faA tuple of seven elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
Adds an element to the right of a tuple in the context implementing this instance.
This is a convenience method to call
Applicative.productas a static method of this type.Declaration
Swift
static func product<AA, B, C, D, E, G, H, I, Z>( _ fa: Kind<F, (AA, B, C, D, E, G, H, I)>, _ fz: Kind<F, Z>) -> Kind<F, (AA, B, C, D, E, G, H, I, Z)> where A == (AA, B, C, D, E, G, H, I, Z)Parameters
faA tuple of eight elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
Creates a tuple out of two values in the context implementing this instance.
This is a convenience method to call
Applicative.zipas a static method of this type.Declaration
Swift
static func zip<AA, B>( _ a: Kind<F, AA>, _ b: Kind<F, B>) -> Kind<F, (AA, B)> where A == (AA, B)Parameters
a1st value of the tuple.
b2nd value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
Creates a tuple out of three values in the context implementing this instance.
This is a convenience method to call
Applicative.zipas a static method of this type.Declaration
Swift
static func zip<AA, B, C>( _ a: Kind<F, AA>, _ b: Kind<F, B>, _ c: Kind<F, C>) -> Kind<F, (AA, B, C)> where A == (AA, B, C)Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
Creates a tuple out of four values in the context implementing this instance.
This is a convenience method to call
Applicative.zipas a static method of this type.Declaration
Swift
static func zip<AA, B, C, D>( _ a: Kind<F, AA>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>) -> Kind<F, (AA, B, C, D)> where A == (AA, B, C, D)Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
Creates a tuple out of five values in the context implementing this instance.
This is a convenience method to call
Applicative.zipas a static method of this type.Declaration
Swift
static func zip<AA, B, C, D, E>( _ a: Kind<F, AA>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>) -> Kind<F, (AA, B, C, D, E)> where A == (AA, B, C, D, E)Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
e5th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
Creates a tuple out of six values in the context implementing this instance.
This is a convenience method to call
Applicative.zipas a static method of this type.Declaration
Swift
static func zip<AA, B, C, D, E, G>( _ a: Kind<F, AA>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>) -> Kind<F, (AA, B, C, D, E, G)> where A == (AA, B, C, D, E, G)Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
e5th value of the tuple.
g6th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
Creates a tuple out of seven values in the context implementing this instance.
This is a convenience method to call
Applicative.zipas a static method of this type.Declaration
Swift
static func zip<AA, B, C, D, E, G, H>( _ a: Kind<F, AA>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>) -> Kind<F, (AA, B, C, D, E, G, H)> where A == (AA, B, C, D, E, G, H)Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
e5th value of the tuple.
g6th value of the tuple.
h7th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
Creates a tuple out of eight values in the context implementing this instance.
This is a convenience method to call
Applicative.zipas a static method of this type.Declaration
Swift
static func zip<AA, B, C, D, E, G, H, I>( _ a: Kind<F, AA>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>, _ i: Kind<F, I>) -> Kind<F, (AA, B, C, D, E, G, H, I)> where A == (AA, B, C, D, E, G, H, I)Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
e5th value of the tuple.
g6th value of the tuple.
h7th value of the tuple.
i8th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
Creates a tuple out of nine values in the context implementing this instance.
This is a convenience method to call
Applicative.zipas a static method of this type.Declaration
Swift
static func zip<AA, B, C, D, E, G, H, I, J>( _ a: Kind<F, AA>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>, _ i: Kind<F, I>, _ j: Kind<F, J>) -> Kind<F, (AA, B, C, D, E, G, H, I, J)> where A == (AA, B, C, D, E, G, H, I, J)Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
e5th value of the tuple.
g6th value of the tuple.
h7th value of the tuple.
i8th value of the tuple.
j9th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
Combines the result of two computations in the context implementing this instance, using the provided function.
This is a convenience method to call
Applicative.mapas a static method of this type.Declaration
Swift
static func map<B, Z>( _ a: Kind<F, Z>, _ b: Kind<F, B>, _ f: @escaping (Z, B) -> A) -> Kind<F, A>Parameters
a1st computation.
b2nd computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
Combines the result of three computations in the context implementing this instance, using the provided function.
This is a convenience method to call
Applicative.mapas a static method of this type.Declaration
Swift
static func map<B, C, Z>( _ a: Kind<F, Z>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ f: @escaping (Z, B, C) -> A) -> Kind<F, A>Parameters
a1st computation.
b2nd computation.
c3rd computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
Combines the result of four computations in the context implementing this instance, using the provided function.
This is a convenience method to call
Applicative.mapas a static method of this type.Declaration
Swift
static func map<B, C, D, Z>( _ a: Kind<F, Z>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ f: @escaping (Z, B, C, D) -> A) -> Kind<F, A>Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
Combines the result of five computations in the context implementing this instance, using the provided function.
This is a convenience method to call
Applicative.mapas a static method of this type.Declaration
Swift
static func map<B, C, D, E, Z>( _ a: Kind<F, Z>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ f: @escaping (Z, B, C, D, E) -> A) -> Kind<F, A>Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
e5th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
Combines the result of six computations in the context implementing this instance, using the provided function.
This is a convenience method to call
Applicative.mapas a static method of this type.Declaration
Swift
static func map<B, C, D, E, G, Z>( _ a: Kind<F, Z>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ f: @escaping (Z, B, C, D, E, G) -> A) -> Kind<F, A>Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
e5th computation.
g6th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
Combines the result of seven computations in the context implementing this instance, using the provided function.
This is a convenience method to call
Applicative.mapas a static method of this type.Declaration
Swift
static func map<B, C, D, E, G, H, Z>( _ a: Kind<F, Z>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>, _ f: @escaping (Z, B, C, D, E, G, H) -> A) -> Kind<F, A>Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
e5th computation.
g6th computation.
h7th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
Combines the result of eight computations in the context implementing this instance, using the provided function.
This is a convenience method to call
Applicative.mapas a static method of this type.Declaration
Swift
static func map<B, C, D, E, G, H, I, Z>( _ a: Kind<F, Z>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>, _ i: Kind<F, I>, _ f: @escaping (Z, B, C, D, E, G, H, I) -> A) -> Kind<F, A>Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
e5th computation.
g6th computation.
h7th computation.
i8th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
Combines the result of nine computations in the context implementing this instance, using the provided function.
This is a convenience method to call
Applicative.mapas a static method of this type.Declaration
Swift
static func map<B, C, D, E, G, H, I, J, Z>( _ a: Kind<F, Z>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>, _ i: Kind<F, I>, _ j: Kind<F, J>, _ f: @escaping (Z, B, C, D, E, G, H, I, J) -> A) -> Kind<F, A>Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
e5th computation.
g6th computation.
h7th computation.
i8th computation.
j9th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
Lifts an error to the context implementing this instance.
This is a convenience method to call
ApplicativeError.raiseErroras a static method of this type.Declaration
Swift
static func raiseError(_ e: F.E) -> Kind<F, A>Parameters
eA value of the error type.
Return Value
A value representing the error in the context implementing this instance.
-
Handles an error, potentially recovering from it by mapping it to a value in the context implementing this instance.
This is a convenience method to call
ApplicativeError.handleErrorWithas an instance method of this type.Declaration
Swift
func handleErrorWith(_ f: @escaping (F.E) -> Kind<F, A>) -> Kind<F, A>Parameters
fA recovery function.
Return Value
A value where the possible errors have been recovered using the provided function.
-
Handles an error, potentially recovering from it by mapping it to a value.
This is a convenience method to call
ApplicativeError.handleErroras an instance method of this type.Declaration
Swift
func handleError(_ f: @escaping (F.E) -> A) -> Kind<F, A>Parameters
fA recovery function.
Return Value
A value where the possible errors have been recovered using the provided function.
-
Handles errors by converting them into
Eithervalues in the context implementing this instance.This is a convenience method to call
ApplicativeError.attemptas an instance method of this type.Declaration
Swift
func attempt() -> Kind<F, Either<F.E, A>>Return Value
An either wrapped in the context implementing this instance.
-
Converts an
Eithervalue into a value in the context implementing this instance.This is a convenience method to call
ApplicativeError.fromEitheras a static method of this type.Declaration
Swift
static func fromEither(_ fea: Either<F.E, A>) -> Kind<F, A>Parameters
feaAn
Eithervalue.Return Value
A value in the context implementing this instance.
-
Converts an
Optionvalue into a value in the context implementing this instance.Declaration
Swift
static func fromOption(_ oa: Option<A>, _ f: () -> F.E) -> Kind<F, A>Parameters
oaAn
Optionvalue.fA function providing the error value in case the option is empty.
Return Value
A value in the context implementing this instance.
-
Converts a
Tryvalue into a value in the context implementing this instance.Declaration
Swift
static func fromTry(_ ta: Try<A>, _ f: (Error) -> F.E) -> Kind<F, A>Parameters
taA
Tryvalue.fA function transforming the error contained in
Tryto the error type of this instance.Return Value
A value in the context implementing this instance.
-
Evaluates a throwing function, catching and mapping errors.
This is a convenience method to call
ApplicativeError.catchErroras a static method of this type.Declaration
Swift
static func catchError(_ f: () throws -> A, _ recover: (Error) -> F.E) -> Kind<F, A>Parameters
fA throwing function.
recoverA function that maps from
Errorto the type that this instance is able to handle.Return Value
A value in the context implementing this instance.
-
Evaluates a throwing function, catching errors.
This is a convenience method to call
ApplicativeError.catchErroras a static method of this type.Declaration
Swift
static func catchError(_ f: () throws -> A) -> Kind<F, A>Parameters
fA throwing function.
Return Value
A value in the context implementing this instance.
-
Applies this value to a function that takes a value in this context, and returns a normal value.
This function is the dual of
Monad.flatMap.This is a convenience function to call
Comonad.coflatMapas an instance method.Declaration
Swift
func coflatMap<B>(_ f: @escaping (Kind<F, A>) -> B) -> Kind<F, B>Parameters
fExtracting function.
Return Value
The result of extracting and transforming the value, in the context implementing this instance.
-
Extracts the value contained in this context.
This function is the dual of
Monad.pure(viaApplicative).This is a convenience function to call
Comonad.extractas an instance method.Declaration
Swift
func extract() -> AReturn Value
A normal value.
-
Wraps this in another layer of this context.
Declaration
Swift
func duplicate() -> Kind<F, Kind<F, A>>Return Value
This value wrapped in another context layer.
-
Gets the underlying global environment from this value.
Declaration
Swift
func ask() -> F.EReturn Value
Global environment.
-
Obtains a value that depends on the environment.
Declaration
Swift
func asks<EE>(_ f: @escaping (F.E) -> EE) -> EEParameters
fFunction to obtain a value from the environment.
Return Value
A value that depends on the environment.
-
Transforms the environment into a local one.
Declaration
Swift
func local(_ f: @escaping (F.E) -> F.E) -> Kind<F, A>Parameters
fTransforming function.
Return Value
A value with the transformed environment.
-
Obtains the current position of the store.
Declaration
Swift
var position: F.S { get } -
Obtains the value stored in the provided position.
Declaration
Swift
func peek(_ s: F.S) -> AParameters
sPosition within the Store.
Return Value
Value stored in the provided position.
-
Obtains a value in a position relative to the current position.
Declaration
Swift
func peeks(_ f: @escaping (F.S) -> F.S) -> AParameters
fFunction to compute the relative position.
Return Value
Value located in a relative position to the current one.
-
Moves to a new position.
Declaration
Swift
func seek(_ s: F.S) -> Kind<F, A>Parameters
sNew position.
Return Value
Store focused into the new position.
-
Moves to a new position relative to the current one.
Declaration
Swift
func seeks(_ f: @escaping (F.S) -> F.S) -> Kind<F, A>Parameters
fFunction to compute the new position, relative to the current one.
Return Value
Store focused into the new position.
-
Extracts a collection of values from positions that depend on the current one.
Declaration
Swift
func experiment<G: Functor>(_ f: @escaping (F.S) -> Kind<G, F.S>) -> Kind<G, A>Parameters
fEffectful function computing new positions based on the current one.
Return Value
A collection of values located a the specified positions.
-
Extracts a value at the specified relative position.
Declaration
Swift
func trace(_ m: F.M) -> AParameters
mRelative position.
Return Value
Value corresponding to the specified position.
-
Extracts a value at a relative position which depends on the current value.
Declaration
Swift
func traces(_ f: @escaping (A) -> F.M) -> AParameters
fFunction to compute the position based on the current value.
Return Value
Value corresponding to the new position.
-
Gets a value that depends on the current position.
Declaration
Swift
func listens<B>(_ f: @escaping (F.M) -> B) -> Kind<F, (B, A)>Parameters
fFunction to compute a value from the current position.
Return Value
A tuple with the current and computed value in the context of this ComonadTraced.
-
Obtains the current position together with the current value.
Declaration
Swift
func listen() -> Kind<F, (F.M, A)>Return Value
A tuple with the current position and value in the context of this ComonadTraced.
-
Apply a function to the current position.
Declaration
Swift
func censor(_ f: @escaping (F.M) -> F.M) -> Kind<F, A>Parameters
fFunction to transform the current position.
Return Value
Trace focused in the new position.
-
Obtains a Trace that can modify the current position.
Declaration
Swift
func pass() -> Kind<F, ((F.M) -> F.M) -> A>Return Value
Trace that can modify the current position.
-
Obtains the comonadic value contained in the provided comonad transformer.
Declaration
Swift
func lower() -> Kind<F.W, A>Return Value
Contained comonadic value within the transformer.
-
Creates a new value transforming the type using the provided function, preserving the structure of the original type.
Declaration
Swift
func contramap<B>(_ f: @escaping (B) -> A) -> Kind<F, B>Parameters
fTransforming function.
Return Value
The result of transforming the value type using the provided function, maintaining the structure of the original value.
-
Given a function, provides a new function lifted to the context type implementing this instance of
Contravariant, but reversing the direction of the arrow.Declaration
Swift
static func contralift<B>(_ f: @escaping (A) -> B) -> (Kind<F, B>) -> Kind<F, A>Parameters
fFunction to be lifted.
Return Value
Function in the context implementing this instance.
-
Takes 2 computations and produces a new one that decides which one will be run, based on a provided function.
Declaration
Swift
static func choose<B, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ f: (A) -> Either<Z, B>) -> Kind<F, A>Parameters
fa1st computation
fb2nd computation
fDeciding function
Return Value
A computation that decides which of the provided arguments should run.
-
Takes 3 computations and produces a new one that decides which one will be run, based on a provided function.
Declaration
Parameters
fa1st computation
fb2nd computation
fc3rd computation
fDeciding function
Return Value
A computation that decides which of the provided arguments should run.
-
Takes 4 computations and produces a new one that decides which one will be run, based on a provided function.
Declaration
Parameters
fa1st computation
fb2nd computation
fc3rd computation
fd4th computation
fDeciding function
Return Value
A computation that decides which of the provided arguments should run.
-
Takes 5 computations and produces a new one that decides which one will be run, based on a provided function.
Declaration
Parameters
fa1st computation
fb2nd computation
fc3rd computation
fd4th computation
fe5th computation
fDeciding function
Return Value
A computation that decides which of the provided arguments should run.
-
Takes 6 computations and produces a new one that decides which one will be run, based on a provided function.
Declaration
Parameters
fa1st computation
fb2nd computation
fc3rd computation
fd4th computation
fe5th computation
ff6th computation
fDeciding function
Return Value
A computation that decides which of the provided arguments should run.
-
Takes 7 computations and produces a new one that decides which one will be run, based on a provided function.
Declaration
Parameters
fa1st computation
fb2nd computation
fc3rd computation
fd4th computation
fe5th computation
ff6th computation
fg7th computation
fDeciding function
Return Value
A computation that decides which of the provided arguments should run.
-
Takes 8 computations and produces a new one that decides which one will be run, based on a provided function.
Declaration
Swift
static func choose<B, C, D, E, FF, G, H, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ ff: Kind<F, FF>, _ fg: Kind<F, G>, _ fh: Kind<F, H>, _ f: (A) -> Either<Z, Either<B, Either<C, Either<D, Either<E, Either<FF, Either<G, H>>>>>>> ) -> Kind<F, A>Parameters
fa1st computation
fb2nd computation
fc3rd computation
fd4th computation
fe5th computation
ff6th computation
fg7th computation
fh8th computation
fDeciding function
Return Value
A computation that decides which of the provided arguments should run.
-
Takes 9 computations and produces a new one that decides which one will be run, based on a provided function.
Declaration
Swift
static func choose<B, C, D, E, FF, G, H, I, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ ff: Kind<F, FF>, _ fg: Kind<F, G>, _ fh: Kind<F, H>, _ fi: Kind<F, I>, _ f: (A) -> Either<Z, Either<B, Either<C, Either<D, Either<E, Either<FF, Either<G, Either<H, I>>>>>>>> ) -> Kind<F, A>Parameters
fa1st computation
fb2nd computation
fc3rd computation
fd4th computation
fe5th computation
ff6th computation
fg7th computation
fh8th computation
fi9th computation
fDeciding function
Return Value
A computation that decides which of the provided arguments should run.
-
Takes 10 computations and produces a new one that decides which one will be run, based on a provided function.
Declaration
Swift
static func choose<B, C, D, E, FF, G, H, I, J, Z>( _ fa: Kind<F, Z>, _ fb: Kind<F, B>, _ fc: Kind<F, C>, _ fd: Kind<F, D>, _ fe: Kind<F, E>, _ ff: Kind<F, FF>, _ fg: Kind<F, G>, _ fh: Kind<F, H>, _ fi: Kind<F, I>, _ fj: Kind<F, J>, _ f: (A) -> Either<Z, Either<B, Either<C, Either<D, Either<E, Either<FF, Either<G, Either<H, Either<I, J>>>>>>>>> ) -> Kind<F, A>Parameters
fa1st computation
fb2nd computation
fc3rd computation
fd4th computation
fe5th computation
ff6th computation
fg7th computation
fh8th computation
fi9th computation
fj10th computation
fDeciding function
Return Value
A computation that decides which of the provided arguments should run.
-
Takes a computation and provides a computation using a function that specifies how to divide the returned type into the two provided types.
Declaration
Swift
func divide<B, C>(_ fb: Kind<F, B>, _ f: (C) -> (A, B)) -> Kind<F, C>Parameters
fb2nd computation.
fDividing function.
Return Value
A computation that merges the divided parts.
-
Provides an empty value for this Divisible instance
Declaration
Swift
static func conquer() -> Kind<F, A>
-
Checks if two kinds are equal, given that the enclosed value type conforms to
Equatable.This is a convenience method to call
EquatableK.eqas an instance method of this type.Declaration
Swift
func eq(_ rhs: Kind<F, A>) -> BoolParameters
lhsLeft hand side of the equality check.
rhsRight hand side of the equality check.
Return Value
A boolean value indicating if the two values are equal or not.
-
Declaration
Swift
public static func == (lhs: Kind<F, A>, rhs: Kind<F, A>) -> Bool
-
Eagerly folds this value to a summary value from left to right.
Declaration
Swift
func foldLeft<B>( _ b: B, _ f: @escaping (B, A) -> B) -> BParameters
bInitial value for the folding process.
fFolding function.
Return Value
Summary value resulting from the folding process.
-
Reduces the elements of this structure down to a single value by applying the provided transformation and aggregation funtions in a left-associative manner.
Declaration
Swift
func reduceLeftToOption<B>( _ f: @escaping (A) -> B, _ g: @escaping (B, A) -> B) -> Option<B>Parameters
fTransforming function.
gFolding function.
Return Value
Optional summary value resulting from the folding process. It will be an
Option.noneif the structure is empty, or a value if not. -
Reduces the elements of this structure down to a single value by applying the provided transformation and aggregation functions in a right-associative manner.
Declaration
Parameters
fTransforming function.
gFolding function.
Return Value
Optional summary value resulting from the folding process. It will be an
Option.noneif the structure is empty, or a value if not. -
Reduces the elements of this structure down to a single value by applying the provided aggregation function in a left-associative manner.
Declaration
Swift
func reduceLeftOption( _ f: @escaping (A, A) -> A) -> Option<A>Parameters
fFolding function.
Return Value
Optional summary value resulting from the folding process.
-
Reduces the elements of this structure down to a single value by applying the provided aggregation function in a right-associative manner.
Parameters
fFolding function.
Return Value
Optional summary value resulting from the folding process.
-
Transforms the elements of this structure to a type with a
Monoidinstance and folds them using the empty and combine methods of suchMonoidinstance.Declaration
Swift
func foldMap<B: Monoid>(_ f: @escaping (A) -> B) -> BParameters
faValue to be transformed and folded.
fTransforming function.
Return Value
Summary value resulting from the transformation and folding process.
-
Traverses this structure of values, transforming them with a provided function and discarding the result of its effect.
Declaration
Swift
func traverse_<G: Applicative, B>(_ f: @escaping (A) -> Kind<G, B>) -> Kind<G, Unit>Parameters
fTransforming function.
Return Value
Unit in the context of the effect of the result of the transforming function.
-
Traverses this structure of effects, performing them and discarding their result.
Declaration
Swift
func sequence_<G, AA>() -> Kind<G, Unit> where A : Kind<G, AA>, G : ApplicativeReturn Value
Unit in the context of the effects contained in the structure.
-
Looks for an element that matches a given predicate.
Declaration
Swift
func find(_ f: @escaping (A) -> Bool) -> Option<A>Parameters
fPredicate.
Return Value
A value if there is any that matches the predicate, or
Option.none. -
Checks if any element in this structure matches a given predicate.
Declaration
Swift
func exists(_ predicate: @escaping (A) -> Bool) -> BoolParameters
predicatePredicate.
Return Value
A boolean value indicating if any elements in the structure match the predicate.
-
Checks if all elements in this structure match a given predicate.
Declaration
Swift
func forall(_ predicate: @escaping (A) -> Bool) -> BoolParameters
predicatePredicate.
Return Value
A boolean value indicating if all elements in the structure match the predicate.
-
Checks if this structure of values is empty.
Declaration
Swift
var isEmpty: Bool { get }Return Value
falseif the structure contains any value,trueotherwise. -
Checks if this structure of values is not empty.
Declaration
Swift
var nonEmpty: Bool { get }Return Value
trueif the structure contains any value,falseotherwise. -
Performs a monadic left fold from the source context to the target monad.
Declaration
Swift
func foldM<G: Monad, B>( _ b: B, _ f: @escaping (B, A) -> Kind<G, B>) -> Kind<G, B>Parameters
bInitial value for the fold.
fFolding function.
Return Value
Summary value resulting from the folding process in the context of the target monad.
-
Performs a monadic left fold by mapping the values in this structure to ones in the target monad context and using the
Monoidinstance to combine them.Declaration
Parameters
fTrasnforming function.
Return Value
Summary value resulting from the transformation and folding process in the context of the target monad.
-
Obtains a specific element of a structure of elements given its indexed position.
Declaration
Swift
func get(_ index: Int64) -> Option<A>Parameters
indexIndexed position of the element to retrieve.
Return Value
A value if there is any at the given position, or
Option.noneotherwise. -
Counts how many elements this structure contains.
Declaration
Swift
var count: Int64 { get }Return Value
An integer value with the count of how many elements are contained in the structure.
-
Undocumented
Declaration
Swift
func reduceK<G: MonoidK, B>() -> Kind<G, B> where A: Kind<G, B>
-
Folds this structure of values provided that its type has an instance of
Monoid.It uses the monoid empty value as initial value and the combination method for the fold.
Declaration
Swift
func fold() -> AReturn Value
Summary value resulting from the folding process.
-
Folds this structure of values provided that its type has an instance of
Monoid.It uses the monoid empty value as initial value and the combination method for the fold.
Declaration
Swift
func combineAll() -> AReturn Value
Summary value resulting from the folding process.
-
Creates a new value transforming the type using the provided function, preserving the structure of the original type.
This is a convenience method to call
Functor.mapas an instance method in this type.Declaration
Swift
func map<B>(_ f: @escaping (A) -> B) -> Kind<F, B>Parameters
fA transforming function.
Return Value
The result of transforming the value type using the provided function, maintaining the structure of the original value.
-
Given a function, provides a new function lifted to the context type implementing this instance of
Functor.This is a convenience method to call
Functor.liftas a static method in this type.Declaration
Swift
static func lift<A, B>(_ f: @escaping (A) -> B) -> (Kind<F, A>) -> Kind<F, B>Parameters
fFunction to be lifted.
Return Value
Function in the context implementing this instance of
Functor. -
Replaces the value type by the
Voidtype.This is a convenience method to call
Functor.voidas an instance method of this type.Declaration
Swift
func void() -> Kind<F, ()>Return Value
New value in the context implementing this instance of
Functor, withVoidas value type. -
Transforms the value type and pairs it with its original value.
This is a conveninence method to call
Functor.fproductas an instance method of is type.Declaration
Swift
func fproduct<B>(_ f: @escaping (A) -> B) -> Kind<F, (A, B)>Parameters
fTransforming function.
Return Value
A pair with the original value and its transformation, in the context of the original value.
-
Transforms the value type with a constant value.
This is a convenience method to call
Functor.asas an instance method of this type.Declaration
Swift
func `as`<B>(_ b: B) -> Kind<F, B>Parameters
bConstant value to replace the value type.
Return Value
A new value with the structure of the original value, with its value type transformed.
-
Transforms the value type by making a tuple with a new constant value to the left of the original value type.
This is a conveninence method to call
Functor.tupleLeftas an instance method of this type.Declaration
Swift
func tupleLeft<B>(_ b: B) -> Kind<F, (B, A)>Parameters
bConstant value for the tuple.
Return Value
A new value with the structure of the original value, with a tuple in its value type.
-
Transforms the value type by making a tuple with a new constant value to the right of the original value type.
This is a convenience method to call
Functor.tupleRightas an instance method of this type.Declaration
Swift
func tupleRight<B>(_ b: B) -> Kind<F, (A, B)>Parameters
bConstant value for the tuple.
Return Value
A new value with the structure of the original value, with a tuple in its value type.
-
Maps the value/s in the context implementing this instance, filtering out the ones resulting in
Option.none.This is a convenience method to call
FunctorFilter.mapFilteras an instance method of this type.Declaration
Swift
func mapFilter<B>(_ f: @escaping (A) -> OptionOf<B>) -> Kind<F, B>Parameters
fA function to map objects and filter them out.
Return Value
Transformed and filtered values, in this context.
-
Removes the
Option.nonevalue/s in this context and extracts theOption.someones.This is a convenience method to call
FunctorFilter.flattenOptionas a static method of this type.Declaration
Swift
static func flattenOption(_ fa: Kind<F, OptionOf<A>>) -> Kind<F, A>Parameters
faOptional values in this context.
Return Value
Plain values in this context.
-
Filters out the value/s in this context that do not match the given predicate.
This is a convenience method to call
FunctorFilter.filteras a static method of this type.Declaration
Swift
func filter(_ f: @escaping (A) -> Bool) -> Kind<F, A>Parameters
fFiltering predicate.
Return Value
Filtered value in this context.
-
Declaration
Swift
public func hash(into hasher: inout Hasher)
-
Transforms the value type using the functions provided.
This is a conveninece method to call
Invariant.imapas an instance method.Declaration
Swift
func imap<B>(_ f: @escaping (A) -> B, _ g: @escaping (B) -> A) -> Kind<F, B>Parameters
fTransforming function.
gTransforming function.
Return Value
A new value in the same context as the original value, with the value type transformed.
-
Sequentially compose this computation with another one, passing any value produced by the first as an argument to the second.
This is a convenience method to call
Monad.flatMapas an instance method of this type.Declaration
Swift
func flatMap<B>(_ f: @escaping (A) -> Kind<F, B>) -> Kind<F, B>Parameters
fA function describing the second computation, which depends on the value of the first.
Return Value
Result of composing the two computations.
-
Monadic tail recursion.
This is a convenience method to call
Monad.tailRecMas a static method of this type.Declaration
Swift
static func tailRecM<B>( _ a: A, _ f: @escaping (A) -> Kind<F, Either<A, B>>) -> Kind<F, B>Parameters
aInitial value for the recursion.
fA function describing a recursive step.
Return Value
Result of evaluating recursively the provided function with the initial value.
-
A stack safe version of
flatMap, based ontailRecM.Declaration
Swift
func stackSafeFlatMap<B>(_ f: @escaping (A) -> Kind<F, B>) -> Kind<F, B>Parameters
fA function describing the second computation, which depends on the value of the first.
Return Value
Result of composing the two computations.
-
Flattens a nested structure of the context implementing this instance into a single layer.
This is a convenience method to call
Monad.flattenas a static method of this type.Declaration
Swift
func flatten<AA>() -> Kind<F, AA> where A == Kind<F, AA>Parameters
ffaValue with a nested structure.
Return Value
Value with a single context structure.
-
Sequentially compose with another computation, discarding the value produced by the this one.
This is a convenience method to call
Monad.followedByas an instance method of this type.Declaration
Swift
func followedBy<B>(_ fb: Kind<F, B>) -> Kind<F, B>Parameters
fbA computation.
Return Value
Result of running the second computation after the first one.
-
Sequentially compose this computation with a potentially lazy one, discarding the value produced by this one.
This is a convenience method to call
Monad.followedByEvalas an instance method of this type.Declaration
Swift
func followedByEval<B>(_ fb: Eval<Kind<F, B>>) -> Kind<F, B>Parameters
fbLazy computation.
Return Value
Result of running the second computation after the first one.
-
Sequentially compose with another computation, discarding the value produced by the received one.
This is a convenience method to call
Monad.forEffectas an instance method of this type.Declaration
Swift
func forEffect<B>(_ fb: Kind<F, B>) -> Kind<F, A>Parameters
fbA computation.
Return Value
Result produced from the first computation after both are computed.
-
Sequentially compose with a potentially lazy computation, discarding the value produced by the received one.
This is a convenience method to call
Monad.forEffectEvalas an instance method of this type.Declaration
Swift
func forEffectEval<B>(_ fb: Eval<Kind<F, B>>) -> Kind<F, A>Parameters
fbLazy computation.
Return Value
Result produced from the first computation after both are computed.
-
Pair the result of this computation with the result of applying a function to such result.
This is a convenience method to call
Monad.mproductas an instance method.Declaration
Swift
func mproduct<B>(_ f: @escaping (A) -> Kind<F, B>) -> Kind<F, (A, B)>Parameters
fA function to be applied to the result of the computation.
Return Value
A tuple of the result of this computation paired with the result of the function, in the context implementing this instance.
-
Applies a monadic function and discard the result while keeping the effect.
Declaration
Swift
func flatTap<B>(_ f: @escaping (A) -> Kind<F, B>) -> Kind<F, A>Parameters
fA monadic function which result will be discarded.
Return Value
A computation with the result of the initial computation and the effect caused by the function application.
-
Conditionally apply a closure based on the boolean result of this computation.
This is a convenience method to call
Monad.ifMas an instance method.Declaration
Swift
func ifM<B>( _ ifTrue: @escaping () -> Kind<F, B>, _ ifFalse: @escaping () -> Kind<F, B>) -> Kind<F, B>Parameters
ifTrueClosure to be applied if the computation evaluates to
true.ifFalseClosure to be applied if the computation evaluates to
false.Return Value
Result of applying the corresponding closure based on the result of the computation.
-
Fold over the inner structure to combine all of the values with our combine method inherited from `MonoidK.
This is a convenience method to call
MonadCombine.uniteas a static method of this type.Declaration
Swift
static func unite<G>(_ fga: Kind<F, Kind<G, A>>) -> Kind<F, A> where G : FoldableParameters
fgaNested contexts value.
Return Value
A value in the context implementing this instance where the inner context has been folded.
-
Creates a bound variable in the monadic context of this kind for the specified type.
Declaration
Swift
static func `var`() -> BoundVar<F, A>Return Value
A bound variable.
-
Checks if the value of this computation matches a predicate, raising an error if not.
This is a convenience method to call
MonadError.ensureas an instance method of this type.Declaration
Swift
func ensure( _ error: @escaping () -> F.E, _ predicate: @escaping (A) -> Bool) -> Kind<F, A>Parameters
errorA function that produces an error of the type this instance is able to handle.
predicateA boolean predicate to test the value of the computation.
Return Value
A value or an error in the context implementing this instance.
-
Applies a monadic function to an effect discarding the output.
Declaration
Swift
func flatTapError<B>(_ f: @escaping (F.E) -> Kind<F, B>) -> Kind<F, A>Parameters
fA monadic function which result will be discarded.
Return Value
A computation with the effect of the initial computation.
-
Obtains an empty element in this context.
Declaration
Swift
static var empty: Kind<F, A> { get }Return Value
Empty element.
-
Retrieves the shared environment.
This is a convenience method to call
MonadReader.askas a static method of this type.Declaration
Swift
static func ask() -> Kind<F, F.D>Return Value
Shared environment.
-
Executes this computation in a modified environment.
This is a convenience method to call
MonadReader.localas an instance method of this type.Declaration
Swift
func local(_ f: @escaping (F.D) -> F.D) -> Kind<F, A>Parameters
fFuntion to modify the environment.
Return Value
Computation in the modified environment.
-
Retrieves a function of the current environment.
This is a convenience method to call
MonadReader.readeras a static method of this type.Declaration
Swift
static func reader(_ f: @escaping (F.D) -> A) -> Kind<F, A>Parameters
fSelector function to apply to the environment.
Return Value
A value extracted from the environment, in the context implementing this instance.
-
Replaces the state inside the monad.
This is a convenience method to call
MonadState.setas a static method of this type.Declaration
Swift
static func set(_ s: F.S) -> Kind<F, ()>Parameters
sNew state.
Return Value
Unit.
-
Modifies the internal state.
This is a convenience method to call
MonadState.modifyas a static method of this type.Declaration
Swift
static func modify(_ f: @escaping (F.S) -> F.S) -> Kind<F, ()>Parameters
fFunction that modifies the state.
Return Value
Unit.
-
Retrieves the state from the internals of the monad.
This is a convenience method to call
MonadState.getas a static method of this type.Declaration
Swift
static func get() -> Kind<F, F.S>Return Value
Maintained state.
-
Embeds a state action into the monad.
This is a convenience method to call
MonadState.stateas a static method of this type.Declaration
Swift
static func state(_ f: @escaping (F.S) -> (F.S, A)) -> Kind<F, A>Parameters
fA function that receives the state and computes a value and a new state.
Return Value
A value with the output of the function and the new state.
-
Retrieves a specific component of the state.
This is a convenience method to call
MonadState.inspectas a static method of this type.Declaration
Swift
static func inspect(_ f: @escaping (F.S) -> A) -> Kind<F, A>Parameters
fProjection function to obtain part of the state.
Return Value
A specific part of the state.
-
Lift a computation from the F monad to this monad.
Declaration
Swift
static func liftF(_ fa: Kind<F.F, A>) -> Kind<F, A>
-
Produces a new value of the side stream of data.
This is a convenience method to call
MonadWriter.tellas a static method of this type.Declaration
Swift
static func tell(_ w: F.W) -> Kind<F, ()>Parameters
wNew value.
Return Value
Unit.
-
Embeds a writer action.
This is a convenience method to call
MonadWriter.writeras a static method of this type.Declaration
Swift
static func writer(_ aw: (F.W, A)) -> Kind<F, A>Parameters
awA tupe of the writer type and a value.
Return Value
The writer action embedded in the context implementing this instance.
-
Adds the side stream of data to the result of this computation.
This is a convenience method to call
MonadWriter.listenas an instance method of this type.Declaration
Swift
func listen() -> Kind<F, (F.W, A)>Return Value
The result of the computation paired with the side stream of data.
-
Performs a computation and transforms the side stream of data.
This is a convenience method to call
MonadWriter.passas a static method of this type.Declaration
Swift
static func pass(_ fa: Kind<F, ((F.W) -> F.W, A)>) -> Kind<F, A>Parameters
faA computation that transform the stream of data.
Return Value
Result of the computation.
-
Performs this computation and transforms the side stream of data, pairing it with the result of this computation.
This is a convenience method to call
MonadWriter.listensas an instance method of this type.Declaration
Swift
func listens<B>(_ f: @escaping (F.W) -> B) -> Kind<F, (B, A)>Parameters
fA function to transform the side stream of data.
Return Value
A tuple of the transformation of the side stream and the result of the computation.
-
Transforms the side stream of data of this computation.
This is a convenience method to call
MonadWriter.censoras an instance method of this type.Declaration
Swift
func censor(_ f: @escaping (F.W) -> F.W) -> Kind<F, A>Parameters
fTransforming function.
Return Value
A computation with the same result as the provided one, with the transformed side stream of data.
-
Empty element.
This element must obey the following laws:
combineK(fa, emptyK()) == combineK(emptyK(), fa) == faThis is a convenience method to call
MonoidK.emptyKas a static method of this type.Declaration
Swift
static func emptyK() -> Kind<F, A>Return Value
A value representing the empty element of this MonoidK instance.
-
Undocumented
Declaration
Swift
static func identity() -> Kind<F, A>
-
Divides this structure of values into a tuple that represents the first value of the structure (first component of the tuple) and the rest of values of the structure (second component of the tuple)
Declaration
Swift
func split() -> (A, Kind<F.G, A>)Return Value
Tuple containing the first and rest of values in the structure.
-
Eagerly reduces this structure of values from left to right, also performing a transformation of values.
Declaration
Swift
func reduceLeftTo<B>( _ f: (A) -> B, _ g: (B, A) -> B) -> BParameters
fTransforming function.
gFolding function.
Return Value
Summary value of this reduction.
-
Lazily reduces this structure of values from right to left, also performing a transformation of values.
Parameters
fTransforming function.
gFolding function.
Return Value
Potentially lazy summary value of this reduction.
-
Reduces this structure of values to a summary value using the combination capabilities of the
Semigroupinstance of the underlying type.Declaration
Swift
func reduce() -> AReturn Value
Summary value of this reduction.
-
Conditionally applies a computation based on the result of this computation.
Declaration
Swift
func select<AA, B>(_ f: Kind<F, (AA) -> B>) -> Kind<F, B> where A == Either<AA, B>Parameters
fA computation that is executed in case the receiving computation evaluates to a left value.
Return Value
Composition of the two computations.
-
Evaluates one out of two computations based on the result of this computation.
Declaration
Swift
func branch<AA, B, C>(ifLeft fa: Kind<F, (AA) -> C>, ifRight fb: Kind<F, (B) -> C>) -> Kind<F, C> where A == Either<AA, B>Parameters
ifLeftComputation that will be executed if this computation evaluates to an
Either.leftvalue.ifRightComputation that will be executed if this computation evaluates to an
Either.rightvalue.Return Value
Composition of the computations.
-
Declaration
Swift
func fromOptionS<AA>(defaultValue x: Kind<F, AA>) -> Kind<F, AA> where A == Option<AA>Parameters
defaultValueDefault value for the empty case.
Return Value
Composition of the two computations.
-
Evaluates the second computation when this evaluates to
true.Declaration
Swift
func whenS(then f: Kind<F, ()>) -> Kind<F, ()>Parameters
thenA computation that will be evaluated if the first computation evaluates to
true.Return Value
Composition of the two computations.
-
Evaluates one out of two computations based on the result of another computation.
Declaration
Swift
func ifS<A>(then t: Kind<F, A>, else e: Kind<F, A>) -> Kind<F, A>Parameters
thenComputation that will be executed if this evaluates to
true.elseComputation that will be executed if this evaluates to
false.Return Value
Composition of the computations.
-
A lifted version of lazy boolean or.
Declaration
Swift
func orS(_ y: Kind<F, Bool>) -> Kind<F, Bool>Parameters
yComputation to be or'ed.
Return Value
Result of the or operation on the two computations.
-
A lifted version of lazy boolean and.
Declaration
Swift
func andS(_ y: Kind<F, Bool>) -> Kind<F, Bool>Parameters
yComputation to be and'ed.
Return Value
Result of the and operation on the two computations.
-
Evaluates this computation as long as it evaluates to
true.Declaration
Swift
func whileS() -> Eval<Kind<F, ()>>Return Value
A potentially lazy computation.
-
Combines this value with another value of the same type.
This is a convenience method to call
SemigroupK.combineKas an instance method of this type.Declaration
Swift
func combineK(_ y: Kind<F, A>) -> Kind<F, A>Parameters
yRight value in the combination.
Return Value
Combination of the two values.
-
Multiplicatively combine F and F into F<(A, B)>
This is a convenience method to call
Semigroupal.productas an instance method of this type.Declaration
Swift
func product<B>(_ y: Kind<F, B>) -> Kind<F, (A, B)>Parameters
yRight value.
Return Value
Cartesian product of the two values.
-
Maps each element of this structure to an effect, evaluates them from left to right and collects the results.
Declaration
Swift
func traverse<G: Applicative, B>(_ f: @escaping (A) -> Kind<G, B>) -> Kind<G, Kind<F, B>>Parameters
fA function producing an effect.
Return Value
Results collected under the context of the effect provided by the function.
-
Evaluate each effect in this structure of values and collects the results.
Declaration
Swift
func sequence<G: Applicative, AA>() -> Kind<G, Kind<F, AA>> where A: Kind<G, AA>Return Value
Results collected under the context of the effects.
-
A traverse followed by flattening the inner result.
Declaration
Swift
func flatTraverse<G: Applicative, B>(_ f: @escaping (A) -> Kind<G, Kind<F, B>>) -> Kind<G, Kind<F, B>>Parameters
fA transforming function yielding nested effects.
Return Value
Results collected and flattened under the context of the effects.
-
Maps each element of this structure using a stateful function.
Declaration
Swift
func scanLeft<B, S>( initialState: S, f: @escaping (A) -> State<S, B>) -> Kind<F, B>Parameters
initialStateThe state that will be passed to f initially.
fA stateful function.
Return Value
A new structure with the results of the function.
-
Maps each element of this structure using a stateful function.
Declaration
Swift
func scanLeft<B>( initialState: B, f: @escaping (B, A) -> B) -> Kind<F, B>Parameters
initialStateThe state that will be passed to f initially.
fA stateful function that returns the new state, which will be included in the returned structure.
Return Value
A new structure with the results of the function.
-
Maps each element of this structure to an effect using a stateful function.
Declaration
Parameters
initialStateThe state that will be passed to f initially.
fA stateful function producing an effect.
Return Value
Results collected under the context of the effect provided by the function.
-
Maps each element of this structure to an effect using a stateful function.
Declaration
Swift
func scanLeftM<M: Monad, B>( initialState: Kind<M, B>, f: @escaping (B, A) -> Kind<M, B>) -> Kind<M, Kind<F, B>>Parameters
initialStateThe state that will be passed to f initially.
fA stateful function producing an effect, which will be included in the returned structure.
Return Value
Results collected under the context of the effect provided by the function.
-
A combined traverse and filter operation. Filtering is handled using
Optioninstead of Bool so that the output can be different than the input type.This is a convenience method to call
TraverseFilter.traverseFilteras an instance method of this type.Declaration
Swift
func traverseFilter<B, G: Applicative>(_ f: @escaping (A) -> Kind<G, OptionOf<B>>) -> Kind<G, Kind<F, B>>Parameters
faA value in this context.
fA function to traverse and filter each value.
Return Value
Result of traversing this structure and filter values using the provided function.
-
Filters values in a different context.
This is a convenience method to call
TraverseFilter.filterAas an instance method of this type.Declaration
Swift
func filterA<G: Applicative>(_ f: @escaping (A) -> Kind<G, Bool>) -> Kind<G, Kind<F, A>>Parameters
faA value in this context.
fA function to filter each value.
Return Value
Result of traversing this structure and filter values using the provided function.
Install in Dash
Kind Class Reference