Interface EffectExpression<Event>
- Type Parameters:
Event- The type of abstract effect in this expression.
- All Known Subinterfaces:
EventGraph<Event>
- All Known Implementing Classes:
EventGraph.Atom,EventGraph.Concurrently,EventGraph.Empty,EventGraph.Sequentially
public interface EffectExpression<Event>
Declares the ability of an object to be evaluated under an
EffectTrait.
Effect expressions describe a series-parallel graph of abstract effects called "events". The EventGraph class
is a concrete realization of this idea. However, if the expression is immediately consumed after construction,
the EventGraph imposes construction of needless intermediate data. Producers of effects will
typically want to return a custom implementor of this class that will directly produce the desired expression
for a given EffectTrait.
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<Effect> Effectevaluate(gov.nasa.jpl.aerie.merlin.protocol.model.EffectTrait<Effect> trait, Function<Event, Effect> substitution) Produce an effect in the domain of effects described by the provided trait and event substitution.default EventProduce an effect in the domain of effects described by the providedEffectTrait.default <TargetType>
EffectExpression<TargetType> Transform abstract effects without evaluating the expression.default <TargetType>
EffectExpression<TargetType> substitute(Function<Event, EffectExpression<TargetType>> transformation) Replace abstract effects with sub-expressions over other abstract effects.
-
Method Details
-
evaluate
<Effect> Effect evaluate(gov.nasa.jpl.aerie.merlin.protocol.model.EffectTrait<Effect> trait, Function<Event, Effect> substitution) Produce an effect in the domain of effects described by the provided trait and event substitution.- Type Parameters:
Effect- The type of effect produced by the visitor.- Parameters:
trait- A visitor to be used to compose effects in sequence or concurrently.substitution- A visitor to be applied at any atomic events.- Returns:
- The effect described by this object, within the provided domain of effects.
-
evaluate
Produce an effect in the domain of effects described by the providedEffectTrait.- Parameters:
trait- A visitor to be used to compose effects in sequence or concurrently.- Returns:
- The effect described by this object, within the provided domain of effects.
-
map
Transform abstract effects without evaluating the expression.This is a functorial "map" operation.
- Type Parameters:
TargetType- The type of abstract effect in the result expression.- Parameters:
transformation- A transformation to be applied to each event.- Returns:
- An equivalent expression over a different set of events.
-
substitute
default <TargetType> EffectExpression<TargetType> substitute(Function<Event, EffectExpression<TargetType>> transformation) Replace abstract effects with sub-expressions over other abstract effects.This is analogous to composing functions
f(x) = x + xandx(t) = 2*tto obtain(f.g)(t) = 2*t + 2*t. For example, for an expressionx; y, we may substitute1 | 2forxand3fory, yielding(1 | 2); 3.This is a monadic "bind" operation.
- Type Parameters:
TargetType- The type of abstract effect in the result expression.- Parameters:
transformation- A transformation from events to effect expressions.- Returns:
- An equivalent expression over a different set of events.
-