LazyFunction1

public final class LazyFunction1<I, O> : LazyFunction1Of<I, O>

This data type acts as a wrapper over functions, like Function1. As opposed to Function1, function composition is stack-safe. This means that no matter how many LazyFunction1s you compose, calling their composition won’t cause a stack overflow.

  • Safe downcast.

    Declaration

    Swift

    public static func fix(_ fa: LazyFunction1Of<I, O>) -> LazyFunction1<I, O>

    Parameters

    fa

    Value in the higher-kind form.

    Return Value

    Value cast to LazyFunction1.

  • Constructs a value of LazyFunction1.

    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.

  • Invokes this function.

    Declaration

    Swift

    public func callAsFunction(_ 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: LazyFunction1<A, I>) -> LazyFunction1<A, O>

    Parameters

    f

    Function to compose.

    Return Value

    Composition of the two functions.

  • Concatenates another function.

    Declaration

    Swift

    public func andThen<A>(_ f: LazyFunction1<O, A>) -> LazyFunction1<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) -> LazyFunction1<A, O>

    Parameters

    f

    Function to compose.

    Return Value

    Composition of the two functions.