Kind
open class Kind<F, A>
Simulates a Higher-Kinded Type in Swift with 1 type argument.
This class simulates Higher-Kinded Type support in Swift. Kind<F, A>
is an alias for F<A>
, which is not syntactically valid in Swift.
Classes that want to have HKT support must extend this class. Type parameter F
is reserved for a witness to prevent circular references in the inheritance relationship. By convention, witnesses are named like the class they represent, with the prefix For
. As an example:
class ForOption {}
class Option<A>: Kind<ForOption, A> {}
-
Undocumented
Declaration
Swift
public init()
-
Undocumented
Declaration
Swift
public static func ana<B>(_ a: B, _ coalgebra: @escaping Coalgebra<A, B>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func projectT() -> Kind<A, Kind<F, A>>
-
Undocumented
Declaration
Swift
public static func project() -> Coalgebra<A, Kind<F, A>>
-
Undocumented
Declaration
Swift
public static func runAsync(_ fa: @escaping Proc<F.E, A>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
func runAsyncCancellable(_ callback: @escaping (Either<F.E, A>) -> Kind<F, ()>) -> Kind<F, Disposable>
-
Undocumented
Declaration
Swift
public func runAsync(_ callback: @escaping (Either<F.E, A>) -> Kind<F, ()>) -> Kind<F, ()>
-
Undocumented
Declaration
Swift
public static func suspend(_ fa: @escaping () -> Kind<F, A>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public static func delay(_ f: @escaping () throws -> A) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public static func lazy() -> Kind<F, ()>
-
Undocumented
Declaration
Swift
public static func delayEither(_ f: @escaping () -> Either<F.E, A>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public static func pure(_ a: A) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func ap<AA, B>(_ fa: Kind<F, AA>) -> Kind<F, B> where A == (AA) -> B
-
Undocumented
Declaration
Swift
public static func product<A, B>(_ fa: Kind<F, A>, _ fb: Kind<F, B>) -> Kind<F, (A, B)>
-
Undocumented
Declaration
Swift
public static func product<A, B, Z>(_ fa: Kind<F, (A, B)>, _ fz: Kind<F, Z>) -> Kind<F, (A, B, Z)>
-
Undocumented
Declaration
Swift
public static func product<A, B, C, Z>(_ fa: Kind<F, (A, B, C)>, _ fz: Kind<F, Z>) -> Kind<F, (A, B, C, Z)>
-
Undocumented
Declaration
Swift
public static func product<A, B, C, D, Z>(_ fa: Kind<F, (A, B, C, D)>, _ fz: Kind<F, Z>) -> Kind<F, (A, B, C, D, Z)>
-
Undocumented
Declaration
Swift
public static func product<A, B, C, D, E, Z>(_ fa: Kind<F, (A, B, C, D, E)>, _ fz: Kind<F, Z>) -> Kind<F, (A, B, C, D, E, Z)>
-
Undocumented
Declaration
Swift
public static func product<A, B, C, D, E, G, Z>(_ fa: Kind<F, (A, B, C, D, E, G)>, _ fz: Kind<F, Z>) -> Kind<F, (A, B, C, D, E, G, Z)>
-
Undocumented
Declaration
Swift
public static func product<A, B, C, D, E, G, H, Z>(_ fa: Kind<F, (A, B, C, D, E, G, H)>, _ fz: Kind<F, Z>) -> Kind<F, (A, B, C, D, E, G, H, Z)>
-
Undocumented
Declaration
Swift
public static func product<A, B, C, D, E, G, H, I, Z>(_ fa: Kind<F, (A, B, C, D, E, G, H, I)>, _ fz: Kind<F, Z>) -> Kind<F, (A, B, C, D, E, G, H, I, Z)>
-
Undocumented
Declaration
Swift
public static func tupled<A, B>(_ a: Kind<F, A>, _ b : Kind<F, B>) -> Kind<F, (A, B)>
-
Undocumented
Declaration
Swift
public static func tupled<A, B, C>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>) -> Kind<F, (A, B, C)>
-
Undocumented
Declaration
Swift
public static func tupled<A, B, C, D>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>) -> Kind<F, (A, B, C, D)>
-
Undocumented
Declaration
Swift
public static func tupled<A, B, C, D, E>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>) -> Kind<F, (A, B, C, D, E)>
-
Undocumented
Declaration
Swift
public static func tupled<A, B, C, D, E, G>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>) -> Kind<F, (A, B, C, D, E, G)>
-
Undocumented
Declaration
Swift
public static func tupled<A, B, C, D, E, G, H>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>) -> Kind<F, (A, B, C, D, E, G, H)>
-
Undocumented
Declaration
Swift
public static func tupled<A, B, C, D, E, G, H, I>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>, _ i: Kind<F, I>) -> Kind<F, (A, B, C, D, E, G, H, I)>
-
Undocumented
Declaration
Swift
public static func tupled<A, B, C, D, E, G, H, I, J>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>, _ i: Kind<F, I>, _ j: Kind<F, J>) -> Kind<F, (A, B, C, D, E, G, H, I, J)>
-
Undocumented
Declaration
Swift
public static func map<A, B, Z>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ f: @escaping (A, B) -> Z) -> Kind<F, Z>
-
Undocumented
Declaration
Swift
public static func map<A, B, C, Z>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ f: @escaping (A, B, C) -> Z) -> Kind<F, Z>
-
Undocumented
Declaration
Swift
public static func map<A, B, C, D, Z>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ f: @escaping (A, B, C, D) -> Z) -> Kind<F, Z>
-
Undocumented
Declaration
Swift
public static func map<A, B, C, D, E, Z>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ f: @escaping (A, B, C, D, E) -> Z) -> Kind<F, Z>
-
Undocumented
Declaration
Swift
public static func map<A, B, C, D, E, G, Z>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ f: @escaping (A, B, C, D, E, G) -> Z) -> Kind<F, Z>
-
Undocumented
Declaration
Swift
public static func map<A, B, C, D, E, G, H, Z>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>, _ f: @escaping (A, B, C, D, E, G, H) -> Z) -> Kind<F, Z>
-
Undocumented
Declaration
Swift
public static func map<A, B, C, D, E, G, H, I, Z>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>, _ i: Kind<F, I>, _ f: @escaping (A, B, C, D, E, G, H, I) -> Z) -> Kind<F, Z>
-
Undocumented
Declaration
Swift
public static func map<A, B, C, D, E, G, H, I, J, Z>(_ a: Kind<F, A>, _ b: Kind<F, B>, _ c: Kind<F, C>, _ d: Kind<F, D>, _ e: Kind<F, E>, _ g: Kind<F, G>, _ h: Kind<F, H>, _ i: Kind<F, I>, _ j: Kind<F, J>, _ f: @escaping (A, B, C, D, E, G, H, I, J) -> Z) -> Kind<F, Z>
-
Undocumented
Declaration
Swift
public static func raiseError(_ e: F.E) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func handleErrorWith(_ f: @escaping (F.E) -> Kind<F, A>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func handleError(_ f: @escaping (F.E) -> A) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func attempt() -> Kind<F, Either<F.E, A>>
-
Undocumented
Declaration
Swift
public static func fromEither(_ fea: Either<F.E, A>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public static func catchError(_ f: () throws -> A, _ recover: (Error) -> F.E) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public static func catchError(_ f: () throws -> A) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func coflatMap<B>(_ f: @escaping (Kind<F, A>) -> B) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public func extract() -> A
-
Undocumented
Declaration
Swift
public func duplicate() -> Kind<F, Kind<F, A>>
-
Undocumented
Declaration
Swift
public func contramap<B>(_ f : @escaping (B) -> A) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public static func contralift<B>(_ f : @escaping (A) -> B) -> (Kind<F, B>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func eq(_ rhs: Kind<F, A>) -> Bool
-
Declaration
Swift
public static func == (lhs: Kind<F, A>, rhs: Kind<F, A>) -> Bool
-
Undocumented
Declaration
Swift
public func foldLeft<B>(_ b: B, _ f: @escaping (B, A) -> B) -> B
-
Undocumented
Declaration
Swift
public func reduceLeftToOption<B>(_ f: @escaping (A) -> B, _ g: @escaping (B, A) -> B) -> Option<B>
-
Undocumented
Declaration
Swift
public func reduceLeftOption(_ f: @escaping (A, A) -> A) -> Option<A>
-
Undocumented
Declaration
Swift
public func foldMap<B: Monoid>(_ f: @escaping (A) -> B) -> B
-
Undocumented
Declaration
Swift
public func traverse_<G: Applicative, B>(_ f: @escaping (A) -> Kind<G, B>) -> Kind<G, Unit>
-
Undocumented
Declaration
Swift
public static func sequence_<G>(_ fga: Kind<F, Kind<G, A>>) -> Kind<G, Unit> where G : Applicative
-
Undocumented
Declaration
Swift
public func find(_ f: @escaping (A) -> Bool) -> Option<A>
-
Undocumented
Declaration
Swift
public func exists(_ predicate: @escaping (A) -> Bool) -> Bool
-
Undocumented
Declaration
Swift
public func forall(_ predicate: @escaping (A) -> Bool) -> Bool
-
Undocumented
Declaration
Swift
public var isEmpty: Bool { get }
-
Undocumented
Declaration
Swift
public var nonEmpty: Bool { get }
-
Undocumented
Declaration
Swift
public func foldM<G: Monad, B>(_ b: B, _ f: @escaping (B, A) -> Kind<G, B>) -> Kind<G, B>
-
Undocumented
Declaration
Swift
public func get(_ index: Int64) -> Option<A>
-
Undocumented
Declaration
Swift
public func fold() -> A
-
Undocumented
Declaration
Swift
public func combineAll() -> A
-
Undocumented
Declaration
Swift
public var count: Int64 { get }
-
Undocumented
Declaration
Swift
public func map<B>(_ f : @escaping (A) -> B) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public static func lift<A, B>(_ f : @escaping (A) -> B) -> (Kind<F, A>) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public func void() -> Kind<F, ()>
-
Undocumented
Declaration
Swift
public func fproduct<B>(_ f : @escaping (A) -> B) -> Kind<F, (A, B)>
-
Undocumented
Declaration
Swift
public func `as`<B>(_ b: B) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public func tupleLeft<B>(_ b: B) -> Kind<F, (B, A)>
-
Undocumented
Declaration
Swift
public func tupleRight<B>(_ b: B) -> Kind<F, (A, B)>
-
Undocumented
Declaration
Swift
public func mapFilter<B>(_ f: @escaping (A) -> OptionOf<B>) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public static func flattenOption(_ fa: Kind<F, OptionOf<A>>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func filter(_ f: @escaping (A) -> Bool) -> Kind<F, A>
-
Undocumented
Declaration
Swift
func imap<B>(_ f : @escaping (A) -> B, _ g : @escaping (B) -> A) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public func flatMap<B>(_ f: @escaping (A) -> Kind<F, B>) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public static func tailRecM<B>(_ a: A, _ f: @escaping (A) -> Kind<F, Either<A, B>>) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public static func flatten(_ ffa: Kind<F, Kind<F, A>>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func followedBy<B>(_ fb: Kind<F, B>) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public func followedByEval<B>(_ fb: Eval<Kind<F, B>>) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public func forEffect<B>(_ fb: Kind<F, B>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func forEffectEval<B>(_ fb: Eval<Kind<F, B>>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func mproduct<B>(_ f: @escaping (A) -> Kind<F, B>) -> Kind<F, (A, B)>
-
Undocumented
Declaration
Swift
public static func binding<B, C>(_ f: () -> Kind<F, B>, _ fb: @escaping (B) -> Kind<F, C>) -> Kind<F, C>
-
Undocumented
Declaration
Swift
public static func binding<B, C, D>(_ f: () -> Kind<F, B>, _ fb: @escaping (B) -> Kind<F, C>, _ fc: @escaping (B, C) -> Kind<F, D>) -> Kind<F, D>
-
Undocumented
Declaration
Swift
public static func binding<B, C, D, E>(_ f: () -> Kind<F, B>, _ fb: @escaping (B) -> Kind<F, C>, _ fc: @escaping (B, C) -> Kind<F, D>, _ fd: @escaping (B, C, D) -> Kind<F, E>) -> Kind<F, E>
-
Undocumented
Declaration
Swift
public static func binding<B, C, D, E, G>(_ f: () -> Kind<F, B>, _ fb: @escaping (B) -> Kind<F, C>, _ fc: @escaping (B, C) -> Kind<F, D>, _ fd: @escaping (B, C, D) -> Kind<F, E>, _ fe: @escaping (B, C, D, E) -> Kind<F, G>) -> Kind<F, G>
-
Undocumented
Declaration
Swift
public static func binding<B, C, D, E, G, H>(_ f: () -> Kind<F, B>, _ fb: @escaping (B) -> Kind<F, C>, _ fc: @escaping (B, C) -> Kind<F, D>, _ fd: @escaping (B, C, D) -> Kind<F, E>, _ fe: @escaping (B, C, D, E) -> Kind<F, G>, _ fg: @escaping (B, C, D, E, G) -> Kind<F, H>) -> Kind<F, H>
-
Undocumented
Declaration
Swift
public static func binding<B, C, D, E, G, H, I>(_ f: () -> Kind<F, B>, _ fb: @escaping (B) -> Kind<F, C>, _ fc: @escaping (B, C) -> Kind<F, D>, _ fd: @escaping (B, C, D) -> Kind<F, E>, _ fe: @escaping (B, C, D, E) -> Kind<F, G>, _ fg: @escaping (B, C, D, E, G) -> Kind<F, H>, _ fh: @escaping (B, C, D, E, G, H) -> Kind<F, I>) -> Kind<F, I>
-
Undocumented
Declaration
Swift
public static func binding<B, C, D, E, G, H, I, J>(_ f: () -> Kind<F, B>, _ fb: @escaping (B) -> Kind<F, C>, _ fc: @escaping (B, C) -> Kind<F, D>, _ fd: @escaping (B, C, D) -> Kind<F, E>, _ fe: @escaping (B, C, D, E) -> Kind<F, G>, _ fg: @escaping (B, C, D, E, G) -> Kind<F, H>, _ fh: @escaping (B, C, D, E, G, H) -> Kind<F, I>, _ fi: @escaping (B, C, D, E, G, H, I) -> Kind<F, J>) -> Kind<F, J>
-
Undocumented
Declaration
Swift
public static func binding<B, C, D, E, G, H, I, J, K>(_ f: () -> Kind<F, B>, _ fb: @escaping (B) -> Kind<F, C>, _ fc: @escaping (B, C) -> Kind<F, D>, _ fd: @escaping (B, C, D) -> Kind<F, E>, _ fe: @escaping (B, C, D, E) -> Kind<F, G>, _ fg: @escaping (B, C, D, E, G) -> Kind<F, H>, _ fh: @escaping (B, C, D, E, G, H) -> Kind<F, I>, _ fi: @escaping (B, C, D, E, G, H, I) -> Kind<F, J>, _ fj: @escaping (B, C, D, E, G, H, I, J) -> Kind<F, K>) -> Kind<F, K>
-
Undocumented
Declaration
Swift
public func ifM<B>(_ ifTrue: @escaping () -> Kind<F, B>, _ ifFalse: @escaping () -> Kind<F, B>) -> Kind<F, B>
-
Undocumented
Declaration
Swift
public static func unite<G, A>(_ fga: Kind<F, Kind<G, A>>) -> Kind<F, A> where G : Foldable
-
Undocumented
Declaration
Swift
public func ensure(_ error: @escaping () -> F.E, _ predicate: @escaping (A) -> Bool) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public static var empty: Kind<F, A> { get }
-
Undocumented
Declaration
Swift
public static func ask() -> Kind<F, F.D>
-
Undocumented
Declaration
Swift
public func local(_ f: @escaping (F.D) -> F.D) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public static func reader(_ f: @escaping (F.D) -> A) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public static func get() -> Kind<F, F.S>
-
Undocumented
Declaration
Swift
public static func set(_ s: F.S) -> Kind<F, ()>
-
Undocumented
Declaration
Swift
public static func state(_ f: @escaping (F.S) -> (F.S, A)) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public static func modify(_ f: @escaping (F.S) -> F.S) -> Kind<F, ()>
-
Undocumented
Declaration
Swift
public static func inspect(_ f: @escaping (F.S) -> A) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public static func writer(_ aw: (F.W, A)) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func listen() -> Kind<F, (F.W, A)>
-
Undocumented
Declaration
Swift
public static func pass(_ fa: Kind<F, ((F.W) -> F.W, A)>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public static func tell(_ w: F.W) -> Kind<F, ()>
-
Undocumented
Declaration
Swift
public func listens<B>(_ f: @escaping (F.W) -> B) -> Kind<F, (B, A)>
-
Undocumented
Declaration
Swift
public func censor(_ f: @escaping (F.W) -> F.W) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func split() -> (A, Kind<F.G, A>)
-
Undocumented
Declaration
Swift
public func reduceLeftTo<B>(_ f: (A) -> B, _ g: (B, A) -> B) -> B
-
Undocumented
Declaration
Swift
public func reduceMap<B>(_ f: (A) -> B) -> B where B : Semigroup
-
Undocumented
Declaration
Swift
public func reduce() -> A
-
Undocumented
Declaration
Swift
public func combineK(_ y: Kind<F, A>) -> Kind<F, A>
-
Undocumented
Declaration
Swift
public func traverse<G: Applicative, B>(_ f: @escaping (A) -> Kind<G, B>) -> Kind<G, Kind<F, B>>
-
Undocumented
Declaration
Swift
public static func sequence<G>(_ fga: Kind<F, Kind<G, A>>) -> Kind<G, Kind<F, A>> where G : Applicative
-
Undocumented
Declaration
Swift
public func flatTraverse<G: Applicative, B>(_ f: @escaping (A) -> Kind<G, Kind<F, B>>) -> Kind<G, Kind<F, B>>
-
Undocumented
Declaration
Swift
public func traverseFilter<B, G: Applicative>(_ f: @escaping (A) -> Kind<G, OptionOf<B>>) -> Kind<G, Kind<F, B>>
-
Undocumented
Declaration
Swift
public func filterA<G: Applicative>(_ f: @escaping (A) -> Kind<G, Bool>) -> Kind<G, Kind<F, A>>