Cokleisli

public class Cokleisli<F, A, B> : CokleisliOf<F, A, B>

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

  • Undocumented

    Declaration

    Swift

    public let run: (Kind<F, A>) -> B
  • Safe downcast.

    Declaration

    Swift

    public static func fix(_ fa: CokleisliOf<F, A, B>) -> Cokleisli<F, A, B>

    Parameters

    value

    Value in higher-kind form.

    Return Value

    Value cast to Cokleisli.

  • Initializes a Cokleisli.

    Declaration

    Swift

    public init(_ run: @escaping (Kind<F, A>) -> B)

    Parameters

    run

    Closure to be wrapped in this Cokleisli.

  • Composes the internal function with another function.

    Declaration

    Swift

    public func contramapValue<C>(_ f: @escaping (Kind<F, C>) -> Kind<F, A>) -> Cokleisli<F, C, B>

    Parameters

    f

    Function to compose with the internal function.

    Return Value

    A Cokleisli with the result of the composition.

  • Invokes this function.

    Declaration

    Swift

    public func callAsFunction(_ value: Kind<F, A>) -> B

    Parameters

    value

    Input to the function.

    Return Value

    Output of the function.

  • Creates a Cokleisli that extracts the value of a Comonad.

    Declaration

    Swift

    public static func ask() -> Cokleisli<F, B, B>

    Return Value

    A Cokleisli that extracts the value of a Comonad.

  • Transforms the type arguments of this Cokleisli.

    Declaration

    Swift

    public func bimap<C, D>(
        _ g: @escaping (D) -> A,
        _ f: @escaping (B) -> C) -> Cokleisli<F, D, C>

    Parameters

    g

    Function to transform the input type argument.

    f

    Function to transform the output type argument.

    Return Value

    A Cokleisli with both type arguments transformed.

  • Transforms the input type argument of this Cokleisli.

    Declaration

    Swift

    public func lmap<D>(_ g: @escaping (D) -> A) -> Cokleisli<F, D, B>

    Parameters

    g

    Function to transform the input type argument.

    Return Value

    A Cokleisli with both type arguments transformed.

  • Composes this Cokleisli with another one.

    Declaration

    Swift

    public func compose<D>(_ a: Cokleisli<F, D, A>) -> Cokleisli<F, D, B>

    Parameters

    a

    Cokleisli to compose with this value.

    Return Value

    Composition of both Cokleisli values.

  • Composes this Cokleisli with an effect, discarding the result produced by this Cokleisli.

    Declaration

    Swift

    public func andThen<C>(_ a: Kind<F, C>) -> Cokleisli<F, A, C>

    Parameters

    a

    An effect.

    Return Value

    Composition of this Cokleisli with an effect.

  • Composes this Cokleisli with another one.

    Declaration

    Swift

    public func andThen<C>(_ a: Cokleisli<F, B, C>) -> Cokleisli<F, A, C>

    Parameters

    a

    Cokleisli to compose with this value.

    Return Value

    Composition of both Cokleisli values.