Protocols

The following protocols are available globally.

  • Base protocol for optics automatic derivation.

    See more

    Declaration

    Swift

    public protocol AutoOptics
  • At provides a Lens for a this structure to focus at AtFoci at a given index AtIndex.

    See more

    Declaration

    Swift

    public protocol At
  • Cons provides a Prism between this structure and a pair containing its first element and its tail. It provides a convenient way to attach or detach elements to the left side of a structure.

    See more

    Declaration

    Swift

    public protocol Cons
  • Each provides a Traversal that can focus into this structure to see all its foci of type EachFoci.

    See more

    Declaration

    Swift

    public protocol Each
  • FilterIndex provides a Traversal for this structure with all its foci FilterIndexFoci whose index FilterIndexType satisfies a predicate.

    See more

    Declaration

    Swift

    public protocol FilterIndex
  • Index provides an AffineTraversal for this structure to focus on an optional IndexFoci at a given index IndexType.

    See more

    Declaration

    Swift

    public protocol Index
  • Snoc defines a Prism between this structure and its init (all elements but the last one) and last elements. It can be seen as the reverse of Cons. It provides a way to attach or detach elements on the end side of a structure.

    See more

    Declaration

    Swift

    public protocol Snoc
  • A Functor provides a type with the ability to transform its value type into another type, while preserving its structure.

    Using the encoding for HKTs in Bow, in the type Kind<F, A>, A is the value type and F represents the structure of the type. An instance of Functor for F allows to transform A into another type, while maintaining F unchanged.

    See more

    Declaration

    Swift

    public protocol Functor : Invariant
  • Async models how a data type runs an asynchronous computation that may fail, described by the Proc signature.

    See more

    Declaration

    Swift

    public protocol Async : MonadDefer
  • Bracket models a generalized abstracted pattern of safe resource acquisition and release in the face of errors or interruptions.

    See more

    Declaration

    Swift

    public protocol Bracket : MonadError
  • Concurrent describes asynchronous operations that can be started concurrently.

    See more

    Declaration

    Swift

    public protocol Concurrent : Async
  • ConcurrentEffect describes computations that can be cancelled and evaluated concurrently.

    See more

    Declaration

    Swift

    public protocol ConcurrentEffect : Effect
  • Effect is a Monad that can suspend side effects into the context implementing it and supports lazy and potentially asynchronous evaluation.

    See more

    Declaration

    Swift

    public protocol Effect : Async
  • UsafeRun provides capabilities to run a computation unsafely, synchronous or asynchronously.

    See more

    Declaration

    Swift

    public protocol UnsafeRun : MonadError
  • A Comonad is the dual of a Monad. It provides capabilities to compose functions that extract values from their context.

    Implementations of this instance must obey the following laws:

    extract(duplicate(fa)) == fa
    map(fa, f) == coflatMap(fa, { a in f(extract(a)) }
    coflatMap(fa, extract) == fa
    extract(coflatMap(fa, f)) == f(fa)
    
    See more

    Declaration

    Swift

    public protocol Comonad : Functor
  • An Applicative Functor is a Functor that also provides functionality to lift pure expressions, and sequence computations and combine their results.

    Instances of this typeclass must obey the following laws:

    1. Identity

      ap(pure(id), v) == v
      
    2. Composition

      ap(ap(ap(pure(compose), u), v), w) == compose(u, compose(v, w))
      
    3. Homomorphism

      ap(pure(f), pure(x)) == pure(f(x))
      
    4. Interchange

      ap(fa, pure(b)) == ap(pure({ x in x(a) }), fa)
      
    See more

    Declaration

    Swift

    public protocol Applicative : Functor
  • An ApplicativeError is an Applicative that has capabilities to raise and handle error values.

    It has an associated type E to represent the error type that the implementing instance is able to handle.

    See more

    Declaration

    Swift

    public protocol ApplicativeError : Applicative
  • The ComonadEnv type class represents a Comonad that support a global environment that can be provided and transformed into a local environment.

    See more

    Declaration

    Swift

    public protocol ComonadEnv : Comonad
  • The ComonadStore type class represents those Comonads that support local position information.

    See more

    Declaration

    Swift

    public protocol ComonadStore : Comonad
  • The ComonadTraced type class represents those comonads which support relative (monoidal) position information.

    See more

    Declaration

    Swift

    public protocol ComonadTraced : Comonad
  • A Contravariant Functor is the dual of a Covariant Functor, usually referred to as just Functor. Whereas an intuition behind Covariant Functors is that they can be seen as containing or producing values, Contravariant Functors can be seen as consuming values.

    See more

    Declaration

    Swift

    public protocol Contravariant : Invariant
  • Decidable is a typeclass modeling contravariant decision. Decidable is the contravariant version of Alternative.

    See more

    Declaration

    Swift

    public protocol Decidable : Divisible
  • Divide is a type class that models the divide part of divide and conquer.

    See more

    Declaration

    Swift

    public protocol Divide : Contravariant
  • Divisible extends Divide by providing an empty value.

    See more

    Declaration

    Swift

    public protocol Divisible : Divide
  • EquatableK provides capabilities to check equality of values at the kind level.

    See more

    Declaration

    Swift

    public protocol EquatableK
  • Foldable describes types that have the ability to be folded to a summary value.

    See more

    Declaration

    Swift

    public protocol Foldable
  • A FunctorFilter provides the same capabilities as a Functor, while filtering out elements simultaneously.

    See more

    Declaration

    Swift

    public protocol FunctorFilter : Functor
  • EquatableK provides capabilities to compute a hash value at the kind level.

    See more

    Declaration

    Swift

    public protocol HashableK : EquatableK
  • An Invariant Functor provides a type the ability to transform its value type into another type. An instance of Functor or Contravariant are Invariant Functors as well.

    See more

    Declaration

    Swift

    public protocol Invariant
  • A Monad provides functionality to sequence operations that are dependent from one another.

    Instances of Monad must obey the following rules:

    flatMap(pure(a), f) == f(a)
    flatMap(fa, pure) == fa
    flatMap(fa) { a in flatMap(f(a), g) } == flatMap(flatMap(fa, f), g)
    

    Also, instances of Monad derive a default implementation for Applicative.ap as:

    ap(ff, fa) == flapMap(ff, { f in map(fa, f) }
    
    See more

    Declaration

    Swift

    public protocol Monad : Selective
  • A MonadFilter is a Monad with FunctorFilter capabilities. It also provides functionality to create a value that represents an empty element in the context implementing an instance of this typeclass.

    Implementing this typeclass automatically derives an implementation for FunctorFilter.mapFilter.

    See more

    Declaration

    Swift

    public protocol MonadFilter : FunctorFilter, Monad
  • A MonadReader is a Monad with capabilities to read values from a shared environment.

    See more

    Declaration

    Swift

    public protocol MonadReader : Monad
  • A monad transformer makes a new monad out of an existing monad, such that computations of the old monad may be embedded in the new one.

    See more

    Declaration

    Swift

    public protocol MonadTrans : Monad
  • A MonadWriter is a Monad with the ability to produce a stream of data in addition to the computed values.

    See more

    Declaration

    Swift

    public protocol MonadWriter : Monad
  • A monoid is an algebraic structure that has the same properties as a semigroup, with an empty element.

    See more

    Declaration

    Swift

    public protocol Monoid : Semigroup
  • The Monoidal type class adds an identity element to Semigroupal type class by defining the function identity.

    Identity returns a specific identity Kind<F, A> value for a given type F and A.

    This type class complies with the following law: fa.product(identity) == identity.product(fa) == identity

    In addition, the laws of Semigroupal type class also apply.

    See more

    Declaration

    Swift

    public protocol Monoidal : Semigroupal
  • NonEmptyReducible defines a Reducible in terms of another type that has an instance of Foldable and a method that is able to split a structure of values in a first value and the rest of the values in the structure.

    See more

    Declaration

    Swift

    public protocol NonEmptyReducible : Reducible
  • Reducible augments the functions provided by Foldable with reducing functions that do not need an initial value.

    See more

    Declaration

    Swift

    public protocol Reducible : Foldable
  • The Selective typeclass represents Selective Applicative Functors, described in this paper. Selective Applicative Functors enrich Applicative Functors by providing an operation that composes two effectful computations where the second depends on the first.

    See more

    Declaration

    Swift

    public protocol Selective : Applicative
  • A semigroup is an algebraic structure that consists of a set of values and an associative operation.

    See more

    Declaration

    Swift

    public protocol Semigroup
  • The Semigroupal type class for a given type F can be seen as an abstraction over the cartesian product. It defines the function product.

    The product function for a given type F, A and B combines a Kind<F, A> and a Kind<F, B> into a Kind<F, (A, B)>. This function guarantees compliance with the following laws:

    Semigroupals are associative under the bijection f = (a,(b,c)) -> ((a,b),c) or f = ((a,b),c) -> (a,(b,c)). Therefore, the following laws also apply:

    f((a.product(b)).product(c)) == a.product(b.product(c))
    
    f(a.product(b.product(c))) == (a.product(b)).product(c)
    
    See more

    Declaration

    Swift

    public protocol Semigroupal
  • A semiring is an algebraic structure that has the same properties as a commutative monoid for addition, with multiplication.

    See more

    Declaration

    Swift

    public protocol Semiring : Monoid