Packages

package eff

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. eff
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type /=[M[_], R] = MemberInOut[M, R]
  2. type <=[M[_], R] = Member[M, R]
  3. final case class AppendMemberIn [T[_], L, R, X](isRight: Boolean, member: MemberIn[T, X]) extends MemberIn[T, FxAppend[L, R]] with Product with Serializable
  4. final case class AppendMemberInOut [T[_], L, R, X](isRight: Boolean, append: MemberInOut[T, X]) extends MemberInOut[T, FxAppend[L, R]] with Product with Serializable
  5. trait Augment [T[_], O[_]] extends AnyRef
  6. 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

  7. trait Batchable [T[_]] extends AnyRef
  8. trait Cache extends AnyRef

    This cache is used to memoize values for the Memoized effect

  9. sealed trait Choose [T] extends AnyRef
  10. trait ChooseCreation extends AnyRef
  11. 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
  12. trait ChooseImplicits extends AnyRef
  13. trait ChooseInterpretation extends AnyRef
  14. case class ChooseZero [T]() extends Choose[T] with Product with Serializable
  15. case class CollectedUnions [M[_], R, U](effects: Vector[M[Any]], otherEffects: Vector[Union[U, Any]], indices: Vector[Int], otherIndices: Vector[Int]) extends Product with Serializable

    Collection of effects of a given type from a Unions objects

  16. case class ConcurrentHashMapCache (map: ConcurrentHashMap[AnyRef, Eval[Any]] = ...) extends Cache with Product with Serializable
  17. class ConcurrentWeakIdentityHashMap [K, V] extends ConcurrentMap[K, V]

  18. case class ConcurrentWeakIdentityHashMapCache (map: ConcurrentWeakIdentityHashMap[AnyRef, Eval[Any]] = ...) extends Cache with Product with Serializable
  19. case class Continuation [R, A, B](functions: Vector[(Any) ⇒ Eff[R, Any]], onNone: Last[R] = Last.none[R]) 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]

    An alternate unit value can also be set on this function in case the argument A is not available. This value can be set by an effect to do some cleanup if it doesn't even get the chance to add its own effect. See SafeEffect.bracket

  20. case class Correct [E]() extends Validate[E, Unit] with Product with Serializable
  21. 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 Arrs type
    • 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:

    • point is Pure
    • bind simply appends the binding function to the Arrs continuation

    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 .asInstanceOf are 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

  22. trait EffCreation extends AnyRef
  23. trait EffImplicits extends AnyRef
  24. trait EffInterpretation extends AnyRef
  25. sealed trait Effect [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

    The effect tree is represented by four possible cases:

    • fx1[T]
    • fx2[T1, T2]
    • fx3[T1, T2, T3]
    • FxAppend[L, R]

    The union type has three concrete constructors:

    • UnionAppendL(nested: Union[L]): Union[FxAppend[L, R]]
    • UnionAppendR(nested: Union[R]): Union[FxAppend[L, R]]
    • UnionTagged(valueUnsafe: Any, index: Int): Union[R] (for R in fx1, fx2, fx3...) In that respect UnionTagged behaves similarly to a tagged union in C or C++.
  26. trait EitherCreation extends AnyRef
  27. trait EitherEffect extends EitherCreation with EitherInterpretation

    Effect for computation which can fail

  28. trait EitherImplicits extends AnyRef
  29. trait EitherInterpretation extends AnyRef
  30. trait ErrorCreation [F] extends ErrorTypes[F]
  31. 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.

  32. trait ErrorInterpretation [F] extends ErrorCreation[F]
  33. trait ErrorTypes [F] extends AnyRef
  34. trait EvalCreation extends EvalTypes
  35. trait EvalEffect extends EvalTypes with EvalCreation with EvalInterpretation

    Effect for delayed computations

    Effect for delayed computations

    uses cats.Eval as a supporting data structure

  36. trait EvalInterpretation extends EvalTypes
  37. trait EvalTypes extends AnyRef
  38. case class Evaluate [F, A](run: Either[Either[Throwable, F], Eval[A]]) extends Product with Serializable
  39. case class EvaluateValue [A](run: Eval[A]) extends Safe[A] with Product with Serializable
  40. case class ExecutorServices (executorServiceEval: Eval[ExecutorService], scheduledExecutorEval: Eval[ScheduledExecutorService], executionContextEval: Eval[ExecutionContext]) extends Product with Serializable
  41. case class FailedFinalizer (t: Throwable) extends Safe[Unit] with Product with Serializable
  42. case class FailedValue [A](t: Throwable) extends Safe[A] with Product with Serializable
  43. trait FutureCreation extends FutureTypes
  44. trait FutureEffect extends FutureCreation with FutureInterpretation
  45. trait FutureInterpretation extends FutureTypes
  46. trait FutureTypes extends AnyRef
  47. sealed trait Fx extends AnyRef

    Base type for a tree of effect types

  48. trait Fx1 [+F[_]] extends Fx
  49. trait Fx2 [+L[_], +R[_]] extends Fx
  50. trait Fx3 [+L[_], +M[_], +R[_]] extends Fx
  51. trait FxAppend [+L, +R] extends Fx

    Append a tree of effects to another one

  52. case class GetCache () extends Memoized[Cache] with Product with Serializable
  53. case class Impure [R, X, A](union: Effect[R, X], continuation: Continuation[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

  54. case class ImpureAp [R, X, A](unions: Unions[R, X], continuation: Continuation[R, Vector[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: Vector[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
  55. trait Interpret extends AnyRef

    The Interpret trait provides method to interpret (or "handle") effects.

    The Interpret trait provides method to interpret (or "handle") effects.

    An interpreter generally handles a given effect M and a value Eff[R, A] where M is a member of R.

    The most general way of interpreting an effect is to implement the Interpreter trait for that effect and use the runInterpreter method. With the Interpreter trait you need to define:

    • what to do with pure values
    • what to do with an effect
    • what to do with a list of effects (the "applicative" case)
    • what to do with a "last" effect, in case of having side-effects to finalize resources (see the SafeEffect)

    For each of those methods you get access to a continuation which you may or may not invoke to create the next effect in a sequence of effects. For example with the EitherEffect once you arrive on a Left value you don't trigger the continuation because there is no value to trigger it with.

    There are also easier ways to define interpreters. The recurse method and the Recurser trait define:

    • onPure(a: A): B: how to map a pure value A to the result B
    • onEffect[X](mx: M[X]): X Either Eff[R, B]: either extract a value from the effect or return another effect
    • onApplicative[X](tx: T[M[X]]): T[X] Either M[T[X]]: either extract individual values from each effect or "sequence" the effect

    Even simpler, the Translate trait does a translation from an effect M[X] to other effects in the stack.

    There are also a few intercept methods to use an effect but still leave it in the stack

  56. trait Interpreter [M[_], R, A, B] extends AnyRef

    Interpret eff values

    Interpret eff values

    For stack-safety reasons, the continuation must *never* be called with a value directly, but always with Eff.impure:

    Eff.impure(a, continuation)

    * *Note* it is the responsibility of the implementation to call continuation.onNone if the continuation is not used to create the return value.

  57. 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

  58. trait IntoPolyLower1 extends IntoPolyLower2
  59. trait IntoPolyLower2 extends IntoPolyLower3
  60. trait IntoPolyLower3 extends IntoPolyLower4
  61. trait IntoPolyLower4 extends IntoPolyLower5
  62. trait IntoPolyLower5 extends AnyRef
  63. 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

  64. trait ListCreation extends AnyRef
  65. trait ListEffect extends ListCreation with ListInterpretation

    Effect for computations possibly returning several values

  66. trait ListInterpretation extends AnyRef
  67. trait Member [T[_], R] extends MemberInOut[T, R]
    Annotations
    @implicitNotFound( ... )
  68. trait MemberIn [T[_], R] extends AnyRef
    Annotations
    @implicitNotFound( ... )
  69. trait MemberInLower1 extends MemberInLower2
  70. trait MemberInLower2 extends MemberInLower3
  71. trait MemberInLower3 extends MemberInLower4
  72. trait MemberInLower4 extends MemberInLower5
  73. trait MemberInLower5 extends AnyRef
  74. trait MemberInOut [T[_], R] extends MemberIn[T, R]
    Annotations
    @implicitNotFound( ... )
  75. trait MemberInOutLower1 extends MemberInOutLower2
  76. trait MemberInOutLower2 extends MemberInOutLower3
  77. trait MemberInOutLower3 extends MemberInOutLower4
  78. trait MemberInOutLower4 extends MemberInOutLower5
  79. trait MemberInOutLower5 extends AnyRef
  80. trait MemberLower1 extends MemberLower2
  81. trait MemberLower10 extends MemberLower11
  82. trait MemberLower11 extends MemberLower12
  83. trait MemberLower12 extends MemberLower13
  84. trait MemberLower13 extends MemberLower14
  85. trait MemberLower14 extends MemberLower15
  86. trait MemberLower15 extends MemberLower16
  87. trait MemberLower16 extends MemberLower17
  88. trait MemberLower17 extends MemberLower18
  89. trait MemberLower18 extends MemberLower19
  90. trait MemberLower19 extends AnyRef
  91. trait MemberLower2 extends MemberLower3
  92. trait MemberLower3 extends MemberLower4
  93. trait MemberLower4 extends MemberLower5
  94. trait MemberLower5 extends MemberLower6
  95. trait MemberLower6 extends MemberLower7
  96. trait MemberLower7 extends MemberLower8
  97. trait MemberLower8 extends MemberLower9
  98. trait MemberLower9 extends MemberLower10
  99. trait MemoCreation extends MemoTypes
  100. trait MemoEffect extends MemoTypes with MemoCreation with MemoInterpretation

    Memoization effect

    Memoization effect

    Memoize a computation for a given key

    This effect can be interpreted with a cache implemented with many different libraries. See Cache.scala for 2 default implementations:

    • one concurrent hashmap (meaning an unbounded cache)
    • one concurrent hashmap with weak references (to evict entries based on garbage collection)

    You can implement your own version using ScalaCache for example

  101. trait MemoInterpretation extends MemoTypes
  102. trait MemoTypes extends AnyRef
  103. sealed trait Memoized [A] extends AnyRef
  104. case class NoEffect [R, A](a: A) extends Effect[R, A] with Product with Serializable
  105. class NoFx extends Fx

    The "empty" tree of effects

  106. trait OptionCreation extends AnyRef
  107. trait OptionEffect extends OptionCreation with OptionInterpretation

    Effect for optional computations

  108. trait OptionInterpretation extends AnyRef
  109. case class Pure [R, A](value: A, last: Last[R] = Last.none[R]) extends Eff[R, A] with Product with Serializable
  110. 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

  111. trait ReaderCreation extends AnyRef
  112. 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

  113. trait ReaderInterpretation extends AnyRef
  114. trait Recurser [M[_], R, A, B] 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

  115. trait RightFold [A, B] extends AnyRef

    support trait for folding values while possibly keeping some internal state

  116. 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

  117. trait SafeCreation extends SafeTypes
  118. trait SafeEffect extends SafeCreation with SafeInterpretation
  119. trait SafeInterpretation extends SafeCreation
  120. trait SafeTypes extends AnyRef
  121. trait SequenceCached [M[_]] extends AnyRef

    type class for effects which can be cached in a SequenceCache

  122. trait SideEffect [T[_]] extends AnyRef
  123. trait StateCreation extends AnyRef
  124. 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

  125. trait StateImplicits extends AnyRef
  126. trait StateInterpretation extends AnyRef
  127. case class Store [A](key: AnyRef, a: () ⇒ A) extends Memoized[A] with Product with Serializable
  128. final case class TaggedMemberIn [T[_], R](tag: Int) extends MemberIn[T, R] with Product with Serializable
  129. final case class TaggedMemberInOut [T[_], R](tag: Int) extends MemberInOut[T, R] with Product with Serializable
  130. final case class TimedFuture [A](callback: (Scheduler, ExecutionContext) ⇒ Future[A], timeout: Option[FiniteDuration] = None) extends Product with Serializable
  131. trait Translate [T[_], U] extends AnyRef

    trait for translating one effect into other ones in the same stack

  132. sealed trait Union [R, A] extends Effect[R, A]
  133. case class UnionAppendL [L, R, A](value: Union[L, A]) extends Union[FxAppend[L, R], A] with Product with Serializable
  134. case class UnionAppendR [L, R, A](value: Union[R, A]) extends Union[FxAppend[L, R], A] with Product with Serializable
  135. trait UnionInto [R, S] extends AnyRef

    transform a Union for a given stack into a Union for another stack

  136. case class UnionTagged [R, A](valueUnsafe: Any, index: Int) extends Union[R, A] with Product with Serializable
  137. case class Unions [R, A](first: Union[R, A], rest: Vector[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

  138. sealed trait Validate [+E, A] extends AnyRef
  139. trait ValidateCreation extends AnyRef
  140. 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

  141. trait ValidateInterpretation extends ValidateCreation
  142. trait Write [T[_], O] extends AnyRef
  143. trait WriterCreation extends AnyRef
  144. 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
  145. trait WriterInterpretation extends AnyRef
  146. case class Wrong [E](e: E) extends Validate[E, Unit] with Product with Serializable
  147. type |=[M[_], R] = MemberIn[M, R]

Value Members

  1. object Batch extends Batch
  2. object ChooseCreation extends ChooseCreation
  3. object ChooseEffect extends ChooseEffect
  4. object ChooseImplicits extends ChooseImplicits
  5. object ChooseInterpretation extends ChooseInterpretation
  6. object ChoosePlus extends Choose[Boolean] with Product with Serializable
  7. object Continuation extends Serializable
  8. object Eff extends EffCreation with EffInterpretation with EffImplicits
  9. object EffCreation extends EffCreation
  10. object EffImplicits extends EffImplicits
  11. object EffInterpretation extends EffInterpretation
  12. object EitherCreation extends EitherCreation
  13. object EitherEffect extends EitherEffect
  14. object EitherImplicits extends EitherImplicits
  15. object EitherInterpretation extends EitherInterpretation
  16. object ErrorEffect extends ErrorEffect[String]

    Simple instantiation of the ErrorEffect trait with String as a Failure type

  17. object EvalEffect extends EvalEffect
  18. object EvalInterpretation extends EvalInterpretation
  19. object EvalTypes extends EvalTypes
  20. object Evaluate extends Serializable
  21. object ExecutorServices extends Schedulers with Serializable
  22. object FutureCreation extends FutureCreation
  23. object FutureEffect extends FutureEffect
  24. object FutureInterpretation extends FutureInterpretation
  25. object Fx
  26. object Interpret extends Interpret
  27. object Interpreter
  28. object IntoPoly extends IntoPolyLower1
  29. object Last extends Serializable
  30. object ListCreation extends ListCreation
  31. object ListEffect extends ListEffect
  32. object ListInterpretation extends ListInterpretation
  33. object Member extends MemberLower1
  34. object MemberIn extends MemberInLower1
  35. object MemberInOut extends MemberInOutLower1
  36. object MemoEffect extends MemoEffect
  37. object MemoInterpretation extends MemoInterpretation
  38. object MemoTypes extends MemoTypes
  39. object NoFx extends NoFx
  40. object OptionCreation extends OptionCreation
  41. object OptionEffect extends OptionEffect
  42. object OptionInterpretation extends OptionInterpretation
  43. object Rand extends Serializable
  44. object ReaderCreation extends ReaderCreation
  45. object ReaderEffect extends ReaderEffect
  46. object ReaderInterpretation extends ReaderInterpretation
  47. object Safe
  48. object SafeEffect extends SafeEffect
  49. object SafeInterpretation extends SafeInterpretation
  50. object StateCreation extends StateCreation
  51. object StateEffect extends StateEffect
  52. object StateImplicits extends StateImplicits
  53. object StateInterpretation extends StateInterpretation
  54. object SubscribeEffect

    This effect is used in the implementation of the Async effect

  55. object TimedFuture extends Serializable
  56. object Union
  57. object Unions extends Serializable
  58. object ValidateCreation extends ValidateCreation
  59. object ValidateEffect extends ValidateEffect
  60. object ValidateInterpretation extends ValidateInterpretation
  61. object WriterCreation extends WriterCreation
  62. object WriterEffect extends WriterEffect
  63. object WriterInterpretation extends WriterInterpretation
  64. object all extends ReaderEffect with WriterEffect with StateEffect with EvalEffect with OptionEffect with ListEffect with EitherEffect with ValidateEffect with ChooseEffect with SafeEffect with MemoEffect with Batch with EffInterpretation with EffCreation with EffImplicits
  65. object batch extends Batch
  66. object choose extends ChooseCreation with ChooseInterpretation
  67. object create extends ReaderCreation with WriterCreation with StateCreation with EvalCreation with OptionCreation with ListCreation with EitherCreation with ValidateCreation with ChooseCreation with FutureCreation with MemoCreation with EffCreation with SafeCreation
  68. object eff extends EffCreation with EffInterpretation
  69. object either extends EitherCreation with EitherInterpretation with EitherImplicits
  70. object eval extends EvalCreation with EvalInterpretation
  71. object future extends FutureCreation with FutureInterpretation
  72. object interpret extends Interpret with Batch
  73. object list extends ListCreation with ListInterpretation
  74. object memo extends MemoCreation with MemoInterpretation
  75. object option extends OptionCreation with OptionInterpretation
  76. object reader extends ReaderCreation with ReaderInterpretation
  77. object safe extends SafeCreation with SafeInterpretation
  78. object state extends StateCreation with StateInterpretation with StateImplicits
  79. object validate extends ValidateCreation with ValidateInterpretation
  80. object writer extends WriterCreation with WriterInterpretation

Inherited from AnyRef

Inherited from Any

Ungrouped