Tuple2Comonad

Comonad instance for Tuple2 (the environment comonad).

Functions

Link copied to clipboard
open override fun <A> duplicate(v: K1<K1<Tuple2.T, S>, A>): Tuple2<S, K1<K1<Tuple2.T, S>, A>>

Wraps every focus position of v with the whole context focused there.

Link copied to clipboard
open override fun <A, B> extend(f: (K1<K1<Tuple2.T, S>, A>) -> B, v: K1<K1<Tuple2.T, S>, A>): Tuple2<S, B>

Applies a context-consuming function at every position of v.

Link copied to clipboard
open fun <A> extract(v: K1<K1<Tuple2.T, S>, A>): A

Returns the value held by v.

Link copied to clipboard
open fun <A, B> fmap(f: (A) -> B, v: K1<K1<Tuple2.T, S>, A>): Tuple2<S, B>

Applies f to every value inside v.

Link copied to clipboard
open override fun <A, B> imap(f: (A) -> B, g: (B) -> A, v: K1<K1<Tuple2.T, S>, A>): K1<K1<Tuple2.T, S>, B>

Implements Invariant.imap by ignoring the backward function.