package eff
- Alphabetic
- By Inheritance
- eff
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- type /=[M[_], R] = MemberInOut[M, R]
- type <=[M[_], R] = Member[M, R]
-
case class
Arrs
[R, A, B](functions: Vector[(Any) ⇒ Eff[R, Any]]) extends (A) ⇒ Eff[R, B] with Product with Serializable
Sequence of monadic functions from A to B: A => Eff[B]
Sequence of monadic functions from A to B: A => Eff[B]
Internally it is represented as a Vector of functions:
A => Eff[R, X1]; X1 => Eff[R, X2]; X2 => Eff[R, X3]; ...; X3 => Eff[R, B]
- sealed trait Async [A] extends Any
- trait AsyncCreation extends AnyRef
- case class AsyncDelayed [A](a: Eval[A], timeout: Option[FiniteDuration] = None) extends Async[A] with Product with Serializable
- case class AsyncEff [A](e: Eff[FS, A], timeout: Option[FiniteDuration] = None) extends Async[A] with Product with Serializable
- trait AsyncEffect extends AsyncCreation
- case class AsyncFailed [A](t: Throwable) extends Async[A] with Product with Serializable
- case class AsyncFutureInterpreter (executors: ExecutorServices) extends AsyncInterpreter[Future] with Product with Serializable
- trait AsyncInterpretation extends AnyRef
- trait AsyncInterpreter [F[_]] extends AnyRef
- case class AsyncNow [A](a: A) extends Async[A] with Product with Serializable
- final class AttemptOps [R, A] extends AnyVal
- trait Augment [T[_], O[_]] extends AnyRef
-
trait
Batch
extends AnyRef
This trait provides a way to rewrite applicative effects when there is an operation allowing the batching of some effects based on the Batchable typeclass
- trait Batchable [T[_]] extends AnyRef
- sealed trait Choose [T] extends AnyRef
- trait ChooseCreation extends AnyRef
-
trait
ChooseEffect
extends ChooseCreation with ChooseInterpretation
The Choose effect models non-determinism So we can get results, either:
The Choose effect models non-determinism So we can get results, either:
- no results (when using ChooseZero)
- the result for action1 or the result for action b (when using ChoosePlus)
When running this effect we can "collect" the results with any F which has an Alternative instance.
For example if F is List then:
- no results is the empty list
- the result for a or b is List(a, b)
If F is Option then:
- no results is the None
- the result for a or b is Some(a) or Some(b
- trait ChooseImplicits extends AnyRef
- trait ChooseInterpretation extends AnyRef
- case class ChooseZero [T]() extends Choose[T] with Product with Serializable
-
case class
CollectedUnions
[M[_], R, U](effects: List[M[Any]], otherEffects: List[Union[U, Any]], indices: List[Int], otherIndices: List[Int]) extends Product with Serializable
Collection of effects of a given type from a Unions objects
- case class Correct [E]() extends Validate[E, Unit] with Product with Serializable
-
sealed
trait
Eff
[R, A] extends AnyRef
Effects of type R, returning a value of type A
Effects of type R, returning a value of type A
It is implemented as a "Free-er" monad with extensible effects:
- the "pure" case is a pure value of type A
- the "impure" case is:
- a disjoint union of possible effects
- a continuation of type X => Eff[R, A] indicating what to do if the current effect is of type M[X]
this type is represented by the
Arrstype
- the "impure applicative" case is:
- list of disjoint unions of possible effects
- a function to apply to the values resulting from those effects
The monad implementation for this type is really simple:
pointis Purebindsimply appends the binding function to theArrscontinuation
Important:
The list of continuations is NOT implemented as a type sequence but simply as a Vector[Any => Eff[R, Any]]
This means that various
.asInstanceOfare present in the implementation and could lead to burns and severe harm. Use with caution!Similarly the list of effects in the applicative case is untyped and interpreters for those effects are supposed to create a list of values to feed the mapping function. If an interpreter doesn't create a list of values of the right size and with the right types, there will be a runtime exception.
The Pure, Impure and ImpureAp cases also incorporate a "last" action returning no value but just used for side-effects (shutting down an execution context for example). This action is meant to be executed at the end of all computations, regardless of the number of flatMaps added on the Eff value.
Since this last action will be executed, its value never collected so if it throws an exception it is possible to print it by defining the eff.debuglast system property (-Deff.debuglast=true)
- See also
http://okmij.org/ftp/Haskell/extensible/more.pdf
- trait EffCreation extends AnyRef
- trait EffImplicits extends AnyRef
- trait EffInterpretation extends AnyRef
-
sealed
trait
Effect
[F[_]] extends AnyRef
one effect, basically a type constructor
- trait EitherCreation extends AnyRef
-
trait
EitherEffect
extends EitherCreation with EitherInterpretation
Effect for computation which can fail
- trait EitherImplicits extends AnyRef
- trait EitherInterpretation extends AnyRef
- trait ErrorCreation [F] extends ErrorTypes[F]
-
trait
ErrorEffect
[F] extends ErrorCreation[F] with ErrorInterpretation[F]
Effect for computation which can fail and return a Throwable, or just stop with a failure
Effect for computation which can fail and return a Throwable, or just stop with a failure
This effect is a mix of Eval and Either in the sense that every computation passed to this effect (with the ok method) is considered "impure" or "faulty" by default.
The type F is used to represent the failure type.
- trait ErrorInterpretation [F] extends ErrorCreation[F]
- trait ErrorTypes [F] extends AnyRef
- trait EvalCreation extends EvalTypes
-
trait
EvalEffect
extends EvalTypes with EvalCreation with EvalInterpretation
Effect for delayed computations
Effect for delayed computations
uses cats.Eval as a supporting data structure
- trait EvalInterpretation extends EvalTypes
- trait EvalTypes extends AnyRef
- case class Evaluate [F, A](run: Either[Either[Throwable, F], Eval[A]]) extends Product with Serializable
- case class EvaluateValue [A](a: Eval[A]) extends Safe[A] with Product with Serializable
- case class ExecutorServices (executorServiceEval: Eval[ExecutorService], scheduledExecutorEval: Eval[ScheduledExecutorService], executionContextEval: Eval[ExecutionContext]) extends Product with Serializable
- case class FailedFinalizer (t: Throwable) extends Safe[Unit] with Product with Serializable
- case class FailedValue [A](t: Throwable) extends Safe[A] with Product with Serializable
-
sealed
trait
Fx
extends AnyRef
Base type for a tree of effect types
- final case class Fx1 [F[_]](e: Effect[F]) extends Fx with Product with Serializable
- final case class Fx2 [L[_], R[_]](left: Effect[L], right: Effect[R]) extends Fx with Product with Serializable
- final case class Fx3 [L[_], M[_], R[_]](left: Effect[L], middle: Effect[M], right: Effect[R]) extends Fx with Product with Serializable
-
final
case class
FxAppend
[L, R](left: L, right: R) extends Fx with Product with Serializable
Append a tree of effects to another one
-
case class
Impure
[R, X, A](union: Union[R, X], continuation: Arrs[R, X, A], last: Last[R] = Last.none[R]) extends Eff[R, A] with Product with Serializable
Impure is an effect (encoded as one possibility among other effects, a Union) and a continuation providing the next Eff value.
Impure is an effect (encoded as one possibility among other effects, a Union) and a continuation providing the next Eff value.
This essentially models a flatMap operation with the current effect and the monadic function to apply to a value once the effect is interpreted
One effect can always be executed last, just for side-effects
-
case class
ImpureAp
[R, X, A](unions: Unions[R, X], continuation: Arrs[R, List[Any], A], last: Last[R] = Last.none[R]) extends Eff[R, A] with Product with Serializable
ImpureAp is a list of independent effects and a pure function creating a value with all the resulting values once all effects have been interpreted.
ImpureAp is a list of independent effects and a pure function creating a value with all the resulting values once all effects have been interpreted.
This essentially models a sequence + map operation but it is important to understand that the list of Union objects can represent different effects and be like: List[Option[Int], Future[String], Option[Int]].
Interpreting such an Eff value for a given effect (say Option) consists in:
- grouping all the Option values,
- sequencing them
- pass them to a continuation which will apply the 'map' functions when the other effects (Future in the example above) will have been interpreted
VERY IMPORTANT:
- this object is highly unsafe
- the size of the list argument to 'map' must always be equal to the number of unions in the Unions object
- the types of the elements in the list argument to 'map' must be the exact types of each effect in unions.unions
-
trait
Interpret
extends AnyRef
Support methods to create interpreters (or "effect handlers") for a given effect M and a value Eff[R, A] when M is a member of R.
Support methods to create interpreters (or "effect handlers") for a given effect M and a value Eff[R, A] when M is a member of R.
Those methods guarantee a stack-safe behaviour when running on a large list of effects (in list.traverse(f) for example).
There are different types of supported interpreters:
- "interpret" + Recurse
This interpreter is used to handle effects which either return a value X from M[X] or stops with Eff[R, B] See an example of such an interpreter in Eval where we just evaluate a computation X for each Eval[X].
2. "interpretState" + StateRecurse
This interpreter is used to handle effects which either return a value X from M[X] or stops with Eff[R, B]
3. "interpretLoop" + Loop
The most generic kind of interpreter where we can even recurse in the case of Pure(a) (See ListEffect for such a use)
4. "intercept / interceptState / interceptLoop" methods are similar but they transform an effect to other effects in the same stack without removing it from the stack
5. "transform" to swap an effect T of a stack to another effect, using a Natural Transformation
6. "translate" to interpret one effect of a stack into other effects of the same stack using a Natural Transformation this is a specialized version of interpret + Recurse
7. "interpretUnsafe + SideEffect" when you have a side effecting function M[X] => X
-
trait
IntoPoly
[R, U] extends AnyRef
Typeclass proving that it is possible to send a tree of effects R into another tree of effects U
Typeclass proving that it is possible to send a tree of effects R into another tree of effects U
for example
send[Option1, Fx.fx3[Option1, Option2, Option3], Int](Option1(1)). into[Fx.fx5[Option1, Option2, Option3, Option4, Option5]]
should work because all the effects of the first stack are present in the second
Note: some implicit definitions are probably missing in some cases
- trait IntoPolyLower1 extends IntoPolyLower2
- trait IntoPolyLower2 extends IntoPolyLower3
- trait IntoPolyLower3 extends IntoPolyLower4
- trait IntoPolyLower4 extends IntoPolyLower5
- trait IntoPolyLower5 extends AnyRef
-
case class
Last
[R](value: Option[Eval[Eff[R, Unit]]]) extends Product with Serializable
Encapsulation of one optional last action to execute at the end of the program
-
trait
LeftFold
[A, B] extends AnyRef
support trait for folding values while possibly keeping some internal state
- trait ListCreation extends AnyRef
-
trait
ListEffect
extends ListCreation with ListInterpretation
Effect for computations possibly returning several values
- trait ListInterpretation extends AnyRef
-
trait
Loop
[M[_], R, A, B, C] extends AnyRef
Generalisation of Recurse and StateRecurse
Generalisation of Recurse and StateRecurse
The loop defines some state with an initial value which is maintained at each step of the interpretation.
A is the type of Eff values to interpret, and B is the result of the interpretation (generally an other Eff value)
C is the type of result for "last" actions.
- the interpretation of a Pure value either returns the final result or possibly one more Eff value to interpret
- onEffect interprets one effect and possibly uses the continuation to produce the next value to interpret. If no X can be used to run the continuation we might just output one final B value
- onLastEffect interprets the last effect of an Eff value. The only difference with onEffect is the fact that last actions return Unit values (and not A values)
- onApplicativeEff interprets a list of effects and possibly uses the continuation to get to the next value to interpret. If no interpretation can be done, a B value might be returned
- onLastApplicativeEffect does the same thing for last actions
-
trait
Member
[T[_], R] extends MemberInOut[T, R]
- Annotations
- @implicitNotFound( ... )
-
trait
MemberIn
[T[_], R] extends AnyRef
- Annotations
- @implicitNotFound( ... )
- trait MemberInLower1 extends MemberInLower2
- trait MemberInLower2 extends MemberInLower3
- trait MemberInLower3 extends MemberInLower4
- trait MemberInLower4 extends MemberInLower5
- trait MemberInLower5 extends AnyRef
-
trait
MemberInOut
[T[_], R] extends MemberIn[T, R]
- Annotations
- @implicitNotFound( ... )
- trait MemberInOutLower1 extends MemberInOutLower2
- trait MemberInOutLower2 extends MemberInOutLower3
- trait MemberInOutLower3 extends MemberInOutLower4
- trait MemberInOutLower4 extends MemberInOutLower5
- trait MemberInOutLower5 extends AnyRef
- trait MemberLower1 extends MemberLower2
- trait MemberLower10 extends MemberLower11
- trait MemberLower11 extends MemberLower12
- trait MemberLower12 extends MemberLower13
- trait MemberLower13 extends MemberLower14
- trait MemberLower14 extends MemberLower15
- trait MemberLower15 extends MemberLower16
- trait MemberLower16 extends MemberLower17
- trait MemberLower17 extends MemberLower18
- trait MemberLower18 extends MemberLower19
- trait MemberLower19 extends AnyRef
- trait MemberLower2 extends MemberLower3
- trait MemberLower3 extends MemberLower4
- trait MemberLower4 extends MemberLower5
- trait MemberLower5 extends MemberLower6
- trait MemberLower6 extends MemberLower7
- trait MemberLower7 extends MemberLower8
- trait MemberLower8 extends MemberLower9
- trait MemberLower9 extends MemberLower10
-
class
NoFx
extends Fx
The "empty" tree of effects
- trait OptionCreation extends AnyRef
-
trait
OptionEffect
extends OptionCreation with OptionInterpretation
Effect for optional computations
- trait OptionInterpretation extends AnyRef
- case class Pure [R, A](value: A, last: Last[R] = Last.none[R]) extends Eff[R, A] with Product with Serializable
-
case class
Rand
[A](run: (Random) ⇒ Option[A]) extends Product with Serializable
This class can be used as a F in runChoose to generate random alternatives
- trait ReaderCreation extends AnyRef
-
trait
ReaderEffect
extends ReaderCreation with ReaderInterpretation
Effect for computations depending on an environment.
Effect for computations depending on an environment.
The inside datatype for this effect is cats.data.Reader
- trait ReaderInterpretation extends AnyRef
-
trait
Recurse
[M[_], R, A] extends AnyRef
Helper trait for computations which might produce several M[X] in a stack of effects.
Helper trait for computations which might produce several M[X] in a stack of effects.
Either we can produce an X to pass to a continuation or we're done
For the applicative case we expect to be able to traverse a list of effects and return an effect of a list of results OR completely consume the effect and return a pure list of values
-
sealed
trait
Safe
[A] extends AnyRef
The Safe type is a mix of a ThrowableEither / Eval effect and a writer effect to collect finalizer failures
- trait SafeCreation extends SafeTypes
- trait SafeEffect extends SafeCreation with SafeInterpretation
- trait SafeInterpretation extends SafeCreation
- trait SafeTypes extends AnyRef
- trait SideEffect [T[_]] extends AnyRef
- trait StateCreation extends AnyRef
-
trait
StateEffect
extends StateCreation with StateInterpretation
Effect for passing state along computations
Effect for passing state along computations
Internally backed up by cats.data.State
- trait StateImplicits extends AnyRef
- trait StateInterpretation extends AnyRef
-
trait
StatelessLoop
[M[_], R, A, B, C] extends AnyRef
Generalisation of Recurse
-
trait
Translate
[T[_], U] extends AnyRef
trait for translating one effect into other ones in the same stack
-
sealed
trait
Union
[+R, A] extends AnyRef
Union represents one effect T[_] embedded in a tree of possible effects R
Union represents one effect T[_] embedded in a tree of possible effects R
Since the effect tree is represented with the following cases:
- Fx1[T]
- Fx2[T1, T2]
- Fx3[T1, T2, T3]
- FxAppend[L, R]
We have the corresponding Union cases. For example T2 is in the "middle" of Fx3[T1, T2, T3] so creating a Union object for that effect uses Union3M
- case class Union1 [T[_], A](ta: T[A]) extends Union[Fx1[T], A] with Product with Serializable
- sealed trait Union2 [R, A] extends Union[R, A]
- case class Union2L [L[_], R[_], A](t: L[A]) extends Union2[Fx2[L, R], A] with Product with Serializable
- case class Union2R [L[_], R[_], A](t: R[A]) extends Union2[Fx2[L, R], A] with Product with Serializable
- sealed trait Union3 [R, A] extends Union[R, A]
- case class Union3L [L[_], M[_], R[_], A](t: L[A]) extends Union3[Fx3[L, M, R], A] with Product with Serializable
- case class Union3M [L[_], M[_], R[_], A](t: M[A]) extends Union3[Fx3[L, M, R], A] with Product with Serializable
- case class Union3R [L[_], M[_], R[_], A](t: R[A]) extends Union3[Fx3[L, M, R], A] with Product with Serializable
- sealed trait UnionAppend [R, A] extends Union[R, A]
- case class UnionAppendL [L, R, A](t: Union[L, A]) extends UnionAppend[FxAppend[L, R], A] with Product with Serializable
- case class UnionAppendR [L, R, A](t: Union[R, A]) extends UnionAppend[FxAppend[L, R], A] with Product with Serializable
- trait UnionInto [R, S] extends AnyRef
-
case class
Unions
[R, A](first: Union[R, A], rest: List[Union[R, Any]]) extends Product with Serializable
A non-empty list of Unions.
A non-empty list of Unions.
It is only partially typed, we just keep track of the type of the first object
- sealed trait Validate [+E, A] extends AnyRef
- trait ValidateCreation extends AnyRef
-
trait
ValidateEffect
extends ValidateCreation with ValidateInterpretation
Effect for computation which can fail but will accumulate errors
Effect for computation which can fail but will accumulate errors
The runValidate interpreter just collects the messages and returns them at the end
- trait ValidateInterpretation extends ValidateCreation
- trait Write [T[_], O] extends AnyRef
- trait WriterCreation extends AnyRef
-
trait
WriterEffect
extends WriterCreation with WriterInterpretation
Effect for logging values alongside computations
Effect for logging values alongside computations
Compared to traditional Writer monad which accumulates values by default this effect can be interpreted in different ways:
- log values to the console or to a file as soon as they are produced
- accumulate values in a list
- trait WriterInterpretation extends AnyRef
- case class Wrong [E](e: E) extends Validate[E, Unit] with Product with Serializable
- type |=[M[_], R] = MemberIn[M, R]
Value Members
- object Arrs extends Serializable
- object Async
- object AsyncCreation extends AsyncCreation
- object AsyncEffect extends AsyncEffect
- object AsyncFutureInterpreter extends Serializable
- object AsyncInterpretation extends AsyncInterpretation
- object Batch extends Batch
- object ChooseCreation extends ChooseCreation
- object ChooseEffect extends ChooseEffect
- object ChooseImplicits extends ChooseImplicits
- object ChooseInterpretation extends ChooseInterpretation
- object ChoosePlus extends Choose[Boolean] with Product with Serializable
- object Eff extends EffCreation with EffInterpretation with EffImplicits
- object EffCreation extends EffCreation
- object EffImplicits extends EffImplicits
- object EffInterpretation extends EffInterpretation
- object EitherCreation extends EitherCreation
- object EitherEffect extends EitherEffect
- object EitherImplicits extends EitherImplicits
- object EitherInterpretation extends EitherInterpretation
-
object
ErrorEffect
extends ErrorEffect[String]
Simple instantiation of the ErrorEffect trait with String as a Failure type
- object EvalEffect extends EvalEffect
- object EvalInterpretation extends EvalInterpretation
- object EvalTypes extends EvalTypes
- object Evaluate extends Serializable
- object ExecutorServices extends Serializable
- object Fx
- object Interpret extends Interpret
- object IntoPoly extends IntoPolyLower1
- object Last extends Serializable
- object ListCreation extends ListCreation
- object ListEffect extends ListEffect
- object ListInterpretation extends ListInterpretation
- object Member extends MemberLower1
- object MemberIn extends MemberInLower1
- object MemberInOut extends MemberInOutLower1
- object NoFx extends NoFx
- object OptionCreation extends OptionCreation
- object OptionEffect extends OptionEffect
- object OptionInterpretation extends OptionInterpretation
- object Rand extends Serializable
- object ReaderCreation extends ReaderCreation
- object ReaderEffect extends ReaderEffect
- object ReaderInterpretation extends ReaderInterpretation
- object SafeEffect extends SafeEffect
- object SafeInterpretation extends SafeInterpretation
- object StateCreation extends StateCreation
- object StateEffect extends StateEffect
- object StateImplicits extends StateImplicits
- object StateInterpretation extends StateInterpretation
-
object
SubscribeEffect
This effect is used in the implementation of the Async effect
- object Unions extends Serializable
- object ValidateCreation extends ValidateCreation
- object ValidateEffect extends ValidateEffect
- object ValidateInterpretation extends ValidateInterpretation
- object WriterCreation extends WriterCreation
- object WriterEffect extends WriterEffect
- object WriterInterpretation extends WriterInterpretation
- object all extends AsyncEffect with ReaderEffect with WriterEffect with StateEffect with EvalEffect with OptionEffect with ListEffect with EitherEffect with ValidateEffect with ChooseEffect with SafeEffect with Batch with EffInterpretation with EffCreation with EffImplicits
- object async extends AsyncCreation with AsyncInterpretation
- object batch extends Batch
- object choose extends ChooseCreation with ChooseInterpretation
- object create extends ReaderCreation with WriterCreation with StateCreation with EvalCreation with OptionCreation with ListCreation with EitherCreation with ValidateCreation with ChooseCreation with AsyncCreation with EffCreation with SafeCreation
- object eff extends EffCreation with EffInterpretation
- object either extends EitherCreation with EitherInterpretation with EitherImplicits
- object eval extends EvalCreation with EvalInterpretation
- object interpret extends Interpret with Batch
- object list extends ListCreation with ListInterpretation
- object option extends OptionCreation with OptionInterpretation
- object reader extends ReaderCreation with ReaderInterpretation
- object safe extends SafeCreation with SafeInterpretation
- object state extends StateCreation with StateInterpretation with StateImplicits
- object validate extends ValidateCreation with ValidateInterpretation
- object writer extends WriterCreation with WriterInterpretation