EitherK

public class EitherK<F, G, A> : EitherKOf<F, G, A>

EitherK is a sum type for kinds. Represents a type where you can hold either a Kind<F, A> or a Kind<G, A>.

  • Safe downcast.

    Declaration

    Swift

    public static func fix(_ fa: EitherKOf<F, G, A>) -> EitherK<F, G, A>

    Parameters

    fa

    Value in the higher-kind form.

    Return Value

    Value cast to EitherK.

  • Initializes a EitherK from an Either.

    Declaration

    Swift

    public init(_ run: Either<Kind<F, A>, Kind<G, A>>)

    Parameters

    run

    Either value to initialize this EitherK.

  • Initializes a EitherK from a value of the left type.

    Declaration

    Swift

    public init(_ fa: Kind<F, A>)

    Parameters

    fa

    Value of the left type.

  • Initializes a EitherK from a value of the right type.

    Declaration

    Swift

    public init(_ ga: Kind<G, A>)

    Parameters

    ga

    Value of the right type.

  • Applies the provided FunctionK based on the content of this EitherK value.

    Declaration

    Swift

    public func fold<H>(_ f: FunctionK<F, H>, _ g: FunctionK<G, H>) -> Kind<H, A>

    Parameters

    f

    Function to apply if the contained value in this EitherK is a member of the left type.

    g

    Function to apply if the contained value in this EitherK is a member of the right type.

    Return Value

    Result of applying the corresponding function to this value.