Interface EffectTrait<Effect>
- Type Parameters:
Effect- The type on which this object gives an effect algebra.
We define an effect type to be a type whose values can be combined sequentially or concurrently, and which has
a known value representing the absence of an effect. An implementation of EffectTrait<P> provides
these operations for a type P, even if the definition of P itself cannot be changed.
We will often refer to an implementation of EffectTrait<P> as "an effect algebra on P".
A useful graphical notation is to write x | y for trait.concurrently(x, y) (when
trait is fixed), and x; y for trait.sequentially(x, y). Nested calls
to these methods can then be understood as expressions over these algebraic operators.
Implementors are required to obey the following contract, up to observable behavior. This contract captures the common-sense behavior expected of effects that occur over time.
sequentiallyis associative:(x; y); z == x; (y; z)concurrentlyis associative:(x | y) | z == x | (y | z)concurrentlyis commutative:x | y == y | xemptyis the identity for sequential composition:empty(); x == x == x; empty()emptyis the identity for concurrent composition:empty() | x == x == x | empty()
-
Method Summary
Modifier and TypeMethodDescriptionconcurrently(Effect left, Effect right) empty()sequentially(Effect prefix, Effect suffix)
-
Method Details
-
empty
Effect empty() -
sequentially
-
concurrently
-