arrow-streams / arrow.streams.internal / FreeC

FreeC

sealed class FreeC<F, out R> : FreeCOf<F, R>

Free Monad with Catch (and Interruption).

FreeC provides mechanism for ensuring stack safety and capturing any exceptions that may arise during computation.

Furthermore, it may capture Interruption of the evaluation, although FreeC itself does not have any interruptible behaviour per se.

Interruption cause may be captured in FreeC.Interrupted and allows user to pass along any information relevant to interpreter.

Typically the FreeC user provides interpretation of FreeC in form of ViewL structure through the ViewL.fold function, that allows to step FreeC via series of Results (FreeC.Pure, FreeC.Fail and FreeC.Interrupted) and FreeC step (ViewL.View).

Types

Result interface Result<out R>
Emulated sealed trait. Never extend this interface! **Working with FreeC.Result must be done using Result.fold **

Properties

viewL val viewL: ViewL<F, R>

Functions

asHandler fun asHandler(e: Throwable): FreeC<F, R>
flatMap fun <R2> flatMap(f: (R) -> FreeCOf<F, R2>): FreeC<F, R2>
map fun <R2> map(f: (R) -> R2): FreeC<F, R2>
toString open fun toString(): String
translate open fun <G> translate(f: FunctionK<F, G>): FreeC<G, R>

Companion Object Functions

defer fun <F, R> defer(fr: () -> FreeCOf<F, R>): FreeC<F, R>
functionKF fun <F> functionKF(): FunctionK<F, FreeCPartialOf<F>>
interrupted fun <F, A, X> interrupted(interruptContext: X, failure: Option<Throwable>): FreeC<F, A>
just fun <F, R> just(r: R): FreeC<F, R>
liftF fun <F, A> liftF(f: Kind<F, A>): FreeC<F, A>
pureContinuation fun <F, R> pureContinuation(): (Result<R>) -> FreeC<F, R>
raiseError fun <F, R> raiseError(error: Throwable): FreeC<F, R>
tailRecM fun <F, A, B> tailRecM(a: A, f: (A) -> FreeC<F, Either<A, B>>): FreeC<F, B>
unit fun <F> unit(): FreeC<F, Unit>

Extension Functions

ap fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.ap(arg1: Kind<Kind<ForFreeC, F>, (A) -> B>): FreeC<F, B>
ap fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.ap(arg1: Kind<Kind<ForFreeC, F>, (A) -> B>): FreeC<F, B>
ap fun <F, A, B> FreeCOf<F, A>.ap(ff: Kind<FreeCPartialOf<F>, (A) -> B>): Kind<FreeCPartialOf<F>, B>
Given a function ff in the context of FreeC, applies the function.
as fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.as(arg1: B): FreeC<F, B>
attempt fun <F, A> Kind<Kind<ForFreeC, F>, A>.attempt(): FreeC<F, Either<Throwable, A>>
bracket fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.bracket(arg1: (A) -> Kind<Kind<ForFreeC, F>, Unit>, arg2: (A) -> Kind<Kind<ForFreeC, F>, B>): FreeC<F, B>
bracketCase fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.bracketCase(arg1: (A, ExitCase<Throwable>) -> Kind<Kind<ForFreeC, F>, Unit>, arg2: (A) -> Kind<Kind<ForFreeC, F>, B>): FreeC<F, B>
bracketCase fun <F, A, B> FreeCOf<F, A>.bracketCase(use: (A) -> FreeCOf<F, B>, release: (A, ExitCase<Throwable>) -> FreeCOf<F, Unit>): FreeC<F, B>
effectM fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.effectM(arg1: (A) -> Kind<Kind<ForFreeC, F>, B>): FreeC<F, A>
ensure fun <F, A> Kind<Kind<ForFreeC, F>, A>.ensure(arg1: () -> Throwable, arg2: (A) -> Boolean): FreeC<F, A>
eqv fun <F, G, A> Kind<Kind<ForFreeC, F>, A>.eqv(ME: MonadError<G, Throwable>, FK: FunctionK<F, G>, EQFA: Eq<Kind<G, Option<A>>>, arg1: Kind<Kind<ForFreeC, F>, A>): Boolean
fix fun <F, R> FreeCOf<F, R>.fix(): FreeC<F, R>
flatMap fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.flatMap(arg1: (A) -> Kind<Kind<ForFreeC, F>, B>): FreeC<F, B>
fold fun <F, R, A> FreeC<F, R>.fold(pure: (R) -> A, fail: (Throwable) -> A, interrupted: (Any?, Option<Throwable>) -> A, eval: (Kind<F, R>) -> A, bind: (FreeC<F, Any?>, (Result<Any?>) -> FreeCOf<F, R>) -> A): A
foldMap fun <M, S, A> FreeCOf<S, A>.foldMap(f: FunctionK<S, M>, MM: MonadError<M, Throwable>): Kind<M, Option<A>>
Catamorphism for FreeC.
followedBy fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.followedBy(arg1: Kind<Kind<ForFreeC, F>, B>): FreeC<F, B>
followedByEval fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.followedByEval(arg1: Eval<Kind<Kind<ForFreeC, F>, B>>): FreeC<F, B>
forEffect fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.forEffect(arg1: Kind<Kind<ForFreeC, F>, B>): FreeC<F, A>
forEffectEval fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.forEffectEval(arg1: Eval<Kind<Kind<ForFreeC, F>, B>>): FreeC<F, A>
fproduct fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.fproduct(arg1: (A) -> B): FreeC<F, Tuple2<A, B>>
fromOption fun <F, A> Kind<ForOption, A>.fromOption(arg1: () -> Throwable): FreeC<F, A>
fromTry fun <F, A> Kind<ForTry, A>.fromTry(arg1: (Throwable) -> Throwable): FreeC<F, A>
guarantee fun <F, A> Kind<Kind<ForFreeC, F>, A>.guarantee(arg1: Kind<Kind<ForFreeC, F>, Unit>): FreeC<F, A>
guaranteeCase fun <F, A> Kind<Kind<ForFreeC, F>, A>.guaranteeCase(arg1: (ExitCase<Throwable>) -> Kind<Kind<ForFreeC, F>, Unit>): FreeC<F, A>
handleError fun <F, A> Kind<Kind<ForFreeC, F>, A>.handleError(arg1: (Throwable) -> A): FreeC<F, A>
handleErrorWith fun <F, A> Kind<Kind<ForFreeC, F>, A>.handleErrorWith(arg1: (Throwable) -> Kind<Kind<ForFreeC, F>, A>): FreeC<F, A>
handleErrorWith fun <F, R> FreeCOf<F, R>.handleErrorWith(h: (Throwable) -> FreeCOf<F, R>): FreeC<F, R>
Handle any error, potentially recovering from it, by mapping it to a FreeCOf value by h.
imap fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.imap(arg1: (A) -> B, arg2: (B) -> A): FreeC<F, B>
map fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.map(arg1: (A) -> B): FreeC<F, B>
map fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.map(arg1: (A) -> B): FreeC<F, B>
map fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.map(arg1: (A) -> B): FreeC<F, B>
map2 fun <F, A, B, Z> Kind<Kind<ForFreeC, F>, A>.map2(arg1: Kind<Kind<ForFreeC, F>, B>, arg2: (Tuple2<A, B>) -> Z): FreeC<F, Z>
map2Eval fun <F, A, B, Z> Kind<Kind<ForFreeC, F>, A>.map2Eval(arg1: Eval<Kind<Kind<ForFreeC, F>, B>>, arg2: (Tuple2<A, B>) -> Z): Eval<Kind<Kind<ForFreeC, F>, Z>>
mproduct fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.mproduct(arg1: (A) -> Kind<Kind<ForFreeC, F>, B>): FreeC<F, Tuple2<A, B>>
neqv fun <F, G, A> Kind<Kind<ForFreeC, F>, A>.neqv(ME: MonadError<G, Throwable>, FK: FunctionK<F, G>, EQFA: Eq<Kind<G, Option<A>>>, arg1: Kind<Kind<ForFreeC, F>, A>): Boolean
product fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.product(arg1: Kind<Kind<ForFreeC, F>, B>): FreeC<F, Tuple2<A, B>>
run fun <F, R> FreeCOf<F, R>.run(ME: MonadError<F, Throwable>): Kind<F, Option<R>>
Runs a FreeC structure with MonadError in context of F.
step tailrec fun <S, A> FreeC<S, A>.step(): FreeC<S, A>
Takes one evaluation step in the Free monad, re-associating left-nested binds in the process.
transform fun <F, G, A, B> FreeCOf<F, A>.transform(f: (A) -> B, fs: FunctionK<F, G>): FreeC<G, B>
Transform both the context F and value A.
transformWith fun <F, R, R2> FreeCOf<F, R>.transformWith(f: (Result<R>) -> FreeC<F, R2>): FreeC<F, R2>
Transform FreeC while being able to inspect the Result type.
tupleLeft fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.tupleLeft(arg1: B): FreeC<F, Tuple2<B, A>>
tupleRight fun <F, A, B> Kind<Kind<ForFreeC, F>, A>.tupleRight(arg1: B): FreeC<F, Tuple2<A, B>>
uncancelable fun <F, A> Kind<Kind<ForFreeC, F>, A>.uncancelable(): FreeC<F, A>
unit fun <F, A> Kind<Kind<ForFreeC, F>, A>.unit(): FreeC<F, Unit>
widen fun <F, B, A : B> Kind<Kind<ForFreeC, F>, A>.widen(): FreeC<F, B>

Companion Object Extension Functions

applicative fun <F> FreeC.Companion.applicative(): FreeCApplicative<F>
applicativeError fun <F> FreeC.Companion.applicativeError(): FreeCApplicativeError<F>
bracket fun <F> FreeC.Companion.bracket(): FreeCBracket<F>
eq fun <F, G, A> FreeC.Companion.eq(ME: MonadError<G, Throwable>, FK: FunctionK<F, G>, EQFA: Eq<Kind<G, Option<A>>>): FreeCEq<F, G, A>
functor fun <F> FreeC.Companion.functor(): FreeCFunctor<F>
monad fun <F> FreeC.Companion.monad(): FreeCMonad<F>
monadDefer fun <F> FreeC.Companion.monadDefer(): FreeCMonadDefer<F>
monadError fun <F> FreeC.Companion.monadError(): FreeCMonadError<F>