-
Safe downcast.
Declaration
Swift
public static func fix(_ fa: KleisliOf<F, D, A>) -> Kleisli<F, D, A>
Parameters
fa
Value in the higher-kind form.
Return Value
Value cast to Kleisli.
-
Creates a constant Kleisli function.
Declaration
Swift
public static func liftF(_ fa: Kind<F, A>) -> Kleisli<F, D, A>
Parameters
fa
Constant value to return.
Return Value
A constant Kleisli function.
-
Initializes a Kleisli value.
Declaration
Swift
public init(_ f: @escaping (D) -> Kind<F, A>)
Parameters
run
Closure to be wrapped in this Kleisli.
-
Inkoves this Kleisli function with an input value.
Declaration
Swift
public func run(_ value: D) -> Kind<F, A>
Parameters
value
Input to the function.
Return Value
Output of the Kleisli.
-
Inkoves this Kleisli function with an input value.
Declaration
Swift
public func callAsFunction(_ value: D) -> Kind<F, A>
Parameters
value
Input to the function.
Return Value
Output of the Kleisli.
-
Pre-composes this Kleisli function with a function transforming the input type.
Declaration
Swift
public func contramap<DD>(_ f: @escaping (DD) -> D) -> Kleisli<F, DD, A>
Parameters
f
Transforming function.
Return Value
Composition of the two functions.
-
Narrows the scope of the context of this Kleisli from
Any
to a concrete typeDeclaration
Swift
public func narrow<DD>() -> Kleisli<F, DD, A> where D == Any
Return Value
A copy of this Kleisli working on a more precise context.
-
Creates an EnvIO from a side-effectful function that has a dependency.
Declaration
Parameters
f
Side-effectful function. Errors thrown from this function must be of type
E
; otherwise, a fatal error will happen.Return Value
An EnvIO value suspending the execution of the side effect.
-
Creates an EnvIO from a side-effectful function returning an Either that has a dependency.
Declaration
Parameters
f
Side-effectful function.
Return Value
An EnvIO value suspending the execution of the side effect.
-
Creates an EnvIO from a side-effectful function returning a Result that has a dependency.
Declaration
Parameters
f
Side-effectful function.
Return Value
An EnvIO value suspending the execution of the side effect.
-
Creates an EnvIO from a side-effectful function returning a Validated that has a dependency.
Declaration
Parameters
f
Side-effectful function.
Return Value
An EnvIO value suspending the execution of the side effect.
-
Retries this computation if it fails based on the provided retrial policy.
This computation will be at least executed once, and if it fails, it will be retried according to the policy.
Declaration
Parameters
policy
Retrial policy.
Return Value
A computation that is retried based on the provided policy when it fails.
-
Retries this computation if it fails based on the provided retrial policy, providing a default computation to handle failures after retrial.
This computation will be at least executed once, and if it fails, it will be retried according to the policy.
Declaration
Parameters
policy
Retrial policy.
orElse
Function to handle errors after retrying.
Return Value
A computation that is retried based on the provided policy when it fails.
-
Repeats this computation until the provided repeating policy completes, or until it fails.
This computation will be at least executed once, and if it succeeds, it will be repeated additional times according to the policy.
Declaration
Parameters
policy
Repeating policy.
onUpdateError
A function providing an error in case the policy fails to update properly.
Return Value
A computation that is repeated based on the provided policy when it succeeds.
-
Repeats this computation until the provided repeating policy completes, or until it fails, with a function to handle potential failures.
Declaration
Parameters
policy
Repeating policy.
onUpdateError
A function providing an error in case the policy fails to update properly.
orElse
A function to return a computation in case of error.
Return Value
A computation that is repeated based on the provided policy when it succeeds.
-
Transforms the type arguments of this EnvIO.
Declaration
Parameters
fe
Function to transform the error type argument.
fa
Function to transform the output type argument.
Return Value
An EnvIO with both type arguments transformed.
-
Performs the side effects that are suspended in this IO in a synchronous manner.
Throws
Error of typeE
that may happen during the evaluation of the side-effects. Errors of other types thrown from the evaluation of this IO will cause a fatal error.Declaration
Swift
func unsafeRunSync<E: Error>( with d: D, on queue: DispatchQueue = .main) throws -> A where F == IOPartial<E>
Parameters
d
Dependencies needed in this operation.
queue
Dispatch queue used to execute the side effects. Defaults to the main queue.
Return Value
Value produced after running the suspended side effects.
-
Performs the side effects that are suspended in this EnvIO in a synchronous manner.
Declaration
Parameters
d
Dependencies needed in this operation.
queue
Dispatch queue used to execute the side effects. Defaults to the main queue.
Return Value
An Either wrapping errors in the left side and values on the right side. Errors of other types thrown from the evaluation of this IO will cause a fatal error.
-
Performs the side effects that are suspended in this EnvIO in an asynchronous manner.
Declaration
Parameters
d
Dependencies needed in this operation.
queue
Dispatch queue used to execute the side effects. Defaults to the main queue.
callback
A callback function to receive the results of the evaluation. Errors of other types thrown from the evaluation of this IO will cause a fatal error.
-
Performs the side effects that are suspended in this IO in a synchronous manner.
Throws
Error of typeE
that may happen during the evaluation of the side-effects. Errors of other types thrown from the evaluation of this IO will cause a fatal error.Declaration
Swift
func unsafeRunSync<E: Error>(on queue: DispatchQueue = .main) throws -> A where F == IOPartial<E>
Parameters
queue
Dispatch queue used to execute the side effects. Defaults to the main queue.
Return Value
Value produced after running the suspended side effects.
-
Performs the side effects that are suspended in this EnvIO in a synchronous manner.
Declaration
Parameters
queue
Dispatch queue used to execute the side effects. Defaults to the main queue.
Return Value
An Either wrapping errors in the left side and values on the right side. Errors of other types thrown from the evaluation of this IO will cause a fatal error.
-
Performs the side effects that are suspended in this EnvIO in an asynchronous manner.
Declaration
Parameters
queue
Dispatch queue used to execute the side effects. Defaults to the main queue.
callback
A callback function to receive the results of the evaluation. Errors of other types thrown from the evaluation of this IO will cause a fatal error.
-
Accesses the environment to produce a pure value.
Declaration
Swift
public static func access(_ f: @escaping (D) -> A) -> Kleisli<F, D, A>
Parameters
f
Function accessing the environment.
Return Value
A Kleisli function wrapping the produced value.
-
Accesses the environment to produce a Kleisli effect.
Declaration
Swift
public static func accessM(_ f: @escaping (D) -> Kleisli<F, D, A>) -> Kleisli<F, D, A>
Parameters
f
Function accessing the environment.
Return Value
A Kleisli function wraping the produced value.
-
Zips this Kleisli function with another one with the same input type.
Declaration
Swift
public func zip<B>(_ o: Kleisli<F, D, B>) -> Kleisli<F, D, (A, B)>
Parameters
o
Kleisli function to be zipped with this one.
Return Value
A Kleisli function that pairs the output of the two Kleisli functions zipped in this operation.
-
Composes this Kleisli with another one.
Declaration
Swift
public func andThen<C>(_ f: Kleisli<F, A, C>) -> Kleisli<F, D, C>
Parameters
f
Kleisli function to be composed after the this one.
Return Value
A Kleisli function that is equivalent to running this Kleisli and then the received one.
-
Composes this Kleisli with a function in Kleisli form.
Declaration
Swift
public func andThen<B>(_ f: @escaping (A) -> Kind<F, B>) -> Kleisli<F, D, B>
Parameters
f
A function to be composed after this Kleisli.
Return Value
A Kleisli function that is equivalent to running this Kleisli and then the received one.
-
Composes this Kleisli with a constant value.
Declaration
Swift
public func andThen<B>(_ fb: Kind<F, B>) -> Kleisli<F, D, B>
Parameters
fb
Constant value.
Return Value
A Kleisli function that is equivalent to running this Kleisli and ommitting its result, returning the constant value produced.
-
Folds over the result of this computation by accepting a function to execute in case of error, and another one in the case of success.
Declaration
Swift
public func foldA<B>( _ f: @escaping (F.E) -> B, _ g: @escaping (A) -> B ) -> Kleisli<F, D, B>
Parameters
f
Function to run in case of error.
g
Function to run in case of success.
Return Value
A computation from the result of applying the provided functions to the result of this computation.
-
Folds over the result of this computation by accepting an effect to execute in case of error, and another one in the case of success.
Declaration
Swift
public func foldM<B>( _ f: @escaping (F.E) -> Kleisli<F, D, B>, _ g: @escaping (A) -> Kleisli<F, D, B>) -> Kleisli<F, D, B>
Parameters
f
Function to run in case of error.
g
Function to run in case of success.
Return Value
A computation from the result of applying the provided functions to the result of this computation.