Package

org.specs2.control

eff

Permalink

package eff

Linear Supertypes
AnyRef, Any
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]

    Permalink
  2. type <=[M[_], R] = Member[M, R]

    Permalink
  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

    Permalink
  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

    Permalink
  5. trait Augment[T[_], O[_]] extends AnyRef

    Permalink
  6. trait Cache extends AnyRef

    Permalink

    This cache is used to memoize values for the Memoized effect

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

    Permalink

    Collection of effects of a given type from a Unions objects

  8. case class ConcurrentHashMapCache(map: ConcurrentHashMap[AnyRef, Evaluated[Any]] = ...) extends Cache with Product with Serializable

    Permalink
  9. class ConcurrentWeakIdentityHashMap[K, V] extends ConcurrentMap[K, V]

    Permalink

  10. case class ConcurrentWeakIdentityHashMapCache(map: ConcurrentWeakIdentityHashMap[AnyRef, Evaluated[Any]] = ...) extends Cache with Product with Serializable

    Permalink
  11. 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

    Permalink

    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

  12. sealed trait Eff[R, A] extends AnyRef

    Permalink

    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

  13. trait EffCreation extends AnyRef

    Permalink
  14. trait EffImplicits extends AnyRef

    Permalink
  15. trait EffInterpretation extends AnyRef

    Permalink
  16. sealed trait Effect[R, A] extends AnyRef

    Permalink

    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++.
  17. trait ErrorCreation[F] extends ErrorTypes[F]

    Permalink
  18. trait ErrorEffect[F] extends ErrorCreation[F] with ErrorInterpretation[F]

    Permalink

    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.

  19. trait ErrorInterpretation[F] extends ErrorCreation[F]

    Permalink
  20. trait ErrorTypes[F] extends AnyRef

    Permalink
  21. case class Evaluate[F, A](run: Either[Either[Throwable, F], () ⇒ A]) extends Product with Serializable

    Permalink
  22. case class EvaluateValue[A](run: () ⇒ A) extends Safe[A] with Product with Serializable

    Permalink
  23. trait Evaluated[+T] extends AnyRef

    Permalink
  24. case class FailedFinalizer(t: Throwable) extends Safe[Unit] with Product with Serializable

    Permalink
  25. case class FailedValue[A](t: Throwable) extends Safe[A] with Product with Serializable

    Permalink
  26. trait FutureCreation extends FutureTypes

    Permalink
  27. trait FutureEffect extends FutureCreation with FutureInterpretation

    Permalink
  28. trait FutureInterpretation extends FutureTypes

    Permalink
  29. trait FutureTypes extends AnyRef

    Permalink
  30. sealed trait Fx extends AnyRef

    Permalink

    Base type for a tree of effect types

  31. trait Fx1[+F[_]] extends Fx

    Permalink
  32. trait Fx2[+L[_], +R[_]] extends Fx

    Permalink
  33. trait Fx3[+L[_], +M[_], +R[_]] extends Fx

    Permalink
  34. final case class FxAppend[L, R](left: L, right: R) extends Fx with Product with Serializable

    Permalink

    Append a tree of effects to another one

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

    Permalink

    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

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

    Permalink

    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
  37. trait Interpret extends AnyRef

    Permalink

    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

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

    Permalink

    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.

  39. trait IntoPoly[R, U] extends AnyRef

    Permalink

    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

  40. trait IntoPolyLower1 extends IntoPolyLower2

    Permalink
  41. trait IntoPolyLower2 extends IntoPolyLower3

    Permalink
  42. trait IntoPolyLower3 extends IntoPolyLower4

    Permalink
  43. trait IntoPolyLower4 extends IntoPolyLower5

    Permalink
  44. trait IntoPolyLower5 extends AnyRef

    Permalink
  45. case class Last[R](value: Option[Name[Eff[R, Unit]]]) extends Product with Serializable

    Permalink

    Encapsulation of one optional last action to execute at the end of the program

  46. trait Member[T[_], R] extends MemberInOut[T, R]

    Permalink
    Annotations
    @implicitNotFound( ... )
  47. trait MemberIn[T[_], R] extends AnyRef

    Permalink
    Annotations
    @implicitNotFound( ... )
  48. trait MemberInLower1 extends MemberInLower2

    Permalink
  49. trait MemberInLower2 extends MemberInLower3

    Permalink
  50. trait MemberInLower3 extends MemberInLower4

    Permalink
  51. trait MemberInLower4 extends MemberInLower5

    Permalink
  52. trait MemberInLower5 extends AnyRef

    Permalink
  53. trait MemberInOut[T[_], R] extends MemberIn[T, R]

    Permalink
    Annotations
    @implicitNotFound( ... )
  54. trait MemberInOutLower1 extends MemberInOutLower2

    Permalink
  55. trait MemberInOutLower2 extends MemberInOutLower3

    Permalink
  56. trait MemberInOutLower3 extends MemberInOutLower4

    Permalink
  57. trait MemberInOutLower4 extends MemberInOutLower5

    Permalink
  58. trait MemberInOutLower5 extends AnyRef

    Permalink
  59. trait MemberLower1 extends MemberLower2

    Permalink
  60. trait MemberLower10 extends MemberLower11

    Permalink
  61. trait MemberLower11 extends MemberLower12

    Permalink
  62. trait MemberLower12 extends MemberLower13

    Permalink
  63. trait MemberLower13 extends MemberLower14

    Permalink
  64. trait MemberLower14 extends MemberLower15

    Permalink
  65. trait MemberLower15 extends MemberLower16

    Permalink
  66. trait MemberLower16 extends MemberLower17

    Permalink
  67. trait MemberLower17 extends MemberLower18

    Permalink
  68. trait MemberLower18 extends MemberLower19

    Permalink
  69. trait MemberLower19 extends AnyRef

    Permalink
  70. trait MemberLower2 extends MemberLower3

    Permalink
  71. trait MemberLower3 extends MemberLower4

    Permalink
  72. trait MemberLower4 extends MemberLower5

    Permalink
  73. trait MemberLower5 extends MemberLower6

    Permalink
  74. trait MemberLower6 extends MemberLower7

    Permalink
  75. trait MemberLower7 extends MemberLower8

    Permalink
  76. trait MemberLower8 extends MemberLower9

    Permalink
  77. trait MemberLower9 extends MemberLower10

    Permalink
  78. case class Memoized[T](t: () ⇒ T) extends Evaluated[T] with Product with Serializable

    Permalink
  79. case class NoEffect[R, A](a: A) extends Effect[R, A] with Product with Serializable

    Permalink
  80. class NoFx extends Fx

    Permalink

    The "empty" tree of effects

  81. case class Pure[R, A](value: A, last: Last[R] = Last.none[R]) extends Eff[R, A] with Product with Serializable

    Permalink
  82. trait Recurser[M[_], R, A, B] extends AnyRef

    Permalink

    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

  83. trait RightFold[A, B] extends AnyRef

    Permalink

    support trait for folding values while possibly keeping some internal state

  84. sealed trait Safe[A] extends AnyRef

    Permalink

    The Safe type is a mix of a ThrowableEither / Eval effect and a writer effect to collect finalizer failures

  85. trait SafeCreation extends SafeTypes

    Permalink
  86. trait SafeEffect extends SafeCreation with SafeInterpretation

    Permalink
  87. trait SafeInterpretation extends SafeCreation

    Permalink
  88. trait SafeTypes extends AnyRef

    Permalink
  89. trait SequenceCached[M[_]] extends AnyRef

    Permalink

    type class for effects which can be cached in a SequenceCache

  90. trait SideEffect[T[_]] extends AnyRef

    Permalink
  91. final case class TaggedMemberIn[T[_], R](tag: Int) extends MemberIn[T, R] with Product with Serializable

    Permalink
  92. final case class TaggedMemberInOut[T[_], R](tag: Int) extends MemberInOut[T, R] with Product with Serializable

    Permalink
  93. final case class TimedFuture[A](callback: (ExecutorServices) ⇒ Future[A], timeout: Option[FiniteDuration] = None) extends Product with Serializable

    Permalink
  94. trait Translate[T[_], U] extends AnyRef

    Permalink

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

  95. sealed trait Union[R, A] extends Effect[R, A]

    Permalink
  96. case class UnionAppendL[L, R, A](value: Union[L, A]) extends Union[FxAppend[L, R], A] with Product with Serializable

    Permalink
  97. case class UnionAppendR[L, R, A](value: Union[R, A]) extends Union[FxAppend[L, R], A] with Product with Serializable

    Permalink
  98. trait UnionInto[R, S] extends AnyRef

    Permalink

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

  99. case class UnionTagged[R, A](valueUnsafe: Any, index: Int) extends Union[R, A] with Product with Serializable

    Permalink
  100. case class Unions[R, A](first: Union[R, A], rest: Vector[Union[R, Any]]) extends Product with Serializable

    Permalink

    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

  101. trait Write[T[_], O] extends AnyRef

    Permalink
  102. case class Writer[O, A](value: O, a: A) extends Product with Serializable

    Permalink
  103. trait WriterCreation extends AnyRef

    Permalink
  104. trait WriterEffect extends WriterCreation with WriterInterpretation

    Permalink

    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
  105. trait WriterInterpretation extends AnyRef

    Permalink
  106. type |=[M[_], R] = MemberIn[M, R]

    Permalink

Value Members

  1. object ConsoleEffect

    Permalink
  2. object Continuation extends Serializable

    Permalink
  3. object Eff extends EffCreation with EffInterpretation with EffImplicits

    Permalink
  4. object EffCreation extends EffCreation

    Permalink
  5. object EffImplicits extends EffImplicits

    Permalink
  6. object EffInterpretation extends EffInterpretation

    Permalink
  7. object ErrorEffect extends ErrorEffect[String]

    Permalink

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

  8. object Evaluate extends Serializable

    Permalink
  9. object FutureCreation extends FutureCreation

    Permalink
  10. object FutureEffect extends FutureEffect

    Permalink
  11. object FutureInterpretation extends FutureInterpretation

    Permalink
  12. object Fx

    Permalink
  13. object Interpret extends Interpret

    Permalink
  14. object Interpreter

    Permalink
  15. object IntoPoly extends IntoPolyLower1

    Permalink
  16. object Last extends Serializable

    Permalink
  17. object Member extends MemberLower1

    Permalink
  18. object MemberIn extends MemberInLower1

    Permalink
  19. object MemberInOut extends MemberInOutLower1

    Permalink
  20. object Memoized extends Serializable

    Permalink
  21. object NoFx extends NoFx

    Permalink
  22. object Now

    Permalink
  23. object Safe

    Permalink
  24. object SafeEffect extends SafeEffect

    Permalink
  25. object SafeInterpretation extends SafeInterpretation

    Permalink
  26. object TimedFuture extends Serializable

    Permalink
  27. object Union

    Permalink
  28. object Unions extends Serializable

    Permalink
  29. object WarningsEffect

    Permalink
  30. object Writer extends Serializable

    Permalink
  31. object WriterCreation extends WriterCreation

    Permalink
  32. object WriterEffect extends WriterEffect

    Permalink
  33. object WriterInterpretation extends WriterInterpretation

    Permalink
  34. object all extends WriterEffect with SafeEffect with EffInterpretation with EffCreation with EffImplicits

    Permalink
  35. object create extends WriterCreation with SafeCreation with EffCreation

    Permalink
  36. object eff extends EffCreation with EffInterpretation

    Permalink
  37. object interpret extends Interpret

    Permalink
  38. object safe extends SafeCreation with SafeInterpretation

    Permalink
  39. package syntax

    Permalink
  40. object writer extends WriterCreation with WriterInterpretation

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped