Package

org.specs2.control

eff

Permalink

package eff

Visibility
  1. Public
  2. All

Type Members

  1. case class Arrs[R, A, B](functions: Vector[(Any) ⇒ Eff[R, Any]]) extends 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]

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

    See also

    http://okmij.org/ftp/Haskell/extensible/more.pdf

  3. trait Effect[F[_]] extends AnyRef

    Permalink

    one effect, basically a type constructor

  4. trait Effects extends AnyRef

    Permalink

    Effects is a type level representing a list of effects which might take place in a computation

    Effects is a type level representing a list of effects which might take place in a computation

    Note that each "effect" is a type constructor

  5. final case class EffectsCons[F[_], T <: Effects](head: Effect[F], tail: T) extends Effects with Product with Serializable

    Permalink

    Append an effect at the beginning of a list of effects

  6. trait ErrorEffect[F] extends AnyRef

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

  7. case class Impure[R, X, A](union: Union[R, X], continuation: Arrs[R, X, A]) extends Eff[R, A] with Product with Serializable

    Permalink

    union is a disjoint union of effects returning a value of type X (not specified)

  8. trait Interpret extends AnyRef

    Permalink

    Support methods to create an interpreter (or "effect handlers") for a given Eff[M |: R, A].

    Support methods to create an interpreter (or "effect handlers") for a given Eff[M |: R, A]. The aim being to "consume" just that effect and produce a value of type B with possibly other effects: Eff[R, B]

    Those methods guarantee a stack-safe behaviour when running on a large list of effects (in a list.traverseU(f) for example).

    There are 3 different types of supported interpreters:

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

  9. trait Member[T[_], R] extends AnyRef

    Permalink

    Member typeclass for effects belonging to a stack of effects R

    Member typeclass for effects belonging to a stack of effects R

    If T is a member of R then we can:

    - create a Union of effects from a single effect with "inject" - extract an effect value from a union if there is such an effect in the stack

  10. trait MemberNat[T[_], R <: Effects, N <: Nat] extends AnyRef

    Permalink

    The rank of a member effects is modelled as a type-level natural and modelled by a value of that type

  11. sealed trait Nat extends AnyRef

    Permalink

    type level naturals

  12. sealed class NoEffect extends Effects

    Permalink

    Nil case for the list of effects

  13. case class P[N <: Nat]() extends Product with Serializable

    Permalink

    values with a phantom type representing a type-level natural

  14. case class Pure[R, A](value: A) extends Eff[R, A] with Product with Serializable

    Permalink
  15. trait Succ[N <: Nat] extends Nat

    Permalink
  16. trait Union[R, A] extends AnyRef

    Permalink

    Open union of effects

    Open union of effects

    They are modelled as a list of

    UnionNext(UnionNext(...(UnionNow(M[X])))

    where M[X] is an effect. The depth of the nesting in an Union value corresponds to the place of the effect in a type E1 |: E2 |: E3 |: .. |: NoEffect

  17. case class UnionNext[O[_], R <: Effects, A](u: Union[R, A]) extends Union[|:[O, R], A] with Product with Serializable

    Permalink
  18. case class UnionNow[T[_], R <: Effects, A](ta: T[A]) extends Union[|:[T, R], A] with Product with Serializable

    Permalink
  19. trait Zero extends Nat

    Permalink

Value Members

  1. object Arrs extends Serializable

    Permalink
  2. object ConsoleEffect

    Permalink
  3. object DisjunctionEffect

    Permalink

    Effect for computation which can fail

  4. object Eff

    Permalink
  5. object Effects

    Permalink

    Aliases for declaring effects with the following syntax

    Aliases for declaring effects with the following syntax

    A |: B |: C |: NoEffect

  6. object ErrorEffect extends ErrorEffect[String]

    Permalink

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

  7. object EvalEffect

    Permalink

    Effect for delayed computations

    Effect for delayed computations

    uses scalaz.Name as a data structure

  8. object Interpret extends Interpret

    Permalink
  9. object ListEffect

    Permalink

    Effect for computations possibly returning several values

  10. object Member

    Permalink
  11. object MemberNat

    Permalink
  12. object OptionEffect

    Permalink

    Effect for optional computations

  13. object P extends Serializable

    Permalink
  14. object ReaderEffect

    Permalink

    Effect for computations depending on an environment.

    Effect for computations depending on an environment.

    The inside datatype for this effect is scalaz.Reader

    Several Reader effects can be present in a given stack provided that they are tagged with scala.Tag.

    A tagged Reader effect can be run with runTaggedReader

  15. object StateEffect

    Permalink

    Effect for passing state along computations

    Effect for passing state along computations

    Several state effects can be used in the same stack if they are tagged

    Internally backed up by scalaz.State

  16. object Union

    Permalink

    create union objects

  17. object WarningsEffect

    Permalink
  18. object WriterEffect

    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

    Several writer effects can be used in the same stack if they are tagged.

Ungrouped