PolyErrorEffect

turbolift.effects.PolyErrorEffect
See thePolyErrorEffect companion object
abstract class PolyErrorEffect extends ErrorEffect Polymorphic_- Any

Polymorphic variant of ErrorEffect.

In the monomorphic variant, the E type parameter is supplied during creation of an instance of the effect:

// The `E` is explicitly set as `String`:
case object MyError extends ErrorEffect[String]

// The `E` is inferred from the effect instance:
val computation = Myerror.raise("OMG")

In the polymorphic variant, the E type parameter is contravariantly inferred at call sites of effect's operations and handlers. In practice, the type can "grow as you go":

case object MyError extends PolyErrorEffect

val computation1 = MyError.raise(42)              // `E` inferred as `Int`
val computation2 = MyError.raise("OMG")           // `E` inferred as `String`
val computation3 = computation1 &&! computation2  // `E` inferred as `Int | String`

// Inferred types of the above computations:
val _: Nothing !! MyError.@@[Int]          = computation1
val _: Nothing !! MyError.@@[String]       = computation2
val _: Nothing !! MyError.@@[Int | String] = computation3

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Error

Members list

Type members

Classlikes

final class CatchAllApply[E]

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Attributes

Supertypes
class Object
trait Matchable
class Any
final class CatchAllEffApply[E]

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Attributes

Supertypes
class Object
trait Matchable
class Any
final class CatchSomeApply[E]

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Attributes

Supertypes
class Object
trait Matchable
class Any
final class CatchSomeEffApply[E]

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Attributes

Supertypes
class Object
trait Matchable
class Any
final class CatchToEitherApply[E]

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Attributes

Supertypes
class Object
trait Matchable
class Any
object handlers

Predefined handlers for this effect.

Predefined handlers for this effect.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
handlers.type

Inherited classlikes

final class Polymorphize[X]

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Helper class for partial type application. Won't be needed in future Scala (SIP-47).

Attributes

Inherited from:
Polymorphic_-
Supertypes
class Object
trait Matchable
class Any

Inherited and Abstract types

type @@[-X]

Read as Apply

Read as Apply

This effect, but with given type parameter applied.

Attributes

Inherited from:
Polymorphic_-

Value members

Concrete methods

final def catchAll[E]: CatchAllApply[E]
final def catchAllEff[E]: CatchAllEffApply[E]
final def catchSome[E]: CatchSomeApply[E]
final def catchSomeEff[E]: CatchSomeEffApply[E]
final def fromEither[A, E](x: Either[E, A]): Computation[A, @@[E]]
final def fromOption[A, E](x: Option[A])(e: => E): Computation[A, @@[E]]
final def fromTry[A, E](x: Try[A])(using ev: Throwable <:< E): Computation[A, @@[E]]
def handler[E]: Handler[Identity, [_] =>> Either[E, _$24], thiz.@@[E], Any]
Extension method from PolyErrorEffect

Alias of the default handler for this effect.

Alias of the default handler for this effect.

Defined as an extension, to allow custom redefinitions without restrictions imposed by overriding

Attributes

final def raise[E](e: E): Computation[Nothing, @@[E]]

Inherited methods

inline def polymorphize[X]: Polymorphize[X]

API for defining custom effects.

API for defining custom effects.

Attributes

Inherited from:
Polymorphic_-

Inherited fields

protected val monomorphic: ErrorEffect[Any]

Attributes

Inherited from:
Polymorphic_-