Kleisli

public final class Kleisli<F, D, A> : KleisliOf<F, D, A>

Kleisli represents a function with the signature (D) -> Kind<F, A>.

  • 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(_ run: @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 invoke(_ value: D) -> Kind<F, A>

    Parameters

    value

    Input to the function.

    Return Value

    Output of the Kleisli.

  • 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>(_ a: Kind<F, B>) -> Kleisli<F, D, B>

    Parameters

    a

    Constant value.

    Return Value

    A Kleisli function that is equivalent to running this Kleisli and ommitting its result, returning the constant value produced.