PolyStateEffect

turbolift.effects.PolyStateEffect
See thePolyStateEffect companion object
abstract class PolyStateEffect extends StateEffect Polymorphic_= Any

Polymorphic variant of StateEffect.

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

// The `S` is explicitly set as `Int`:
case object MyState extends StateEffect[Int]

// The `S` is inferred from the effect instance:
val computation = MyState.get

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

case object MyState extends PolyStateEffect

val computation1 = MyState.put(42)      // `S` inferred as `Int`
val computation2 = MyState.get[Int]     // `S` inferred as `Int`
val computation3 = MyState.get[String]  // `S` inferred as `String`

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

// Type error!
// Since `S` is invariant, compiler can't unify `S` as `Int` with `S` as `String`
val computation4 = computation2 &&! computation3

User must ensure that S is inferred as the same type at all call sites, within the scope delimited by this effect's handler. Otherwise, application of the handler will fail to typecheck.

Attributes

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

Members list

Type members

Classlikes

final class GetModifyEffApply[S]

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 GetModifyGetEffApply[S]

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 GetUpdateApply[S]

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 GetUpdateEffApply[S]

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 GetUpdateGetApply[S]

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 GetUpdateGetEffApply[S]

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 GetsApply[S]

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 GetsEffApply[S]

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 LocalModifyApply[S]

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 LocalModifyEffApply[S]

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 LocalPutApply[S]

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 LocalPutEffApply[S]

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 ModifyEffApply[S]

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 ModifyGetEffApply[S]

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 PutEffApply[S]

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 SwapEffApply[S]

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 UpdateApply[S]

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 UpdateEffApply[S]

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 UpdateGetApply[S]

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 UpdateGetEffApply[S]

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 get[S]: Computation[S, @@[S]]
final def getModify[S](f: S => S): Computation[S, @@[S]]
final def getModifyEff[S]: GetModifyEffApply[S]
final def getModifyGet[S](f: S => S): Computation[(S, S), @@[S]]
final def getUpdate[S]: GetUpdateApply[S]
final def getUpdateEff[S]: GetUpdateEffApply[S]
final def getUpdateGet[S]: GetUpdateGetApply[S]
final def gets[S]: GetsApply[S]
final def getsEff[S]: GetsEffApply[S]
def handler[S](initial: S): Handler[Identity, Tuple2, thiz.@@[S], Any]
Extension method from PolyStateEffect

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 localModify[S]: LocalModifyApply[S]
final def localPut[S]: LocalPutApply[S]
final def localPutEff[S]: LocalPutEffApply[S]
final def modify[S](f: S => S): Computation[Unit, @@[S]]
final def modifyEff[S]: ModifyEffApply[S]
final def modifyGet[S](f: S => S): Computation[S, @@[S]]
final def modifyGetEff[S]: ModifyGetEffApply[S]
final def put[S](s: S): Computation[Unit, @@[S]]
final def putEff[S]: PutEffApply[S]
final def swap[S](s: S): Computation[S, @@[S]]
final def swapEff[S]: SwapEffApply[S]
final def update[S]: UpdateApply[S]
final def updateEff[S]: UpdateEffApply[S]
final def updateGet[S]: UpdateGetApply[S]
final def updateGetEff[S]: UpdateGetEffApply[S]

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

Attributes

Inherited from:
Polymorphic_=