PolyResourceEffect

turbolift.effects.PolyResourceEffect
See thePolyResourceEffect companion object
abstract class PolyResourceEffect extends ResourceEffect Polymorphic_+ Any

Polymorphic variant of ResourceEffect.

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

// `The U` is explicitly set as `IO`:
case object MyResource extends ResourceEffect[IO]

// The `U` is inferred from the effect instance:
val computation = MyResource.register(IO(println("RESOURCE CLOSED!")))

In the polymorphic variant, the U type parameter is covariantly inferred at call sites of effect's operations and handlers:

case object MyResource extends PolyResourceEffect

// auxiliary definitions, because we need 2 distinct effects:
case object S1 extends StateEffect[Boolean]; type S1 = S1.type
case object S2 extends StateEffect[Boolean]; type S2 = S2.type

val computation1 = MyResource.register(S1.put(false))  // `U` inferred as `S1`
val computation2 = MyResource.register(S2.put(false))  // `U` inferred as `S2`
val computation3 = computation1 &&! computation2       // `U` inferred as `S1 & S2`

Attributes

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

Members list

Type members

Classlikes

final class ScopedApply[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

Supertypes
class Object
trait Matchable
class Any
final class UseApply[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

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

def handler[U]: Handler[Identity, Identity, thiz.@@[U], U]
Extension method from PolyResourceEffect

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 register[X](release: Computation[Unit, X]): Computation[Unit, @@[X]]
final def scoped[X]: ScopedApply[X]
final def use[X]: UseApply[X]

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: ResourceEffect[Any]

Attributes

Inherited from:
Polymorphic_+