Protocols

The following protocols are available globally.

  • Undocumented

    See more

    Declaration

    Swift

    public protocol At
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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 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
  • 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
  • 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