ComonadEnv

public protocol ComonadEnv : Comonad

The ComonadEnv type class represents a Comonad that support a global environment that can be provided and transformed into a local environment.

  • Type of the associated environment

    Declaration

    Swift

    associatedtype E
  • Gets the underlying global environment from the provided value.

    Declaration

    Swift

    static func ask<A>(_ wa: Kind<Self, A>) -> E

    Parameters

    wa

    Value to obtain the environment from.

    Return Value

    Global environment.

  • Transforms the environment into a local one.

    Declaration

    Swift

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

    Parameters

    wa

    Value containing the environment.

    f

    Transforming function.

    Return Value

    A value with the transformed environment.

  • asks(_:_:) Extension method

    Obtains a value that depends on the environment.

    Declaration

    Swift

    static func asks<A, EE>(_ wa: Kind<Self, A>, _ f: @escaping (E) -> EE) -> EE

    Parameters

    wa

    Value containing the environment.

    f

    Function to obtain a value from the environment.

    Return Value

    A value that depends on the environment.