Function1

public final class Function1<I, O> : Function1Of<I, O>

This data type acts as a wrapper over functions. It receives two type parameters representing the input and output type of the function. The wrapper adds capabilities to use a function as a Higher Kinded Type and conform to typeclasses that have this requirement.

  • Safe downcast.

    Declaration

    Swift

    public static func fix(_ fa: Function1Of<I, O>) -> Function1<I, O>

    Parameters

    fa

    Value in the higher-kind form.

    Return Value

    Value cast to Function1.

  • Constructs a value of Function1.

    Declaration

    Swift

    public init(_ f: @escaping (I) -> O)

    Parameters

    f

    Function to be wrapped in this Higher Kinded Type.

  • Invokes this function.

    Declaration

    Swift

    public func invoke(_ value: I) -> O

    Parameters

    value

    Input to the function.

    Return Value

    Result of invoking the function.

  • Composes with another function.

    Declaration

    Swift

    public func compose<A>(_ f: Function1<A, I>) -> Function1<A, O>

    Parameters

    f

    Function to compose.

    Return Value

    Composition of the two functions.

  • Concatenates another function.

    Declaration

    Swift

    public func andThen<A>(_ f: Function1<O, A>) -> Function1<I, A>

    Parameters

    f

    Function to concatenate.

    Return Value

    Concatenation of the two functions.

  • Composes with another function.

    Declaration

    Swift

    public func contramap<A>(_ f: @escaping (A) -> I) -> Function1<A, O>

    Parameters

    f

    Function to compose.

    Return Value

    Composition of the two functions.

  • Declaration

    Swift

    public func combine(_ other: Function1<I, O>) -> Function1<I, O>