ReaderTMonadReader

MonadReader instance for ReaderT.

Properties

Link copied to clipboard
abstract val monad: Monad<F>

The underlying monad.

Functions

Link copied to clipboard
open fun <A, B> ap(f: K1<K2<ReaderT.T, F, R>, (A) -> B>, v: K1<K2<ReaderT.T, F, R>, A>): ReaderT<F, R, B>

Applies the function(s) in f to the value(s) in v, combining both effects.

Link copied to clipboard
open override fun ask(): ReaderT<F, R, R>

Returns the current environment.

Link copied to clipboard
open fun <A, B> bind(f: (A) -> K1<K2<ReaderT.T, F, R>, B>, v: K1<K2<ReaderT.T, F, R>, A>): ReaderT<F, R, B>

Sequentially composes v with f, feeding each result of v to f (a.k.a. flatMap / >>=).

Link copied to clipboard
open fun <A, B> fmap(f: (A) -> B, v: K1<K2<ReaderT.T, F, R>, A>): ReaderT<F, R, B>

Applies f to every value inside v.

Link copied to clipboard
fun <T, A> Monad<T>.fx(block: suspend MonadScope<T>.() -> A): K1<T, A>

Do-notation for monads that call the continuation passed to bind at most once per run. Each run of the resulting value starts a fresh coroutine, so lazy monads can be run repeatedly.

Link copied to clipboard
fun <T, A> Monad<T>.fxReplay(block: suspend MonadScope<T>.() -> A): K1<T, A>

Do-notation for any monad, including those that call the continuation passed to bind several times. The block is re-run from the start for every bound value, so code between binds may run multiple times.

Link copied to clipboard
open override fun <A, B> imap(f: (A) -> B, g: (B) -> A, v: K1<K2<ReaderT.T, F, R>, A>): K1<K2<ReaderT.T, F, R>, B>

Implements Invariant.imap by ignoring the backward function.

Link copied to clipboard
open fun <A> join(v: K1<K2<ReaderT.T, F, R>, K1<K2<ReaderT.T, F, R>, A>>): ReaderT<F, R, A>

Flattens one level of nesting.

Link copied to clipboard
open override fun <A> local(f: (R) -> R, v: K1<K2<ReaderT.T, F, R>, A>): ReaderT<F, R, A>

Runs v with the environment modified by f.

Link copied to clipboard
open fun <A> pure(v: A): ReaderT<F, R, A>

Wraps v in the minimal context.

Link copied to clipboard
open fun <A> reader(f: (R) -> A): K1<K2<ReaderT.T, F, R>, A>

Returns a projection of the environment.