CoT

public class CoT<W, M, A> : CoTOf<W, M, A> where W : Comonad

CoT gives you the best pairing monad transformer for any Comonad W In other words, an explorer for the state space given by W. It can also provide: - A MonadReader from a ComonadEnv - A MonadWriter from a ComonadTraced - A MonadState from a ComonadStore

  • Safe downcast.

    Declaration

    Swift

    public static func fix(_ value: CoTOf<W, M, A>) -> CoT<W, M, A>

    Parameters

    value

    Value in the higher-kind form.

    Return Value

    Value cast to CoT.

  • Lifts a comonadic query into a CoT.

    The original signature of this function is: (forall s. w s -> a) -> CoT w m a

    Declaration

    Swift

    public static func liftT(_ f: @escaping (Kind<W, Any/*S*/>) -> A) -> CoT<W, M, A>

    Parameters

    f

    Comonadic query.

    Return Value

    A CoT from the Comonadic query.

  • Initializes a CoT. It embeds a function with the signature: forall r. w (a -> m r) -> m r

    Declaration

    Swift

    public init(_ cow: @escaping /*forall R.*/(Kind<W, (A) -> Kind<M, /*R*/Any>>) -> Kind<M, /*R*/Any>)

    Parameters

    cow

    Inner function of this CoT.

  • Runs the inner function.

    Declaration

    Swift

    public func runT<R>(_ w: Kind<W, (A) -> Kind<M, R>>) -> Kind<M, R>

    Parameters

    w

    Argument for the inner function.

    Return Value

    Value in the base Monad context.

  • Performs a natural transformation on the Comonad of this CoT.

    Declaration

    Swift

    public func hoistT<V>(_ transform: FunctionK<V, W>) -> CoT<V, M, A> where V : Comonad

    Parameters

    transform

    Natural transformation.

    Return Value

    A new CoT with the transformed Comonad.

  • Runs the inner function with a value that does not runs on the base Monad.

    Declaration

    Swift

    func lowerT<B>(_ input: Kind<W, B>) -> Kind<M, A>

    Parameters

    input

    A value in the Comonad context.

    Return Value

    A value in the base Monad context.

  • Explores the space of a Comonad with a given Monad.

    Declaration

    Swift

    static func select<A, B>(
        _ co: Co<W, (A) -> B>,
        _ wa: Kind<W, A>) -> Kind<W, B>

    Parameters

    co

    Monadic actions to explore the Comonad.

    wa

    Comonadic space to explore.

    Return Value

    A new Comonadic space resulting from the exploration.

  • Lifts a comonadic query into a CoT.

    The original signature of this function is: (forall s. w s -> a) -> Co w a

    Declaration

    Swift

    static func lift(_ f: @escaping (Kind<W, Any>) -> A) -> Co<W, A>

    Parameters

    f

    Comonadic query.

    Return Value

    A Co from the Comonadic query.

  • Obtains a Pairing between a Comonad and its dual Monad.

    Declaration

    Swift

    static func pair() -> Pairing<W, CoPartial<W>>

    Return Value

    The pairing between the underlying comonad, W, and the monad Co<w>.

  • Runs the inner function.

    Declaration

    Swift

    func run<R>(_ w: Kind<W, (A) -> R>) -> R

    Parameters

    w

    Argument for the inner function.

    Return Value

    A plain value.

  • Performs a natural transformation on the Comonad of this Co.

    Declaration

    Swift

    func hoist<V>(_ transform: FunctionK<V, W>) -> Co<V, A> where V : Comonad

    Parameters

    transform

    Natural transformation.

    Return Value

    A new Co with the transformed Comonad.

  • Runs the inner function with a value that does not runs on the base Monad.

    Declaration

    Swift

    func lower<B>(_ input: Kind<W, B>) -> A

    Parameters

    input

    A value in the Comonad context.

    Return Value

    A plain value.