ComonadStore

public protocol ComonadStore : Comonad

The ComonadStore type class represents those Comonads that support local position information.

  • Type of the position within the ComonadStore

    Declaration

    Swift

    associatedtype S
  • Obtains the current position of the store.

    Declaration

    Swift

    static func position<A>(_ wa: Kind<Self, A>) -> S

    Parameters

    wa

    Value from which the store is retrieved.

    Return Value

    Current position.

  • Obtains the value stored in the provided position.

    Declaration

    Swift

    static func peek<A>(_ wa: Kind<Self, A>, _ s: S) -> A

    Parameters

    wa

    Store.

    s

    Position within the Store.

    Return Value

    Value stored in the provided position.

  • peeks(_:_:) Extension method

    Obtains a value in a position relative to the current position.

    Declaration

    Swift

    static func peeks<A>(_ wa: Kind<Self, A>, _ f: @escaping (S) -> S) -> A

    Parameters

    wa

    Store.

    f

    Function to compute the relative position.

    Return Value

    Value located in a relative position to the current one.

  • seek(_:_:) Extension method

    Moves to a new position.

    Declaration

    Swift

    static func seek<A>(_ wa: Kind<Self, A>, _ s: S) -> Kind<Self, A>

    Parameters

    wa

    Store.

    s

    New position.

    Return Value

    Store focused into the new position.

  • seeks(_:_:) Extension method

    Moves to a new position relative to the current one.

    Declaration

    Swift

    static func seeks<A>(_ wa: Kind<Self, A>, _ f: @escaping (S) -> S) -> Kind<Self, A>

    Parameters

    wa

    Store.

    f

    Function to compute the new position, relative to the current one.

    Return Value

    Store focused into the new position.

  • experiment(_:_:) Extension method

    Extracts a collection of values from positions that depend on the current one.

    Declaration

    Swift

    static func experiment<F: Functor, A>(_ wa: Kind<Self, A>, _ f: @escaping (S) -> Kind<F, S>) -> Kind<F, A>

    Parameters

    wa

    Store.

    f

    Effectful function computing new positions based on the current one.

    Return Value

    A collection of values located a the specified positions.