EitherK

public final 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.

  • Provides an Iso to go from/to this type to its Kind version.

    Declaration

    Swift

    static var fixIso: Iso<EitherK<F, G, A>, EitherKOf<F, G, A>> { get }
  • Provides a Fold based on the Foldable instance of this type.

    Declaration

    Swift

    static var fold: Fold<EitherK<F, G, A>, A> { get }
  • Provides a Traversal based on the Traverse instance of this type.

    Declaration

    Swift

    static var traversal: Traversal<EitherK<F, G, A>, A> { get }
  • Undocumented

    Declaration

    Swift

    public typealias EachFoci = A
  • Declaration

    Swift

    public static var each: Traversal<EitherK<F, G, A>, A> { get }
  • Creates a left value with the provided value.

    Declaration

    Swift

    public static func left(_ a: A) -> EitherK<F, G, A>

    Parameters

    a

    Value to be wrapped in the left side.

    Return Value

    An EitherK with the provided value on the left side.

  • Creates a right value with the provided value.

    Declaration

    Swift

    public static func right(_ a: A) -> EitherK<F, G, A>

    Parameters

    a

    Value to be wrapped in the right side.

    Return Value

    An EitherK with the provided value on the right side.