FunctionK

open class FunctionK<F, G>

A transformation between two kinds.

As Function1<A, B> represents a transformation from A to B, FunctionK<F, G> represents a transformation from Kind<F, A> to Kind<G, A>. Subclasses of FunctionK need to implement invoke.

  • Initializer

    Declaration

    Swift

    public init()
  • Invokes this transformation.

    Declaration

    Swift

    open func invoke<A>(_ fa: Kind<F, A>) -> Kind<G, A>

    Parameters

    fa

    Input to this function

    Return Value

    Transformed input.

  • Composes this function with another one.

    Declaration

    Swift

    public func andThen<H>(_ g: FunctionK<G, H>) -> FunctionK<F, H>

    Parameters

    g

    Function to compose with this one.

    Return Value

    A function that transform the input with this function and the received one afterwards.

  • Composes this function with another one.

    Declaration

    Swift

    public func compose<H>(_ g: FunctionK<H, F>) -> FunctionK<H, G>

    Parameters

    g

    Function to compose with this one.

    Return Value

    A function that transform the input with the received function and this one afterwards.

  • Identity FunctionK.

    It returns the input unmodified.

    Declaration

    Swift

    public static var id: FunctionK<F, F> { get }