# eff

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

2. #### case class Apps[R, A, B](functions: Vector[Eff[R, (Any) ⇒ Any]]) extends Product with Serializable

Sequence of applicative functions from A to B: Eff[R, A => B]

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

6. #### 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:

• 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:

• the result for a or b is List(a, b)

If F is Option then:

• the result for a or b is Some(a) or Some(b

12. #### trait DisjunctionEffect extends DisjunctionCreation with DisjunctionInterpretation

Effect for computation which can fail

14. #### 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 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!

18. #### sealed trait Effect[F[_]] extends AnyRef

one effect, basically a type constructor

20. #### 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 \/ 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.

24. #### trait EvalEffect extends EvalTypes with EvalCreation with EvalInterpretation

Effect for delayed computations

Effect for delayed computations

uses scalaz.Need as a supporting data structure

31. #### trait Fold[A, B] extends AnyRef

support trait for folding values while possibly keeping some internal state

33. #### trait FutureEffect extends FutureCreation with FutureInterpretation

Effect for Future computations

35. #### sealed trait Fx extends AnyRef

Base type for a tree of effect types

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

Append a tree of effects to another one

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

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

41. #### case class ImpureAp[R, X, A](union: Union[R, X], continuation: Apps[R, X, A]) extends Eff[R, A] with Product with Serializable

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

42. #### trait Interpret extends AnyRef

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)

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

49. #### trait ListEffect extends ListCreation with ListInterpretation

Effect for computations possibly returning several values

51. #### trait Member[T[_], R] extends MemberIn[T, R]

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

Annotations
@implicitNotFound( ... )

77. #### class NoFx extends Fx

The "empty" tree of effects

79. #### trait OptionEffect extends OptionCreation with OptionInterpretation

Effect for optional computations

82. #### trait ReaderCreation extends AnyRef

Effect for computations depending on an environment.

Effect for computations depending on an environment.

The inside datatype for this effect is scalaz.Reader

85. #### sealed trait Safe[A] extends AnyRef

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

91. #### trait StateEffect extends StateCreation with StateInterpretation

Effect for passing state along computations

Effect for passing state along computations

Internally backed up by scalaz.State

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

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

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

### Value Members

16. #### object ErrorEffect extends ErrorEffect[String]

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